예제 #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()