def setup_new_conf(self): """Receiver custom setup_new_conf method Implements specific setup for receiver :return: None """ with self.conf_lock: conf = self.new_conf self.new_conf = None self.cur_conf = conf # Got our name from the globals if 'receiver_name' in conf['global']: name = conf['global']['receiver_name'] else: name = 'Unnamed receiver' self.name = name self.api_key = conf['global']['api_key'] self.secret = conf['global']['secret'] self.http_proxy = conf['global']['http_proxy'] self.statsd_host = conf['global']['statsd_host'] self.statsd_port = conf['global']['statsd_port'] self.statsd_prefix = conf['global']['statsd_prefix'] self.statsd_enabled = conf['global']['statsd_enabled'] statsmgr.register(self, self.name, 'receiver', api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) # pylint: disable=E1101 logger.load_obj(self, name) self.direct_routing = conf['global']['direct_routing'] self.accept_passive_unknown_check_results = \ conf['global']['accept_passive_unknown_check_results'] g_conf = conf['global'] # If we've got something in the schedulers, we do not want it anymore for sched_id in conf['schedulers']: already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: logger.info("[%s] We already got the conf %d (%s)", self.name, sched_id, conf['schedulers'][sched_id]['name']) wait_homerun = self.schedulers[sched_id]['wait_homerun'] actions = self.schedulers[sched_id]['actions'] external_commands = self.schedulers[sched_id]['external_commands'] con = self.schedulers[sched_id]['con'] sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched if sched['name'] in g_conf['satellitemap']: sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri if already_got: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions self.schedulers[sched_id]['external_commands'] = external_commands self.schedulers[sched_id]['con'] = con else: self.schedulers[sched_id]['wait_homerun'] = {} self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['external_commands'] = [] self.schedulers[sched_id]['con'] = None self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched['data_timeout'] # Do not connect if we are a passive satellite if self.direct_routing and not already_got: # And then we connect to it :) self.pynag_con_init(sched_id) logger.debug("[%s] Sending us configuration %s", self.name, conf) if not self.have_modules: self.modules = mods = conf['global']['modules'] self.have_modules = True logger.info("We received modules %s ", mods) # Set our giving timezone from arbiter use_timezone = conf['global']['use_timezone'] if use_timezone != 'NOTSET': logger.info("Setting our timezone to %s", use_timezone) os.environ['TZ'] = use_timezone time.tzset()
def setup_new_conf(self): """Setup new conf received from Arbiter :return: None """ with self.conf_lock: conf = self.new_conf logger.debug("[%s] Sending us a configuration %s", self.name, conf) self.new_conf = None self.cur_conf = conf g_conf = conf['global'] # Got our name from the globals if 'poller_name' in g_conf: name = g_conf['poller_name'] elif 'reactionner_name' in g_conf: name = g_conf['reactionner_name'] else: name = 'Unnamed satellite' self.name = name # kernel.io part self.api_key = g_conf['api_key'] self.secret = g_conf['secret'] self.http_proxy = g_conf['http_proxy'] # local statsd self.statsd_host = g_conf['statsd_host'] self.statsd_port = g_conf['statsd_port'] self.statsd_prefix = g_conf['statsd_prefix'] self.statsd_enabled = g_conf['statsd_enabled'] # we got a name, we can now say it to our statsmgr if 'poller_name' in g_conf: statsmgr.register(self, self.name, 'poller', api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) else: statsmgr.register(self, self.name, 'reactionner', api_key=self.api_key, secret=self.secret, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) self.passive = g_conf['passive'] if self.passive: logger.info("[%s] Passive mode enabled.", self.name) # If we've got something in the schedulers, we do not want it anymore for sched_id in conf['schedulers']: already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: logger.info("[%s] We already got the conf %d (%s)", self.name, sched_id, conf['schedulers'][sched_id]['name']) wait_homerun = self.schedulers[sched_id]['wait_homerun'] actions = self.schedulers[sched_id]['actions'] sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched if sched['name'] in g_conf['satellitemap']: sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri if already_got: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions else: self.schedulers[sched_id]['wait_homerun'] = {} self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched['data_timeout'] # Do not connect if we are a passive satellite if not self.passive and not already_got: # And then we connect to it :) self.pynag_con_init(sched_id) # Now the limit part, 0 mean: number of cpu of this machine :) # if not available, use 4 (modern hardware) self.max_workers = g_conf['max_workers'] if self.max_workers == 0: try: self.max_workers = cpu_count() except NotImplementedError: self.max_workers = 4 logger.info("[%s] Using max workers: %s", self.name, self.max_workers) self.min_workers = g_conf['min_workers'] if self.min_workers == 0: try: self.min_workers = cpu_count() except NotImplementedError: self.min_workers = 4 logger.info("[%s] Using min workers: %s", self.name, self.min_workers) self.processes_by_worker = g_conf['processes_by_worker'] self.polling_interval = g_conf['polling_interval'] self.timeout = self.polling_interval # Now set tags # ['None'] is the default tags self.poller_tags = g_conf.get('poller_tags', ['None']) self.reactionner_tags = g_conf.get('reactionner_tags', ['None']) self.max_plugins_output_length = g_conf.get('max_plugins_output_length', 8192) # Set our giving timezone from arbiter use_timezone = g_conf['use_timezone'] if use_timezone != 'NOTSET': logger.info("[%s] Setting our timezone to %s", self.name, use_timezone) os.environ['TZ'] = use_timezone time.tzset() logger.info("We have our schedulers: %s", str(self.schedulers)) # Now manage modules # TODO: check how to better handle this with modules_manager.. mods = g_conf['modules'] self.new_modules_conf = [] for module in mods: # If we already got it, bypass if module.python_name not in self.q_by_mod: logger.debug("Add module object %s", str(module)) self.new_modules_conf.append(module) logger.info("[%s] Got module: %s ", self.name, module.python_name) self.q_by_mod[module.python_name] = {}
def setup_new_conf(self): """Receiver custom setup_new_conf method Implements specific setup for receiver :return: None """ with self.conf_lock: conf = self.new_conf self.new_conf = None self.cur_conf = conf # Got our name from the globals if 'receiver_name' in conf['global']: name = conf['global']['receiver_name'] else: name = 'Unnamed receiver' self.name = name self.api_key = conf['global']['api_key'] self.secret = conf['global']['secret'] self.http_proxy = conf['global']['http_proxy'] self.statsd_host = conf['global']['statsd_host'] self.statsd_port = conf['global']['statsd_port'] self.statsd_prefix = conf['global']['statsd_prefix'] self.statsd_enabled = conf['global']['statsd_enabled'] statsmgr.register(self, self.name, 'receiver', api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) # pylint: disable=E1101 logger.load_obj(self, name) self.direct_routing = conf['global']['direct_routing'] self.accept_passive_unknown_check_results = \ conf['global']['accept_passive_unknown_check_results'] g_conf = conf['global'] # If we've got something in the schedulers, we do not want it anymore for sched_id in conf['schedulers']: already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: logger.info("[%s] We already got the conf %d (%s)", self.name, sched_id, conf['schedulers'][sched_id]['name']) wait_homerun = self.schedulers[sched_id]['wait_homerun'] actions = self.schedulers[sched_id]['actions'] external_commands = self.schedulers[sched_id][ 'external_commands'] con = self.schedulers[sched_id]['con'] sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched if sched['name'] in g_conf['satellitemap']: sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri if already_got: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions self.schedulers[sched_id][ 'external_commands'] = external_commands self.schedulers[sched_id]['con'] = con else: self.schedulers[sched_id]['wait_homerun'] = {} self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['external_commands'] = [] self.schedulers[sched_id]['con'] = None self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched[ 'data_timeout'] # Do not connect if we are a passive satellite if self.direct_routing and not already_got: # And then we connect to it :) self.pynag_con_init(sched_id) logger.debug("[%s] Sending us configuration %s", self.name, conf) if not self.have_modules: self.modules = mods = conf['global']['modules'] self.have_modules = True logger.info("We received modules %s ", mods) # Set our giving timezone from arbiter use_timezone = conf['global']['use_timezone'] if use_timezone != 'NOTSET': logger.info("Setting our timezone to %s", use_timezone) os.environ['TZ'] = use_timezone time.tzset()
def setup_new_conf(self): """Setup new conf received from Arbiter :return: None """ with self.conf_lock: conf = self.new_conf logger.debug("[%s] Sending us a configuration %s", self.name, conf) self.new_conf = None self.cur_conf = conf g_conf = conf['global'] # Got our name from the globals if 'poller_name' in g_conf: name = g_conf['poller_name'] elif 'reactionner_name' in g_conf: name = g_conf['reactionner_name'] else: name = 'Unnamed satellite' self.name = name # kernel.io part self.api_key = g_conf['api_key'] self.secret = g_conf['secret'] self.http_proxy = g_conf['http_proxy'] # local statsd self.statsd_host = g_conf['statsd_host'] self.statsd_port = g_conf['statsd_port'] self.statsd_prefix = g_conf['statsd_prefix'] self.statsd_enabled = g_conf['statsd_enabled'] # we got a name, we can now say it to our statsmgr if 'poller_name' in g_conf: statsmgr.register(self, self.name, 'poller', api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) else: statsmgr.register(self, self.name, 'reactionner', api_key=self.api_key, secret=self.secret, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) self.passive = g_conf['passive'] if self.passive: logger.info("[%s] Passive mode enabled.", self.name) # If we've got something in the schedulers, we do not want it anymore for sched_id in conf['schedulers']: already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: logger.info("[%s] We already got the conf %d (%s)", self.name, sched_id, conf['schedulers'][sched_id]['name']) wait_homerun = self.schedulers[sched_id]['wait_homerun'] actions = self.schedulers[sched_id]['actions'] sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched if sched['name'] in g_conf['satellitemap']: sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri if already_got: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions else: self.schedulers[sched_id]['wait_homerun'] = {} self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched[ 'data_timeout'] # Do not connect if we are a passive satellite if not self.passive and not already_got: # And then we connect to it :) self.pynag_con_init(sched_id) # Now the limit part, 0 mean: number of cpu of this machine :) # if not available, use 4 (modern hardware) self.max_workers = g_conf['max_workers'] if self.max_workers == 0: try: self.max_workers = cpu_count() except NotImplementedError: self.max_workers = 4 logger.info("[%s] Using max workers: %s", self.name, self.max_workers) self.min_workers = g_conf['min_workers'] if self.min_workers == 0: try: self.min_workers = cpu_count() except NotImplementedError: self.min_workers = 4 logger.info("[%s] Using min workers: %s", self.name, self.min_workers) self.processes_by_worker = g_conf['processes_by_worker'] self.polling_interval = g_conf['polling_interval'] self.timeout = self.polling_interval # Now set tags # ['None'] is the default tags self.poller_tags = g_conf.get('poller_tags', ['None']) self.reactionner_tags = g_conf.get('reactionner_tags', ['None']) self.max_plugins_output_length = g_conf.get( 'max_plugins_output_length', 8192) # Set our giving timezone from arbiter use_timezone = g_conf['use_timezone'] if use_timezone != 'NOTSET': logger.info("[%s] Setting our timezone to %s", self.name, use_timezone) os.environ['TZ'] = use_timezone time.tzset() logger.info("We have our schedulers: %s", str(self.schedulers)) # Now manage modules # TODO: check how to better handle this with modules_manager.. mods = g_conf['modules'] self.new_modules_conf = [] for module in mods: # If we already got it, bypass if module.python_name not in self.q_by_mod: logger.debug("Add module object %s", str(module)) self.new_modules_conf.append(module) logger.info("[%s] Got module: %s ", self.name, module.python_name) self.q_by_mod[module.python_name] = {}
def setup_new_conf(self): """Parse new configuration and initialize all required :return: None """ with self.conf_lock: conf = self.new_conf self.new_conf = None self.cur_conf = conf # Got our name from the globals g_conf = conf['global'] if 'broker_name' in g_conf: name = g_conf['broker_name'] else: name = 'Unnamed broker' self.name = name self.api_key = g_conf['api_key'] self.secret = g_conf['secret'] self.http_proxy = g_conf['http_proxy'] self.statsd_host = g_conf['statsd_host'] self.statsd_port = g_conf['statsd_port'] self.statsd_prefix = g_conf['statsd_prefix'] self.statsd_enabled = g_conf['statsd_enabled'] # We got a name so we can update the logger and the stats global objects # pylint: disable=E1101 logger.load_obj(self, name) statsmgr.register(self, name, 'broker', api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) logger.debug("[%s] Sending us configuration %s", self.name, conf) # If we've got something in the schedulers, we do not # want it anymore # self.schedulers.clear() for sched_id in conf['schedulers']: # Must look if we already have it to do not overdie our broks already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: broks = self.schedulers[sched_id]['broks'] running_id = self.schedulers[sched_id]['running_id'] else: broks = {} running_id = 0 sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched # replacing scheduler address and port by those defined in satellitemap if sched['name'] in g_conf['satellitemap']: sched = dict(sched) # make a copy sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri self.schedulers[sched_id]['broks'] = broks self.schedulers[sched_id]['instance_id'] = sched['instance_id'] self.schedulers[sched_id]['running_id'] = running_id self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['last_connection'] = 0 self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched['data_timeout'] logger.info("We have our schedulers: %s ", self.schedulers) # Now get arbiter for arb_id in conf['arbiters']: # Must look if we already have it already_got = arb_id in self.arbiters if already_got: broks = self.arbiters[arb_id]['broks'] else: broks = {} arb = conf['arbiters'][arb_id] self.arbiters[arb_id] = arb # replacing arbiter address and port by those defined in satellitemap if arb['name'] in g_conf['satellitemap']: arb = dict(arb) # make a copy arb.update(g_conf['satellitemap'][arb['name']]) proto = 'http' if arb['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, arb['address'], arb['port']) self.arbiters[arb_id]['uri'] = uri self.arbiters[arb_id]['broks'] = broks self.arbiters[arb_id]['instance_id'] = 0 # No use so all to 0 self.arbiters[arb_id]['running_id'] = 0 self.arbiters[arb_id]['last_connection'] = 0 # We do not connect to the arbiter. Connection hangs logger.info("We have our arbiters: %s ", self.arbiters) # Now for pollers for pol_id in conf['pollers']: # Must look if we already have it already_got = pol_id in self.pollers if already_got: broks = self.pollers[pol_id]['broks'] running_id = self.schedulers[sched_id]['running_id'] else: broks = {} running_id = 0 poll = conf['pollers'][pol_id] self.pollers[pol_id] = poll # replacing poller address and port by those defined in satellitemap if poll['name'] in g_conf['satellitemap']: poll = dict(poll) # make a copy poll.update(g_conf['satellitemap'][poll['name']]) proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, poll['address'], poll['port']) self.pollers[pol_id]['uri'] = uri self.pollers[pol_id]['broks'] = broks self.pollers[pol_id]['instance_id'] = 0 # No use so all to 0 self.pollers[pol_id]['running_id'] = running_id self.pollers[pol_id]['last_connection'] = 0 # #And we connect to it # self.app.pynag_con_init(pol_id, 'poller') logger.info("We have our pollers: %s", self.pollers) # Now reactionners for rea_id in conf['reactionners']: # Must look if we already have it already_got = rea_id in self.reactionners if already_got: broks = self.reactionners[rea_id]['broks'] running_id = self.schedulers[sched_id]['running_id'] else: broks = {} running_id = 0 reac = conf['reactionners'][rea_id] self.reactionners[rea_id] = reac # replacing reactionner address and port by those defined in satellitemap if reac['name'] in g_conf['satellitemap']: reac = dict(reac) # make a copy reac.update(g_conf['satellitemap'][reac['name']]) proto = 'http' if reac['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, reac['address'], reac['port']) self.reactionners[rea_id]['uri'] = uri self.reactionners[rea_id]['broks'] = broks self.reactionners[rea_id]['instance_id'] = 0 # No use so all to 0 self.reactionners[rea_id]['running_id'] = running_id self.reactionners[rea_id]['last_connection'] = 0 # #And we connect to it # self.app.pynag_con_init(rea_id, 'reactionner') logger.info("We have our reactionners: %s", self.reactionners) # Now receivers for rec_id in conf['receivers']: # Must look if we already have it already_got = rec_id in self.receivers if already_got: broks = self.receivers[rec_id]['broks'] running_id = self.schedulers[sched_id]['running_id'] else: broks = {} running_id = 0 rec = conf['receivers'][rec_id] self.receivers[rec_id] = rec # replacing reactionner address and port by those defined in satellitemap if rec['name'] in g_conf['satellitemap']: rec = dict(rec) # make a copy rec.update(g_conf['satellitemap'][rec['name']]) proto = 'http' if rec['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, rec['address'], rec['port']) self.receivers[rec_id]['uri'] = uri self.receivers[rec_id]['broks'] = broks self.receivers[rec_id]['instance_id'] = 0 # No use so all to 0 self.receivers[rec_id]['running_id'] = running_id self.receivers[rec_id]['last_connection'] = 0 if not self.have_modules: self.modules = mods = conf['global']['modules'] self.have_modules = True logger.info("We received modules %s ", mods) # Ok now start, or restart them! # Set modules, init them and start external ones self.do_load_modules(self.modules) self.modules_manager.start_external_instances() # Set our giving timezone from arbiter use_timezone = conf['global']['use_timezone'] if use_timezone != 'NOTSET': logger.info("Setting our timezone to %s", use_timezone) os.environ['TZ'] = use_timezone time.tzset() # Connection init with Schedulers for sched_id in self.schedulers: self.pynag_con_init(sched_id, i_type='scheduler') for pol_id in self.pollers: self.pynag_con_init(pol_id, i_type='poller') for rea_id in self.reactionners: self.pynag_con_init(rea_id, i_type='reactionner')
def setup_new_conf(self): """Receiver custom setup_new_conf method Implements specific setup for receiver :return: None """ with self.conf_lock: self.clean_previous_run() conf = unserialize(self.new_conf, True) self.new_conf = None self.cur_conf = conf # Got our name from the globals if 'receiver_name' in conf['global']: name = conf['global']['receiver_name'] else: name = 'Unnamed receiver' self.name = name # Set my own process title self.set_proctitle(self.name) logger.info("[%s] Received a new configuration, containing:", self.name) for key in conf: logger.info("[%s] - %s", self.name, key) logger.debug("[%s] global configuration part: %s", self.name, conf['global']) # local statsd self.statsd_host = conf['global']['statsd_host'] self.statsd_port = conf['global']['statsd_port'] self.statsd_prefix = conf['global']['statsd_prefix'] self.statsd_enabled = conf['global']['statsd_enabled'] statsmgr.register(self.name, 'receiver', statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) self.accept_passive_unknown_check_results = \ conf['global']['accept_passive_unknown_check_results'] # Update External Commands Manager self.external_commands_manager.accept_passive_unknown_check_results = \ conf['global']['accept_passive_unknown_check_results'] g_conf = conf['global'] # If we've got something in the schedulers, we do not want it anymore self.host_assoc = {} for sched_id in conf['schedulers']: old_sched_id = self.get_previous_sched_id(conf['schedulers'][sched_id], sched_id) if old_sched_id: logger.info("[%s] We already got the conf %s (%s)", self.name, old_sched_id, name) wait_homerun = self.schedulers[old_sched_id]['wait_homerun'] actions = self.schedulers[old_sched_id]['actions'] external_commands = self.schedulers[old_sched_id]['external_commands'] con = self.schedulers[old_sched_id]['con'] del self.schedulers[old_sched_id] sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched self.push_host_names(sched_id, sched['hosts']) if sched['name'] in g_conf['satellitemap']: sched.update(g_conf['satellitemap'][sched['name']]) proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri if old_sched_id: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions self.schedulers[sched_id]['external_commands'] = external_commands self.schedulers[sched_id]['con'] = con else: self.schedulers[sched_id]['wait_homerun'] = {} self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['external_commands'] = [] self.schedulers[sched_id]['con'] = None self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched['data_timeout'] self.schedulers[sched_id]['con'] = None self.schedulers[sched_id]['last_connection'] = 0 self.schedulers[sched_id]['connection_attempt'] = 0 self.schedulers[sched_id]['max_failed_connections'] = 3 # Do not connect if we are a passive satellite if not old_sched_id: # And then we connect to it :) self.daemon_connection_init(sched_id) logger.debug("We have our schedulers: %s", self.schedulers) logger.info("We have our schedulers:") for daemon in self.schedulers.values(): logger.info(" - %s ", daemon['name']) if not self.have_modules: self.modules = conf['global']['modules'] self.have_modules = True self.do_load_modules(self.modules) # and start external modules too self.modules_manager.start_external_instances() # Set our giving timezone from arbiter use_timezone = conf['global']['use_timezone'] if use_timezone != 'NOTSET': logger.info("Setting our timezone to %s", use_timezone) os.environ['TZ'] = use_timezone time.tzset()
def setup_new_conf(self): # pylint: disable=too-many-statements """Setup new conf received for scheduler :return: None """ with self.conf_lock: self.clean_previous_run() new_conf = self.new_conf logger.info("[%s] Sending us a configuration", self.name) conf_raw = new_conf['conf'] override_conf = new_conf['override_conf'] modules = new_conf['modules'] satellites = new_conf['satellites'] instance_name = new_conf['instance_name'] # Ok now we can save the retention data if hasattr(self.sched, 'conf'): self.sched.update_retention_file(forced=True) # horay, we got a name, we can set it in our stats objects statsmgr.register(instance_name, 'scheduler', statsd_host=new_conf['statsd_host'], statsd_port=new_conf['statsd_port'], statsd_prefix=new_conf['statsd_prefix'], statsd_enabled=new_conf['statsd_enabled']) t00 = time.time() try: conf = unserialize(conf_raw) except AlignakClassLookupException as exp: # pragma: no cover, simple protection logger.error( 'Cannot un-serialize configuration received from arbiter: %s', exp) logger.debug("Conf received at %d. Un-serialized in %d secs", t00, time.time() - t00) self.new_conf = None if 'scheduler_name' in new_conf: name = new_conf['scheduler_name'] else: name = instance_name self.name = name # Set my own process title self.set_proctitle(self.name) logger.info("[%s] Received a new configuration, containing: ", self.name) for key in new_conf: logger.info("[%s] - %s", self.name, key) logger.info("[%s] configuration identifiers: %s (%s)", self.name, new_conf['conf_uuid'], new_conf['push_flavor']) # Tag the conf with our data self.conf = conf self.conf.push_flavor = new_conf['push_flavor'] self.conf.alignak_name = new_conf['alignak_name'] self.conf.instance_name = instance_name self.conf.skip_initial_broks = new_conf['skip_initial_broks'] self.conf.accept_passive_unknown_check_results = \ new_conf['accept_passive_unknown_check_results'] self.cur_conf = conf self.override_conf = override_conf self.modules = unserialize(modules, True) self.satellites = satellites # Now We create our pollers, reactionners and brokers for sat_type in ['pollers', 'reactionners', 'brokers']: if sat_type not in satellites: continue for sat_id in satellites[sat_type]: # Must look if we already have it sats = getattr(self, sat_type) sat = satellites[sat_type][sat_id] sats[sat_id] = sat if sat['name'] in override_conf['satellitemap']: sat = dict(sat) # make a copy sat.update(override_conf['satellitemap'][sat['name']]) proto = 'http' if sat['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sat['address'], sat['port']) sats[sat_id]['uri'] = uri sats[sat_id]['con'] = None sats[sat_id]['running_id'] = 0 sats[sat_id]['last_connection'] = 0 sats[sat_id]['connection_attempt'] = 0 sats[sat_id]['max_failed_connections'] = 3 setattr(self, sat_type, sats) logger.debug("We have our %s: %s ", sat_type, satellites[sat_type]) logger.info("We have our %s:", sat_type) for daemon in satellites[sat_type].values(): logger.info(" - %s ", daemon['name']) # First mix conf and override_conf to have our definitive conf for prop in self.override_conf: val = self.override_conf[prop] setattr(self.conf, prop, val) if self.conf.use_timezone != '': logger.info("Setting our timezone to %s", str(self.conf.use_timezone)) os.environ['TZ'] = self.conf.use_timezone time.tzset() self.do_load_modules(self.modules) logger.info("Loading configuration.") self.conf.explode_global_conf() # pylint: disable=E1101 # we give sched it's conf self.sched.reset() self.sched.load_conf(self.conf) self.sched.load_satellites(self.pollers, self.reactionners, self.brokers) # We must update our Config dict macro with good value # from the config parameters self.sched.conf.fill_resource_macros_names_macros() # Creating the Macroresolver Class & unique instance m_solver = MacroResolver() m_solver.init(self.conf) # self.conf.dump() # self.conf.quick_debug() # Now create the external commands manager # We are an applyer: our role is not to dispatch commands, but to apply them ecm = ExternalCommandManager(self.conf, 'applyer', self.sched) # Scheduler needs to know about this external command manager to use it if necessary self.sched.set_external_commands_manager(ecm) # Update External Commands Manager self.sched.external_commands_manager.accept_passive_unknown_check_results = \ self.sched.conf.accept_passive_unknown_check_results # We clear our schedulers managed (it's us :) ) # and set ourselves in it self.schedulers = {self.conf.uuid: self.sched} # pylint: disable=E1101 # Ok now we can load the retention data self.sched.retention_load() # Create brok new conf brok = Brok({'type': 'new_conf', 'data': {}}) self.sched.add_brok(brok)
def setup_new_conf(self): # pylint: disable=R0915,R0912 """Parse new configuration and initialize all required :return: None """ with self.conf_lock: self.clean_previous_run() conf = unserialize(self.new_conf, True) self.new_conf = None self.cur_conf = conf # Got our name from the globals g_conf = conf['global'] if 'broker_name' in g_conf: name = g_conf['broker_name'] else: name = 'Unnamed broker' self.name = name # Set my own process title self.set_proctitle(self.name) logger.info("[%s] Received a new configuration, containing:", self.name) for key in conf: logger.info("[%s] - %s", self.name, key) logger.debug("[%s] global configuration part: %s", self.name, conf['global']) # local statsd self.statsd_host = g_conf['statsd_host'] self.statsd_port = g_conf['statsd_port'] self.statsd_prefix = g_conf['statsd_prefix'] self.statsd_enabled = g_conf['statsd_enabled'] # We got a name so we can update the logger and the stats global objects statsmgr.register(name, 'broker', statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled) # Get our Schedulers for sched_id in conf['schedulers']: # Must look if we already have it to do not overdie our broks old_sched_id = self.get_previous_sched_id(conf['schedulers'][sched_id], sched_id) if old_sched_id: logger.info("[%s] We already got the conf %s (%s)", self.name, old_sched_id, name) broks = self.schedulers[old_sched_id]['broks'] running_id = self.schedulers[old_sched_id]['running_id'] del self.schedulers[old_sched_id] else: broks = {} running_id = 0 sched = conf['schedulers'][sched_id] self.schedulers[sched_id] = sched # replacing scheduler address and port by those defined in satellitemap if sched['name'] in g_conf['satellitemap']: sched = dict(sched) # make a copy sched.update(g_conf['satellitemap'][sched['name']]) # todo: why not using a SatteliteLink object? proto = 'http' if sched['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, sched['address'], sched['port']) self.schedulers[sched_id]['uri'] = uri self.schedulers[sched_id]['broks'] = broks self.schedulers[sched_id]['instance_id'] = sched['instance_id'] self.schedulers[sched_id]['running_id'] = running_id self.schedulers[sched_id]['active'] = sched['active'] self.schedulers[sched_id]['last_connection'] = 0 self.schedulers[sched_id]['timeout'] = sched['timeout'] self.schedulers[sched_id]['data_timeout'] = sched['data_timeout'] self.schedulers[sched_id]['con'] = None self.schedulers[sched_id]['last_connection'] = 0 self.schedulers[sched_id]['connection_attempt'] = 0 self.schedulers[sched_id]['max_failed_connections'] = 3 logger.debug("We have our schedulers: %s", self.schedulers) logger.info("We have our schedulers:") for daemon in self.schedulers.values(): logger.info(" - %s ", daemon['name']) # Now get arbiters for arb_id in conf['arbiters']: # Must look if we already have it already_got = arb_id in self.arbiters if already_got: broks = self.arbiters[arb_id]['broks'] else: broks = {} arb = conf['arbiters'][arb_id] self.arbiters[arb_id] = arb # replacing arbiter address and port by those defined in satellitemap if arb['name'] in g_conf['satellitemap']: arb = dict(arb) # make a copy arb.update(g_conf['satellitemap'][arb['name']]) # todo: why not using a SatteliteLink object? proto = 'http' if arb['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, arb['address'], arb['port']) self.arbiters[arb_id]['uri'] = uri self.arbiters[arb_id]['broks'] = broks self.arbiters[arb_id]['instance_id'] = 0 # No use so all to 0 self.arbiters[arb_id]['running_id'] = 0 self.arbiters[arb_id]['con'] = None self.arbiters[arb_id]['last_connection'] = 0 self.arbiters[arb_id]['connection_attempt'] = 0 self.arbiters[arb_id]['max_failed_connections'] = 3 # We do not connect to the arbiter. Connection hangs logger.debug("We have our arbiters: %s ", self.arbiters) logger.info("We have our arbiters:") for daemon in self.arbiters.values(): logger.info(" - %s ", daemon['name']) # Now for pollers # 658: temporary fix if 'pollers' in conf: for pol_id in conf['pollers']: # Must look if we already have it already_got = pol_id in self.pollers if already_got: broks = self.pollers[pol_id]['broks'] running_id = self.pollers[pol_id]['running_id'] else: broks = {} running_id = 0 poll = conf['pollers'][pol_id] self.pollers[pol_id] = poll # replacing poller address and port by those defined in satellitemap if poll['name'] in g_conf['satellitemap']: poll = dict(poll) # make a copy poll.update(g_conf['satellitemap'][poll['name']]) # todo: why not using a SatteliteLink object? proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, poll['address'], poll['port']) self.pollers[pol_id]['uri'] = uri self.pollers[pol_id]['broks'] = broks self.pollers[pol_id]['instance_id'] = 0 # No use so all to 0 self.pollers[pol_id]['running_id'] = running_id self.pollers[pol_id]['con'] = None self.pollers[pol_id]['last_connection'] = 0 self.pollers[pol_id]['connection_attempt'] = 0 self.pollers[pol_id]['max_failed_connections'] = 3 else: logger.warning("[%s] no pollers in the received configuration", self.name) logger.debug("We have our pollers: %s", self.pollers) logger.info("We have our pollers:") for daemon in self.pollers.values(): logger.info(" - %s ", daemon['name']) # Now reactionners # 658: temporary fix if 'reactionners' in conf: for rea_id in conf['reactionners']: # Must look if we already have it already_got = rea_id in self.reactionners if already_got: broks = self.reactionners[rea_id]['broks'] running_id = self.reactionners[rea_id]['running_id'] else: broks = {} running_id = 0 reac = conf['reactionners'][rea_id] self.reactionners[rea_id] = reac # replacing reactionner address and port by those defined in satellitemap if reac['name'] in g_conf['satellitemap']: reac = dict(reac) # make a copy reac.update(g_conf['satellitemap'][reac['name']]) # todo: why not using a SatteliteLink object? proto = 'http' if reac['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, reac['address'], reac['port']) self.reactionners[rea_id]['uri'] = uri self.reactionners[rea_id]['broks'] = broks self.reactionners[rea_id]['instance_id'] = 0 # No use so all to 0 self.reactionners[rea_id]['running_id'] = running_id self.reactionners[rea_id]['con'] = None self.reactionners[rea_id]['last_connection'] = 0 self.reactionners[rea_id]['connection_attempt'] = 0 self.reactionners[rea_id]['max_failed_connections'] = 3 else: logger.warning("[%s] no reactionners in the received configuration", self.name) logger.debug("We have our reactionners: %s", self.reactionners) logger.info("We have our reactionners:") for daemon in self.reactionners.values(): logger.info(" - %s ", daemon['name']) # Now receivers # 658: temporary fix if 'receivers' in conf: for rec_id in conf['receivers']: # Must look if we already have it already_got = rec_id in self.receivers if already_got: broks = self.receivers[rec_id]['broks'] running_id = self.receivers[rec_id]['running_id'] else: broks = {} running_id = 0 rec = conf['receivers'][rec_id] self.receivers[rec_id] = rec # replacing reactionner address and port by those defined in satellitemap if rec['name'] in g_conf['satellitemap']: rec = dict(rec) # make a copy rec.update(g_conf['satellitemap'][rec['name']]) # todo: why not using a SatteliteLink object? proto = 'http' if rec['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, rec['address'], rec['port']) self.receivers[rec_id]['uri'] = uri self.receivers[rec_id]['broks'] = broks self.receivers[rec_id]['instance_id'] = rec['instance_id'] self.receivers[rec_id]['running_id'] = running_id self.receivers[rec_id]['con'] = None self.receivers[rec_id]['last_connection'] = 0 self.receivers[rec_id]['connection_attempt'] = 0 self.receivers[rec_id]['max_failed_connections'] = 3 else: logger.warning("[%s] no receivers in the received configuration", self.name) logger.debug("We have our receivers: %s", self.receivers) logger.info("We have our receivers:") for daemon in self.receivers.values(): logger.info(" - %s ", daemon['name']) if not self.have_modules: self.modules = conf['global']['modules'] self.have_modules = True # Ok now start, or restart them! # Set modules, init them and start external ones self.do_load_modules(self.modules) self.modules_manager.start_external_instances() # Set our giving timezone from arbiter use_timezone = conf['global']['use_timezone'] if use_timezone != 'NOTSET': logger.info("Setting our timezone to %s", use_timezone) os.environ['TZ'] = use_timezone time.tzset() # Initialize connection with Schedulers, Pollers and Reactionners for sched_id in self.schedulers: self.daemon_connection_init(sched_id, s_type='scheduler') for pol_id in self.pollers: self.daemon_connection_init(pol_id, s_type='poller') for rea_id in self.reactionners: self.daemon_connection_init(rea_id, s_type='reactionner')
def setup_new_conf(self): """Setup new conf received for scheduler :return: None """ with self.conf_lock: new_c = self.new_conf conf_raw = new_c['conf'] override_conf = new_c['override_conf'] modules = new_c['modules'] satellites = new_c['satellites'] instance_name = new_c['instance_name'] push_flavor = new_c['push_flavor'] skip_initial_broks = new_c['skip_initial_broks'] accept_passive_unknown_chk_res = new_c[ 'accept_passive_unknown_check_results'] api_key = new_c['api_key'] secret = new_c['secret'] http_proxy = new_c['http_proxy'] statsd_host = new_c['statsd_host'] statsd_port = new_c['statsd_port'] statsd_prefix = new_c['statsd_prefix'] statsd_enabled = new_c['statsd_enabled'] # horay, we got a name, we can set it in our stats objects statsmgr.register(self.sched, instance_name, 'scheduler', api_key=api_key, secret=secret, http_proxy=http_proxy, statsd_host=statsd_host, statsd_port=statsd_port, statsd_prefix=statsd_prefix, statsd_enabled=statsd_enabled) t00 = time.time() conf = cPickle.loads(conf_raw) logger.debug("Conf received at %d. Unserialized in %d secs", t00, time.time() - t00) self.new_conf = None # Tag the conf with our data self.conf = conf self.conf.push_flavor = push_flavor self.conf.instance_name = instance_name self.conf.skip_initial_broks = skip_initial_broks self.conf.accept_passive_unknown_check_results = accept_passive_unknown_chk_res self.cur_conf = conf self.override_conf = override_conf self.modules = modules self.satellites = satellites # self.pollers = self.app.pollers if self.conf.human_timestamp_log: # pylint: disable=E1101 logger.set_human_format() # Now We create our pollers for pol_id in satellites['pollers']: # Must look if we already have it already_got = pol_id in self.pollers poll = satellites['pollers'][pol_id] self.pollers[pol_id] = poll if poll['name'] in override_conf['satellitemap']: poll = dict(poll) # make a copy poll.update(override_conf['satellitemap'][poll['name']]) proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, poll['address'], poll['port']) self.pollers[pol_id]['uri'] = uri self.pollers[pol_id]['last_connection'] = 0 # Now We create our reactionners for reac_id in satellites['reactionners']: # Must look if we already have it already_got = reac_id in self.reactionners reac = satellites['reactionners'][reac_id] self.reactionners[reac_id] = reac if reac['name'] in override_conf['satellitemap']: reac = dict(reac) # make a copy reac.update(override_conf['satellitemap'][reac['name']]) proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, reac['address'], reac['port']) self.reactionners[reac_id]['uri'] = uri self.reactionners[reac_id]['last_connection'] = 0 # First mix conf and override_conf to have our definitive conf for prop in self.override_conf: val = self.override_conf[prop] setattr(self.conf, prop, val) if self.conf.use_timezone != '': logger.debug("Setting our timezone to %s", str(self.conf.use_timezone)) os.environ['TZ'] = self.conf.use_timezone time.tzset() if len(self.modules) != 0: logger.debug("I've got %s modules", str(self.modules)) # TODO: if scheduler had previous modules instanciated it must clean them! self.do_load_modules(self.modules) logger.info("Loading configuration.") self.conf.explode_global_conf() # we give sched it's conf self.sched.reset() self.sched.load_conf(self.conf) self.sched.load_satellites(self.pollers, self.reactionners) # We must update our Config dict macro with good value # from the config parameters self.sched.conf.fill_resource_macros_names_macros() # print "DBG: got macros", self.sched.conf.macros # Creating the Macroresolver Class & unique instance m_solver = MacroResolver() m_solver.init(self.conf) # self.conf.dump() # self.conf.quick_debug() # Now create the external commander # it's a applyer: it role is not to dispatch commands, # but to apply them ecm = ExternalCommandManager(self.conf, 'applyer') # Scheduler need to know about external command to # activate it if necessary self.sched.load_external_command(ecm) # External command need the sched because he can raise checks ecm.load_scheduler(self.sched) # We clear our schedulers managed (it's us :) ) # and set ourself in it self.schedulers = {self.conf.instance_id: self.sched}
def setup_new_conf(self): """Setup new conf received for scheduler :return: None """ with self.conf_lock: new_c = self.new_conf conf_raw = new_c['conf'] override_conf = new_c['override_conf'] modules = new_c['modules'] satellites = new_c['satellites'] instance_name = new_c['instance_name'] push_flavor = new_c['push_flavor'] skip_initial_broks = new_c['skip_initial_broks'] accept_passive_unknown_chk_res = new_c['accept_passive_unknown_check_results'] api_key = new_c['api_key'] secret = new_c['secret'] http_proxy = new_c['http_proxy'] statsd_host = new_c['statsd_host'] statsd_port = new_c['statsd_port'] statsd_prefix = new_c['statsd_prefix'] statsd_enabled = new_c['statsd_enabled'] # horay, we got a name, we can set it in our stats objects statsmgr.register(self.sched, instance_name, 'scheduler', api_key=api_key, secret=secret, http_proxy=http_proxy, statsd_host=statsd_host, statsd_port=statsd_port, statsd_prefix=statsd_prefix, statsd_enabled=statsd_enabled) t00 = time.time() conf = cPickle.loads(conf_raw) logger.debug("Conf received at %d. Unserialized in %d secs", t00, time.time() - t00) self.new_conf = None # Tag the conf with our data self.conf = conf self.conf.push_flavor = push_flavor self.conf.instance_name = instance_name self.conf.skip_initial_broks = skip_initial_broks self.conf.accept_passive_unknown_check_results = accept_passive_unknown_chk_res self.cur_conf = conf self.override_conf = override_conf self.modules = modules self.satellites = satellites # self.pollers = self.app.pollers if self.conf.human_timestamp_log: logger.set_human_format() # Now We create our pollers for pol_id in satellites['pollers']: # Must look if we already have it already_got = pol_id in self.pollers poll = satellites['pollers'][pol_id] self.pollers[pol_id] = poll if poll['name'] in override_conf['satellitemap']: poll = dict(poll) # make a copy poll.update(override_conf['satellitemap'][poll['name']]) proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, poll['address'], poll['port']) self.pollers[pol_id]['uri'] = uri self.pollers[pol_id]['last_connection'] = 0 # Now We create our reactionners for reac_id in satellites['reactionners']: # Must look if we already have it already_got = reac_id in self.reactionners reac = satellites['reactionners'][reac_id] self.reactionners[reac_id] = reac if reac['name'] in override_conf['satellitemap']: reac = dict(reac) # make a copy reac.update(override_conf['satellitemap'][reac['name']]) proto = 'http' if poll['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, reac['address'], reac['port']) self.reactionners[reac_id]['uri'] = uri self.reactionners[reac_id]['last_connection'] = 0 # First mix conf and override_conf to have our definitive conf for prop in self.override_conf: val = self.override_conf[prop] setattr(self.conf, prop, val) if self.conf.use_timezone != '': logger.debug("Setting our timezone to %s", str(self.conf.use_timezone)) os.environ['TZ'] = self.conf.use_timezone time.tzset() if len(self.modules) != 0: logger.debug("I've got %s modules", str(self.modules)) # TODO: if scheduler had previous modules instanciated it must clean them! self.modules_manager.set_modules(self.modules) self.do_load_modules() logger.info("Loading configuration.") self.conf.explode_global_conf() # we give sched it's conf self.sched.reset() self.sched.load_conf(self.conf) self.sched.load_satellites(self.pollers, self.reactionners) # We must update our Config dict macro with good value # from the config parameters self.sched.conf.fill_resource_macros_names_macros() # print "DBG: got macros", self.sched.conf.macros # Creating the Macroresolver Class & unique instance m_solver = MacroResolver() m_solver.init(self.conf) # self.conf.dump() # self.conf.quick_debug() # Now create the external commander # it's a applyer: it role is not to dispatch commands, # but to apply them ecm = ExternalCommandManager(self.conf, 'applyer') # Scheduler need to know about external command to # activate it if necessary self.sched.load_external_command(ecm) # External command need the sched because he can raise checks ecm.load_scheduler(self.sched) # We clear our schedulers managed (it's us :) ) # and set ourself in it self.schedulers = {self.conf.instance_id: self.sched}