def prepare_dispatch(self):
        # pylint:disable=too-many-branches, too-many-statements, too-many-locals
        """
        Prepare dispatch, so prepare for each daemon (schedulers, brokers, receivers, reactionners,
        pollers)

        This function will only prepare something if self.new_to_dispatch is False
        It will reset the first_dispatch_done flag

        A DispatcherError exception is raised if a configuration is already prepared! Unset the
        new_to_dispatch flag before calling!

        :return: None
        """
        if self.new_to_dispatch:
            raise DispatcherError("A configuration is already prepared!")

        # So we are preparing a new dispatching...
        self.new_to_dispatch = True
        self.first_dispatch_done = False

        # Update Alignak name for all the satellites
        for daemon_link in self.all_daemons_links:
            daemon_link.cfg.update({'alignak_name': self.alignak_conf.alignak_name})

        logger.info("Preparing realms dispatch:")

        # Prepare the arbiters configuration
        master_arbiter_cfg = arbiters_cfg = {}
        for arbiter_link in self.get_satellites_list('arbiters'):
            # # If not me and not a spare arbiter...
            # if arbiter_link == self.arbiter_link:
            #     # I exclude myself from the dispatching, I have my configuration ;)
            #     continue

            if not arbiter_link.active:
                # I exclude the daemons that are not active
                continue

            arbiter_cfg = arbiter_link.cfg
            arbiter_cfg.update({
                'managed_hosts_names': [h.get_name() for h in self.alignak_conf.hosts],
                'modules': serialize(arbiter_link.modules, True),

                'managed_conf_id': self.alignak_conf.instance_id,
                'push_flavor': ''
            })

            # Hash the configuration
            cfg_string = json.dumps(arbiter_cfg, sort_keys=True).encode('utf-8')
            arbiter_cfg['hash'] = hashlib.sha1(cfg_string).hexdigest()

            # Update the arbiters list, but do not include the whole conf
            arbiters_cfg[arbiter_link.uuid] = arbiter_cfg['self_conf']

            # Not for the master arbiter...
            if arbiter_link != self.arbiter_link:
                arbiter_cfg.update({
                    'arbiters': master_arbiter_cfg,
                    'whole_conf': self.alignak_conf.spare_arbiter_conf,
                })

                # Hash the whole configuration
                try:
                    s_conf_part = json.dumps(arbiter_cfg, sort_keys=True).encode('utf-8')
                except UnicodeDecodeError:
                    pass
                arbiter_cfg['hash'] = hashlib.sha1(s_conf_part).hexdigest()

            # Dump the configuration part size
            pickled_conf = pickle.dumps(arbiter_cfg)
            logger.info('   arbiter configuration size: %d bytes', sys.getsizeof(pickled_conf))

            # The configuration is assigned to the arbiter
            # todo: perhaps this should be done in the realms (like schedulers and satellites)?
            arbiter_link.cfg = arbiter_cfg
            arbiter_link.cfg_to_manage = self.alignak_conf
            arbiter_link.push_flavor = arbiter_cfg['push_flavor']
            arbiter_link.hash = arbiter_cfg['hash']
            arbiter_link.need_conf = False
            arbiter_link.configuration_sent = False

            # If not me and not a spare arbiter...
            if arbiter_link == self.arbiter_link:
                # The master arbiter configuration for the other satellites
                master_arbiter_cfg = {self.arbiter_link.uuid: arbiter_cfg['self_conf']}

            logger.info('   arbiter configuration prepared for %s', arbiter_link.name)

        # main_realm = self.alignak_conf.realms.find_by_name('All')
        # all_realms = main_realm.all_sub_members
        # for realm_uuid in all_realms:
        #     realm = self.alignak_conf.realms[realm_uuid]
        #     logger.info("- realm %s: %s", realm_uuid, realm)

        for realm in self.alignak_conf.realms:
            logger.info("- realm %s: %d configuration part(s)", realm.name, len(realm.parts))

            # parts_to_dispatch is a list of configuration parts built when
            # the configuration is split into parts for the realms and their schedulers
            # Only get the parts that are not yet assigned to a scheduler
            parts_to_dispatch = [cfg for cfg in list(realm.parts.values()) if not cfg.is_assigned]
            if not parts_to_dispatch:
                logger.info('  no configuration to dispatch for this realm!')
                continue

            logger.info(" preparing the dispatch for schedulers:")

            # Now we get all the schedulers of this realm and upper
            # schedulers = self.get_scheduler_ordered_list(realm)
            schedulers = realm.get_potential_satellites_by_type(
                self.get_satellites_list('schedulers'), 'scheduler')
            if not schedulers:
                logger.error('  no available schedulers in this realm (%s)!', realm)
                continue
            logger.info("  realm schedulers: %s",
                        ','.join([s.get_name() for s in schedulers]))

            for cfg_part in parts_to_dispatch:
                logger.info("  .assigning configuration part %s (%s), name:%s",
                            cfg_part.instance_id, cfg_part.uuid, cfg_part.config_name)

                # we need to loop until the configuration part is assigned to a scheduler
                # or no more scheduler is available
                while True:
                    try:
                        scheduler_link = schedulers.pop()
                    except IndexError:  # No more schedulers.. not good, no loop
                        # The configuration part do not need to be dispatched anymore
                        # todo: should be managed inside the Realm class!
                        logger.error("No more scheduler link: %s", realm)
                        for sat_type in ('reactionner', 'poller', 'broker', 'receiver'):
                            realm.to_satellites[sat_type][cfg_part.instance_id] = None
                            realm.to_satellites_need_dispatch[sat_type][cfg_part.instance_id] = \
                                False
                            realm.to_satellites_managed_by[sat_type][cfg_part.instance_id] = []
                        break

                    # if scheduler_link.manage_sub_realms:
                    #     logger.warning('[%s] The scheduler %s is configured to manage sub realms.'
                    #                    ' This is not yet possible, sorry!',
                    #                    realm.name, scheduler_link.name)
                    #     scheduler_link.manage_sub_realms = False
                    #     continue

                    if not scheduler_link.need_conf:
                        logger.info('[%s] The scheduler %s do not need any configuration, sorry',
                                    realm.name, scheduler_link.name)
                        continue

                    logger.debug("   preparing configuration part '%s' for the scheduler '%s'",
                                 cfg_part.instance_id, scheduler_link.name)
                    logger.debug("   - %d hosts, %d services",
                                 len(cfg_part.hosts), len(cfg_part.services))

                    # Serialization and hashing
                    s_conf_part = serialize(realm.parts[cfg_part.instance_id])
                    try:
                        s_conf_part = s_conf_part.encode('utf-8')
                    except UnicodeDecodeError:
                        pass
                    cfg_part.push_flavor = hashlib.sha1(s_conf_part).hexdigest()

                    # We generate the scheduler configuration for the satellites:
                    # ---
                    sat_scheduler_cfg = scheduler_link.give_satellite_cfg()
                    sat_scheduler_cfg.update({
                        'managed_hosts_names': [h.get_name() for h in cfg_part.hosts],

                        'managed_conf_id': cfg_part.instance_id,
                        'push_flavor': cfg_part.push_flavor
                    })
                    # Generate a configuration hash
                    cfg_string = json.dumps(sat_scheduler_cfg, sort_keys=True).encode('utf-8')
                    sat_scheduler_cfg['hash'] = hashlib.sha1(cfg_string).hexdigest()

                    logger.debug(' satellite scheduler configuration: %s', sat_scheduler_cfg)
                    for sat_type in ('reactionner', 'poller', 'broker', 'receiver'):
                        realm.to_satellites[sat_type][cfg_part.instance_id] = sat_scheduler_cfg
                        realm.to_satellites_need_dispatch[sat_type][cfg_part.instance_id] = True
                        realm.to_satellites_managed_by[sat_type][cfg_part.instance_id] = []
                    # ---

                    scheduler_link.cfg.update({
                        # Global instance configuration
                        'instance_id': scheduler_link.instance_id,
                        'instance_name': scheduler_link.name,

                        'schedulers': {scheduler_link.uuid: sat_scheduler_cfg},
                        'arbiters': arbiters_cfg if scheduler_link.manage_arbiters else {},
                        'satellites': realm.get_links_for_a_scheduler(self.pollers,
                                                                      self.reactionners,
                                                                      self.brokers),

                        'modules': serialize(scheduler_link.modules, True),

                        'conf_part': serialize(realm.parts[cfg_part.instance_id]),
                        'managed_conf_id': cfg_part.instance_id,
                        'push_flavor': cfg_part.push_flavor,

                        'override_conf': scheduler_link.get_override_configuration()
                    })

                    # Hash the whole configuration
                    cfg_string = json.dumps(scheduler_link.cfg, sort_keys=True).encode('utf-8')
                    scheduler_link.cfg['hash'] = hashlib.sha1(cfg_string).hexdigest()

                    # Dump the configuration part size
                    pickled_conf = pickle.dumps(scheduler_link.cfg)
                    logger.info("   scheduler configuration size: %d bytes",
                                sys.getsizeof(pickled_conf))
                    logger.info("   scheduler satellites:")
                    satellites = realm.get_links_for_a_scheduler(self.pollers,
                                                                 self.reactionners,
                                                                 self.brokers)
                    for sat_type in satellites:
                        logger.info("   - %s", sat_type)
                        for sat_link_uuid in satellites[sat_type]:
                            satellite = satellites[sat_type][sat_link_uuid]
                            logger.info("   %s", satellite['name'])

                    # The configuration part is assigned to a scheduler
                    cfg_part.is_assigned = True
                    cfg_part.scheduler_link = scheduler_link
                    scheduler_link.cfg_to_manage = cfg_part
                    scheduler_link.push_flavor = cfg_part.push_flavor
                    scheduler_link.hash = scheduler_link.cfg['hash']
                    scheduler_link.need_conf = False
                    scheduler_link.configuration_sent = False

                    logger.info('   configuration %s (%s) assigned to %s',
                                cfg_part.instance_id, cfg_part.push_flavor, scheduler_link.name)

                    # The configuration part is assigned to a scheduler, no need to go further ;)
                    break

            logger.info(" preparing the dispatch for satellites:")
            for cfg_part in list(realm.parts.values()):
                logger.info("  .configuration part %s (%s), name:%s",
                            cfg_part.instance_id, cfg_part.uuid, cfg_part.config_name)
                for sat_type in ('reactionner', 'poller', 'broker', 'receiver'):
                    if cfg_part.instance_id not in realm.to_satellites_need_dispatch[sat_type]:
                        logger.warning("   nothing to dispatch for %ss", sat_type)
                        return

                    if not realm.to_satellites_need_dispatch[sat_type][cfg_part.instance_id]:
                        logger.warning("   no need to dispatch to %ss", sat_type)
                        return

                    # Get the list of the concerned satellites
                    satellites = realm.get_potential_satellites_by_type(self.satellites, sat_type)
                    if satellites:
                        logger.info("  realm %ss: %s",
                                    sat_type, ','.join([s.get_name() for s in satellites]))
                    else:
                        logger.info("   no %s satellites", sat_type)

                    # Now we dispatch cfg to every one ask for it
                    nb_cfg_prepared = 0
                    for sat_link in satellites:
                        if not sat_link.active:
                            # I exclude the daemons that are not active
                            continue

                        if nb_cfg_prepared > realm.get_nb_of_must_have_satellites(sat_type):
                            logger.warning("Too much configuration parts prepared "
                                           "for the expected satellites count. "
                                           "Realm: %s, satellite: %s - prepared: %d out of %d",
                                           realm.name, sat_link.name, nb_cfg_prepared,
                                           realm.get_nb_of_must_have_satellites(sat_type))
                            # Fred - 2018-07-20 - temporary disable this error raising!
                            # raise DispatcherError("Too much configuration parts prepared "
                            #                       "for the expected satellites count. "
                            #                       "This should never happen!")

                        logger.info("   preparing configuration part '%s' for the %s '%s'",
                                    cfg_part.instance_id, sat_type, sat_link.name)

                        sat_link.cfg.update({
                            # Global instance configuration
                            'arbiters': arbiters_cfg if sat_link.manage_arbiters else {},
                            'modules': serialize(sat_link.modules, True),
                            'managed_conf_id': 'see_my_schedulers',
                            'global_conf': self.global_conf
                        })
                        sat_link.cfg['schedulers'].update({
                            cfg_part.uuid: realm.to_satellites[sat_type][cfg_part.instance_id]})

                        # Brokers should have pollers and reactionners links too
                        if sat_type == "broker":
                            sat_link.cfg.update({'satellites': realm.get_links_for_a_broker(
                                self.pollers, self.reactionners, self.receivers,
                                self.alignak_conf.realms, sat_link.manage_sub_realms)})

                        # Hash the whole configuration
                        cfg_string = json.dumps(sat_link.cfg, sort_keys=True).encode('utf-8')
                        sat_link.cfg['hash'] = hashlib.sha1(cfg_string).hexdigest()

                        # Dump the configuration part size
                        pickled_conf = pickle.dumps(sat_link.cfg)
                        logger.info('   %s configuration size: %d bytes',
                                    sat_type, sys.getsizeof(pickled_conf))

                        # The configuration part is assigned to a satellite
                        sat_link.cfg_to_manage = cfg_part
                        sat_link.push_flavor = cfg_part.push_flavor
                        sat_link.hash = sat_link.cfg['hash']
                        sat_link.need_conf = False
                        sat_link.configuration_sent = False

                        logger.info('   configuration %s (%s) assigned to %s',
                                    cfg_part.instance_id, cfg_part.push_flavor, sat_link.name)

                        nb_cfg_prepared += 1
                        realm.to_satellites_managed_by[sat_type][
                            cfg_part.instance_id].append(sat_link)

                        # I've got enough satellite, the next ones are considered unuseful!
                        if nb_cfg_prepared == realm.get_nb_of_must_have_satellites(sat_type):
                            logger.info("   no more %s needed in this realm.", sat_type)
                            realm.to_satellites_need_dispatch[sat_type][
                                cfg_part.instance_id] = False

        nb_missed = len([cfg for cfg in list(
            self.alignak_conf.parts.values()) if not cfg.is_assigned])
        if nb_missed > 0:
            logger.warning("Some configuration parts are not dispatched, %d are missing", nb_missed)
        else:
            logger.info("All configuration parts are assigned "
                        "to schedulers and their satellites :)")

        # Schedulers without a configuration in a dispatch ok do not need a configuration
        # so they do not raise dispatching errors if they are not used
        for scheduler_link in self.schedulers:
            if not scheduler_link.cfg_to_manage:
                # "so it do not ask anymore for conf"
                logger.warning('The scheduler %s do not need a configuration!', scheduler_link.name)
                scheduler_link.need_conf = False
def prepare_dispatch ( self ) : if self . new_to_dispatch : raise DispatcherError ( "A configuration is already prepared!" ) self . new_to_dispatch = True self . first_dispatch_done = False for daemon_link in self . all_daemons_links : daemon_link . cfg . update ( { 'alignak_name' : self . alignak_conf . alignak_name } ) logger . info ( "Preparing realms dispatch:" ) master_arbiter_cfg = arbiters_cfg = { } for arbiter_link in self . get_satellites_list ( 'arbiters' ) : if not arbiter_link . active : continue arbiter_cfg = arbiter_link . cfg arbiter_cfg . update ( { 'managed_hosts_names' : [ h . get_name ( ) for h in self . alignak_conf . hosts ] , 'modules' : serialize ( arbiter_link . modules , True ) , 'managed_conf_id' : self . alignak_conf . instance_id , 'push_flavor' : '' } ) cfg_string = json . dumps ( arbiter_cfg , sort_keys = True ) . encode ( 'utf-8' ) arbiter_cfg [ 'hash' ] = hashlib . sha1 ( cfg_string ) . hexdigest ( ) arbiters_cfg [ arbiter_link . uuid ] = arbiter_cfg [ 'self_conf' ] if arbiter_link != self . arbiter_link : arbiter_cfg . update ( { 'arbiters' : master_arbiter_cfg , 'whole_conf' : self . alignak_conf . spare_arbiter_conf , } ) try : s_conf_part = json . dumps ( arbiter_cfg , sort_keys = True ) . encode ( 'utf-8' ) except UnicodeDecodeError : pass arbiter_cfg [ 'hash' ] = hashlib . sha1 ( s_conf_part ) . hexdigest ( ) pickled_conf = pickle . dumps ( arbiter_cfg ) logger . info ( '   arbiter configuration size: %d bytes' , sys . getsizeof ( pickled_conf ) ) arbiter_link . cfg = arbiter_cfg arbiter_link . cfg_to_manage = self . alignak_conf arbiter_link . push_flavor = arbiter_cfg [ 'push_flavor' ] arbiter_link . hash = arbiter_cfg [ 'hash' ] arbiter_link . need_conf = False arbiter_link . configuration_sent = False if arbiter_link == self . arbiter_link : master_arbiter_cfg = { self . arbiter_link . uuid : arbiter_cfg [ 'self_conf' ] } logger . info ( '   arbiter configuration prepared for %s' , arbiter_link . name ) for realm in self . alignak_conf . realms : logger . info ( "- realm %s: %d configuration part(s)" , realm . name , len ( realm . parts ) ) parts_to_dispatch = [ cfg for cfg in list ( realm . parts . values ( ) ) if not cfg . is_assigned ] if not parts_to_dispatch : logger . info ( '  no configuration to dispatch for this realm!' ) continue logger . info ( " preparing the dispatch for schedulers:" ) schedulers = realm . get_potential_satellites_by_type ( self . get_satellites_list ( 'schedulers' ) , 'scheduler' ) if not schedulers : logger . error ( '  no available schedulers in this realm (%s)!' , realm ) continue logger . info ( "  realm schedulers: %s" , ',' . join ( [ s . get_name ( ) for s in schedulers ] ) ) for cfg_part in parts_to_dispatch : logger . info ( "  .assigning configuration part %s (%s), name:%s" , cfg_part . instance_id , cfg_part . uuid , cfg_part . config_name ) while True : try : scheduler_link = schedulers . pop ( ) except IndexError : logger . error ( "No more scheduler link: %s" , realm ) for sat_type in ( 'reactionner' , 'poller' , 'broker' , 'receiver' ) : realm . to_satellites [ sat_type ] [ cfg_part . instance_id ] = None realm . to_satellites_need_dispatch [ sat_type ] [ cfg_part . instance_id ] = False realm . to_satellites_managed_by [ sat_type ] [ cfg_part . instance_id ] = [ ] break if not scheduler_link . need_conf : logger . info ( '[%s] The scheduler %s do not need any configuration, sorry' , realm . name , scheduler_link . name ) continue logger . debug ( "   preparing configuration part '%s' for the scheduler '%s'" , cfg_part . instance_id , scheduler_link . name ) logger . debug ( "   - %d hosts, %d services" , len ( cfg_part . hosts ) , len ( cfg_part . services ) ) s_conf_part = serialize ( realm . parts [ cfg_part . instance_id ] ) try : s_conf_part = s_conf_part . encode ( 'utf-8' ) except UnicodeDecodeError : pass cfg_part . push_flavor = hashlib . sha1 ( s_conf_part ) . hexdigest ( ) sat_scheduler_cfg = scheduler_link . give_satellite_cfg ( ) sat_scheduler_cfg . update ( { 'managed_hosts_names' : [ h . get_name ( ) for h in cfg_part . hosts ] , 'managed_conf_id' : cfg_part . instance_id , 'push_flavor' : cfg_part . push_flavor } ) cfg_string = json . dumps ( sat_scheduler_cfg , sort_keys = True ) . encode ( 'utf-8' ) sat_scheduler_cfg [ 'hash' ] = hashlib . sha1 ( cfg_string ) . hexdigest ( ) logger . debug ( ' satellite scheduler configuration: %s' , sat_scheduler_cfg ) for sat_type in ( 'reactionner' , 'poller' , 'broker' , 'receiver' ) : realm . to_satellites [ sat_type ] [ cfg_part . instance_id ] = sat_scheduler_cfg realm . to_satellites_need_dispatch [ sat_type ] [ cfg_part . instance_id ] = True realm . to_satellites_managed_by [ sat_type ] [ cfg_part . instance_id ] = [ ] scheduler_link . cfg . update ( { 'instance_id' : scheduler_link . instance_id , 'instance_name' : scheduler_link . name , 'schedulers' : { scheduler_link . uuid : sat_scheduler_cfg } , 'arbiters' : arbiters_cfg if scheduler_link . manage_arbiters else { } , 'satellites' : realm . get_links_for_a_scheduler ( self . pollers , self . reactionners , self . brokers ) , 'modules' : serialize ( scheduler_link . modules , True ) , 'conf_part' : serialize ( realm . parts [ cfg_part . instance_id ] ) , 'managed_conf_id' : cfg_part . instance_id , 'push_flavor' : cfg_part . push_flavor , 'override_conf' : scheduler_link . get_override_configuration ( ) } ) cfg_string = json . dumps ( scheduler_link . cfg , sort_keys = True ) . encode ( 'utf-8' ) scheduler_link . cfg [ 'hash' ] = hashlib . sha1 ( cfg_string ) . hexdigest ( ) pickled_conf = pickle . dumps ( scheduler_link . cfg ) logger . info ( "   scheduler configuration size: %d bytes" , sys . getsizeof ( pickled_conf ) ) logger . info ( "   scheduler satellites:" ) satellites = realm . get_links_for_a_scheduler ( self . pollers , self . reactionners , self . brokers ) for sat_type in satellites : logger . info ( "   - %s" , sat_type ) for sat_link_uuid in satellites [ sat_type ] : satellite = satellites [ sat_type ] [ sat_link_uuid ] logger . info ( "   %s" , satellite [ 'name' ] ) cfg_part . is_assigned = True cfg_part . scheduler_link = scheduler_link scheduler_link . cfg_to_manage = cfg_part scheduler_link . push_flavor = cfg_part . push_flavor scheduler_link . hash = scheduler_link . cfg [ 'hash' ] scheduler_link . need_conf = False scheduler_link . configuration_sent = False logger . info ( '   configuration %s (%s) assigned to %s' , cfg_part . instance_id , cfg_part . push_flavor , scheduler_link . name ) break logger . info ( " preparing the dispatch for satellites:" ) for cfg_part in list ( realm . parts . values ( ) ) : logger . info ( "  .configuration part %s (%s), name:%s" , cfg_part . instance_id , cfg_part . uuid , cfg_part . config_name ) for sat_type in ( 'reactionner' , 'poller' , 'broker' , 'receiver' ) : if cfg_part . instance_id not in realm . to_satellites_need_dispatch [ sat_type ] : logger . warning ( "   nothing to dispatch for %ss" , sat_type ) return if not realm . to_satellites_need_dispatch [ sat_type ] [ cfg_part . instance_id ] : logger . warning ( "   no need to dispatch to %ss" , sat_type ) return satellites = realm . get_potential_satellites_by_type ( self . satellites , sat_type ) if satellites : logger . info ( "  realm %ss: %s" , sat_type , ',' . join ( [ s . get_name ( ) for s in satellites ] ) ) else : logger . info ( "   no %s satellites" , sat_type ) nb_cfg_prepared = 0 for sat_link in satellites : if not sat_link . active : continue if nb_cfg_prepared > realm . get_nb_of_must_have_satellites ( sat_type ) : logger . warning ( "Too much configuration parts prepared " "for the expected satellites count. " "Realm: %s, satellite: %s - prepared: %d out of %d" , realm . name , sat_link . name , nb_cfg_prepared , realm . get_nb_of_must_have_satellites ( sat_type ) ) logger . info ( "   preparing configuration part '%s' for the %s '%s'" , cfg_part . instance_id , sat_type , sat_link . name ) sat_link . cfg . update ( { 'arbiters' : arbiters_cfg if sat_link . manage_arbiters else { } , 'modules' : serialize ( sat_link . modules , True ) , 'managed_conf_id' : 'see_my_schedulers' , 'global_conf' : self . global_conf } ) sat_link . cfg [ 'schedulers' ] . update ( { cfg_part . uuid : realm . to_satellites [ sat_type ] [ cfg_part . instance_id ] } ) if sat_type == "broker" : sat_link . cfg . update ( { 'satellites' : realm . get_links_for_a_broker ( self . pollers , self . reactionners , self . receivers , self . alignak_conf . realms , sat_link . manage_sub_realms ) } ) cfg_string = json . dumps ( sat_link . cfg , sort_keys = True ) . encode ( 'utf-8' ) sat_link . cfg [ 'hash' ] = hashlib . sha1 ( cfg_string ) . hexdigest ( ) pickled_conf = pickle . dumps ( sat_link . cfg ) logger . info ( '   %s configuration size: %d bytes' , sat_type , sys . getsizeof ( pickled_conf ) ) sat_link . cfg_to_manage = cfg_part sat_link . push_flavor = cfg_part . push_flavor sat_link . hash = sat_link . cfg [ 'hash' ] sat_link . need_conf = False sat_link . configuration_sent = False logger . info ( '   configuration %s (%s) assigned to %s' , cfg_part . instance_id , cfg_part . push_flavor , sat_link . name ) nb_cfg_prepared += 1 realm . to_satellites_managed_by [ sat_type ] [ cfg_part . instance_id ] . append ( sat_link ) if nb_cfg_prepared == realm . get_nb_of_must_have_satellites ( sat_type ) : logger . info ( "   no more %s needed in this realm." , sat_type ) realm . to_satellites_need_dispatch [ sat_type ] [ cfg_part . instance_id ] = False nb_missed = len ( [ cfg for cfg in list ( self . alignak_conf . parts . values ( ) ) if not cfg . is_assigned ] ) if nb_missed > 0 : logger . warning ( "Some configuration parts are not dispatched, %d are missing" , nb_missed ) else : logger . info ( "All configuration parts are assigned " "to schedulers and their satellites :)" ) for scheduler_link in self . schedulers : if not scheduler_link . cfg_to_manage : logger . warning ( 'The scheduler %s do not need a configuration!' , scheduler_link . name ) scheduler_link . need_conf = False
Prepare dispatch, so prepare for each daemon (schedulers, brokers, receivers, reactionners,
        pollers)

        This function will only prepare something if self.new_to_dispatch is False
        It will reset the first_dispatch_done flag

        A DispatcherError exception is raised if a configuration is already prepared! Unset the
        new_to_dispatch flag before calling!

        :return: None