コード例 #1
0
ファイル: __init__.py プロジェクト: AnatomicJC/mmc
def initialize(config):
    singleton = HttpInventoryProxySingleton()
    singleton.initialise(config)
    f = http.HTTPFactory()
    f.protocol = MyProxy
    # Listen to incoming connection
    reactor.listenTCP(config.port, f)
    # Run the periodic inventory if configured
    if config.polling:
        r = RunInventory()
        r.setup(config)
        r.run()
コード例 #2
0
def initialize(config):
    singleton = HttpInventoryProxySingleton()
    singleton.initialise(config)
    f = http.HTTPFactory()
    f.protocol = MyProxy
    # Listen to incoming connection
    reactor.listenTCP(config.port, f)
    # Run the periodic inventory if configured
    if config.polling:
        r = RunInventory()
        r.setup(config)
        r.run()
コード例 #3
0
ファイル: threads.py プロジェクト: AnatomicJC/mmc
class RunInventory(Singleton):

    """
    Little helper class that runs the inventory agent
    """

    def setup(self, config):
        self.config = config
        self.logger = logging.getLogger()
        from pulse2.proxyssl.http_inventory_proxy import HttpInventoryProxySingleton
        self.singleton = HttpInventoryProxySingleton()

    def maybeStartLoop(self):
        if self.config.polling:
            self.logger.debug("Scheduling inventory in %s seconds" % self.config.polling_time)
            reactor.callLater(self.config.polling_time, self.run)

    def run(self):
        """
        Start an OCS inventory, and loop according to the configuration
        """
        if self.singleton.check_flag():
            self.logger.debug("Starting an inventory")
            d = utils.getProcessOutputAndValue(self.config.command_name, self.config.command_attr)
            d.addCallbacks(self.onSuccess, self.onError)
        else:
            self.logger.debug("Flag not set, not starting an inventory")
        self.maybeStartLoop()

    def onSuccess(self, result):
        self.logger.debug("Inventory done")

    def onError(self, reason):
        self.logger.error("Error while doing inventory: %s" % str(reason))
コード例 #4
0
class RunInventory(Singleton):
    """
    Little helper class that runs the inventory agent
    """
    def setup(self, config):
        self.config = config
        self.logger = logging.getLogger()
        from pulse2.proxyssl.http_inventory_proxy import HttpInventoryProxySingleton
        self.singleton = HttpInventoryProxySingleton()

    def maybeStartLoop(self):
        if self.config.polling:
            self.logger.debug("Scheduling inventory in %s seconds" %
                              self.config.polling_time)
            reactor.callLater(self.config.polling_time, self.run)

    def run(self):
        """
        Start an OCS inventory, and loop according to the configuration
        """
        if self.singleton.check_flag():
            self.logger.debug("Starting an inventory")
            d = utils.getProcessOutputAndValue(self.config.command_name,
                                               self.config.command_attr)
            d.addCallbacks(self.onSuccess, self.onError)
        else:
            self.logger.debug("Flag not set, not starting an inventory")
        self.maybeStartLoop()

    def onSuccess(self, result):
        self.logger.debug("Inventory done")

    def onError(self, reason):
        self.logger.error("Error while doing inventory: %s" % str(reason))
コード例 #5
0
ファイル: threads.py プロジェクト: AnatomicJC/mmc
 def setup(self, config):
     self.config = config
     self.logger = logging.getLogger()
     from pulse2.proxyssl.http_inventory_proxy import HttpInventoryProxySingleton
     self.singleton = HttpInventoryProxySingleton()
コード例 #6
0
 def setup(self, config):
     self.config = config
     self.logger = logging.getLogger()
     from pulse2.proxyssl.http_inventory_proxy import HttpInventoryProxySingleton
     self.singleton = HttpInventoryProxySingleton()