def run(self):
        from chroma_core.services.plugin_runner.agent_daemon_interface import AgentDaemonRpcInterface
        from chroma_core.services.plugin_runner.scan_daemon import ScanDaemon
        from chroma_core.services.plugin_runner.scan_daemon_interface import ScanDaemonRpcInterface
        from chroma_core.lib.storage_plugin.manager import storage_plugin_manager

        super(Service, self).run()

        errors = storage_plugin_manager.get_errored_plugins()
        if errors:
            self.log.error("The following plugins could not be loaded: %s" %
                           errors)
            raise RuntimeError("Some plugins could not be loaded: %s" % errors)

        resource_manager = ResourceManager()
        scan_daemon = ScanDaemon(resource_manager)

        # For each plugin, start a thread which will consume its agent RX queue
        agent_handlers = AgentPluginHandlerCollection(resource_manager)
        for handler in agent_handlers.handlers.values():
            self.threads.append(ServiceThread(handler))

        scan_daemon_thread = ServiceThread(scan_daemon)
        scan_rpc_thread = ServiceThread(ScanDaemonRpcInterface(scan_daemon))
        agent_rpc_thread = ServiceThread(
            AgentDaemonRpcInterface(agent_handlers))

        self.threads.extend(
            [scan_daemon_thread, scan_rpc_thread, agent_rpc_thread])
        for thread in self.threads:
            thread.start()

        self._children_started.set()
        self._complete.wait()
        self.log.debug("Leaving main loop")
    def run(self, kwargs):
        from chroma_core.services.plugin_runner.agent_daemon_interface import AgentDaemonRpcInterface
        from chroma_core.services.job_scheduler.agent_rpc import AgentException

        host = kwargs['host']

        try:
            network_data = self.invoke_agent(host, "device_plugin", {'plugin': 'linux_network'})['linux_network']
            AgentDaemonRpcInterface().update_host_resources(host.id, {'linux_network': network_data})
        except TypeError:
            self.log("Data received from old client. Host %s state cannot be updated until agent is updated" % host)
        except AgentException as e:
            self.log("No data for plugin linux_network from host %s due to exception %s" % (host, e))
Beispiel #3
0
    def run(self, kwargs):
        from chroma_core.services.plugin_runner.agent_daemon_interface import AgentDaemonRpcInterface
        from chroma_core.services.job_scheduler.agent_rpc import AgentException

        host_id = kwargs["host_id"]
        fqdn = kwargs["fqdn"]

        try:
            network_data = self.invoke_agent(fqdn, "device_plugin", {"plugin": "linux_network"})["linux_network"]
            AgentDaemonRpcInterface().update_host_resources(host_id, {"linux_network": network_data})
        except TypeError:
            self.log(
                "Data received from old client. Host {} state cannot be updated until agent is updated".format(fqdn)
            )
        except AgentException as e:
            self.log("No data for plugin linux_network from host {} due to exception {}".format(fqdn, e))