Пример #1
0
    def __init__(self, connection, config, handler=None):
        # Grab a copy of our config section
        self.config = config.section('DHCPAgent')

        # grab relevant settings
        queue_expire = int(self.config.get('queue_expire', 60))

        # Initialize logger
        self.logger = Logger(name='dhcpagent',
                             level=self.config['loglevel'],
                             handler=handler)

        # Parse agent conf
        self.qconfig = Config(self.config['conffile'], 'AGENT')

        # Initialize super
        NeutronAgent.__init__(self, self.qconfig, self.config, 'DHCP agent')

        # Initialize RPC bits
        RPC.__init__(self,
                     connection,
                     exopts={
                         'name': self.event_queue(),
                         'durable': False,
                         'type': 'topic'
                     },
                     qopts={
                         'name': 'rpcdaemon-dhcp_%s' % uuid4(),
                         'auto_delete': True,
                         'durable': False,
                         'routing_key': 'q-plugin',
                         'queue_arguments': {
                             'x-expires': queue_expire * 1000,
                         }
                     })
Пример #2
0
 def __init__(self, connection, plugins=[], handler=None):
     Thread.__init__(self, target=self.run)  # MRO picks mixin.run
     self.connection = connection
     self.is_connected = True
     self.plugins = plugins
     self.queues = [plugin.queue for plugin in plugins]
     self.callbacks = [plugin.update for plugin in plugins]
     self.logger = Logger(name='consumer',
                          handler=handler)
Пример #3
0
    def __init__(self, args=None):
        # Parse args
        if args is None:
            args = {}

        options, _ = getopt.getopt(sys.argv[1:], 'c:d')
        options = dict(options)

        config_file = options.get('-c', '/usr/local/etc/rpcdaemon.conf')
        daemonize = '-d' not in options

        # Parse config
        self.config = Config(config_file, 'Daemon')

        # Initialize logger
        self.logger = Logger(
            name='rpcdaemon',
            level = self.config['loglevel'],
            path = self.config['logfile'] if daemonize else None,
            handler = None if daemonize else logging.StreamHandler()
        )

        self.pidfile = PIDFile(self.config['pidfile']) if daemonize else None;

        # TOOD: plugin.check thread pool?
        self.timeout = int(self.config.get('check_interval', 1))

        # Clamp in case we exit before worker exists
        self.worker = None

        # Initialize daemon
        DaemonContext.__init__(
            self,
            detach_process=daemonize,
            files_preserve=[self.logger.handler.stream.fileno()],
            pidfile=self.pidfile,
            stdout=self.logger.handler.stream,
            stderr=self.logger.handler.stream
        )
Пример #4
0
    def __init__(self, connection, config, handler=None):
        # Grab a copy of our config section
        self.config = config.section('Dump')

        # Initialize logger
        self.logger = Logger(name='dump',
                             level=self.config['loglevel'],
                             handler=handler)

        # Initialize RPC bits
        RPC.__init__(self,
                     connection,
                     exopts={
                         'name': self.config.get('queue', 'neutron'),
                         'durable': False,
                         'type': 'topic'
                     },
                     qopts={
                         'name': 'rpcdaemon-dump_%s' % uuid4(),
                         'auto_delete': True,
                         'durable': False,
                         'routing_key': 'q-plugin'
                     })