def _run(self): log.info("%s running" % self.__class__.__name__) event = SaltEventSource(log, salt_config) while not self._complete.is_set(): ev = event.get_event(full=True) if ev is not None and 'tag' in ev: tag = ev['tag'] data = ev['data'] try: if tag.startswith("salt/auth"): log.debug("Tag: %s Data: %s" % (tag, data)) if djangoUtil.check_minion_is_new(data['id']): djangoUtil.add_minion_to_free_pool(data['id']) else: log.debug( "Ignoring - Already added to the free pool") else: # This does not concern us, ignore it log.debug("TopLevelEvents: ignoring %s" % tag) pass except: log.exception("Exception handling message tag=%s" % tag) log.info("%s complete" % self.__class__.__name__)
def start(self): log.info("%s starting" % self.__class__.__name__) # Before we start listening to the outside world, recover # our last known state from persistent storage try: self._recover() except: log.exception("Recovery failed") os._exit(-1) # self._rpc_thread.bind() # self._rpc_thread.start() self._discovery_thread.start()