code: def get_retention_data(self):  # pylint: disable=too-many-branches,too-many-statements
          # pylint: disable=too-many-locals
          
          retention_data = {
              'hosts': {}, 'services': {}
          }
          for host in self.hosts:
              h_dict = {}
  
              # Get the hosts properties and running properties
              properties = host.__class__.properties
              properties.update(host.__class__.running_properties)
              for prop, entry in list(properties.items()):
                  if not entry.retention:
                      continue
  
                  val = getattr(host, prop)
                  # If a preparation function exists...
                  prepare_retention = entry.retention_preparation
                  if prepare_retention:
                      val = prepare_retention(host, val)
                  h_dict[prop] = val
  
              retention_data['hosts'][host.host_name] = h_dict
          logger.info('%d hosts sent to retention', len(retention_data['hosts']))
  
          # Same for services
          for service in self.services:
              s_dict = {}
  
              # Get the services properties and running properties
              properties = service.__class__.properties
              properties.update(service.__class__.running_properties)
              for prop, entry in list(properties.items()):
                  if not entry.retention:
                      continue
  
                  val = getattr(service, prop)
                  # If a preparation function exists...
                  prepare_retention = entry.retention_preparation
                  if prepare_retention:
                      val = prepare_retention(service, val)
                  s_dict[prop] = val
  
              retention_data['services'][(service.host_name, service.service_description)] = s_dict
          logger.info('%d services sent to retention', len(retention_data['services']))
  
          return retention_data
docs: Get all hosts and services data to be sent to the retention storage.
  
          This function only prepares the data because a module is in charge of making
          the data survive to the scheduler restart.
  
          todo: Alignak scheduler creates two separate dictionaries: hosts and services
          It would be better to merge the services into the host dictionary!
  
          :return: dict containing host and service data
          :rtype: dict