def main(): """handle unexpected exceptions""" parser = argparse.ArgumentParser( description="Integrated Manager for Lustre software Agent") parser.add_argument("--publish-zconf", action="store_true") parser.parse_args() signal.signal(signal.SIGHUP, signal.SIG_IGN) daemon_log_setup() console_log_setup() daemon_log.info("Starting") try: daemon_log.info("Entering main loop") try: url = urljoin(os.environ["IML_MANAGER_URL"], "agent/message/") except KeyError as e: daemon_log.error( "No configuration found (must be registered before running the agent service), " "details: %s" % e) return if config.profile_managed is False: # This is kind of terrible. The design of DevicePluginManager is # such that it can be called with either class methods or # instantiated and then called with instance methods. As such, # we can't pass in a list of excluded plugins to the instance # constructor. Well, we could, but it would only work some # of the time and that would be even more awful. import chroma_agent.plugin_manager chroma_agent.plugin_manager.EXCLUDED_PLUGINS += ["corosync"] agent_client = AgentClient( url, ActionPluginManager(), DevicePluginManager(), ServerProperties(), Crypto(ENV_PATH), ) def teardown_callback(*args, **kwargs): agent_client.stop() agent_client.join() [function() for function in agent_daemon_teardown_functions] signal.signal(signal.SIGINT, teardown_callback) signal.signal(signal.SIGTERM, teardown_callback) signal.signal(signal.SIGUSR1, decrease_loglevel) signal.signal(signal.SIGUSR2, increase_loglevel) # Call any agent daemon startup methods that were registered. [function() for function in agent_daemon_startup_functions] agent_client.start() # Waking-wait to pick up signals while not agent_client.stopped.is_set(): agent_client.stopped.wait(timeout=10) agent_client.join() except Exception as e: backtrace = "\n".join(traceback.format_exception(*(sys.exc_info()))) daemon_log.error("Unhandled exception: %s" % backtrace) # Call any agent daemon teardown methods that were registered. [function() for function in agent_daemon_teardown_functions] daemon_log.info("Terminating")
def test_get_action_plugins(self): """Test that we get a list of loaded plugin classes.""" self.assertNotEqual(len(ActionPluginManager().commands), 0)
"No configuration found (must be registered before running the agent service), " "details: %s" % e) return if config.profile_managed is False: # This is kind of terrible. The design of DevicePluginManager is # such that it can be called with either class methods or # instantiated and then called with instance methods. As such, # we can't pass in a list of excluded plugins to the instance # constructor. Well, we could, but it would only work some # of the time and that would be even more awful. import chroma_agent.plugin_manager chroma_agent.plugin_manager.EXCLUDED_PLUGINS += ['corosync'] agent_client = AgentClient(conf['url'] + "message/", ActionPluginManager(), DevicePluginManager(), ServerProperties(), Crypto(config.path)) def teardown_callback(*args, **kwargs): agent_client.stop() agent_client.join() [function() for function in agent_daemon_teardown_functions] if not args.foreground: handlers = { signal.SIGTERM: teardown_callback, signal.SIGUSR1: decrease_loglevel, signal.SIGUSR2: increase_loglevel } set_signal_handlers(handlers)