Пример #1
0
    def __init__(self):
        self.config = Config('giraffe.cfg')

        # configure RabbitMQ connector (and consumer)
        self.connector = Connector(username=self.config.get('rabbit', 'user'),
                                   password=self.config.get('rabbit', 'pass'),
                                   host=self.config.get('rabbit', 'host'),
                                   port=self.config.getint('rabbit', 'port'))
        self.queue = self.config.get('rabbit', 'queue')
        self.exchange = self.config.get('rabbit', 'exchange')
        self.routing_key = self.config.get('rabbit', 'routing_key')

        self.consumer = BasicConsumer(self.connector, self.queue,
                                      self.exchange, self._collector_callback)

        self.shared_secret = self.config.get('collector', 'shared_secret')

        # connect to giraffe database
        self.db = db.connect(
            '%s://%s:%s@%s/%s' %
            (self.config.get('db', 'vendor'), self.config.get('db', 'user'),
             self.config.get('db', 'pass'), self.config.get(
                 'db', 'host'), self.config.get('db', 'schema')))

        # prepare connection to nova-client
        self._credentials = dict(
            username=self.config.get('agent', 'user'),
            password=self.config.get('agent', 'pass'),
            #                        tenant_id=self.config.get('agent', 'tenant_id'),
            tenant_name=self.config.get('agent', 'tenant_name'),
            auth_url=self.config.get('auth', 'admin_url'),
            insecure=True)

        # known servers/instances
        self.known_instances = {}
Пример #2
0
    def __init__(self, agent):
        threading.Thread.__init__(self)

        self.agent = agent
        config = Config('giraffe.cfg')
        self.host_name = config.get('agent', 'host_name')

        self.flush_duration = config.getint('agent', 'duration')

        self.connector = Connector(username=config.get('rabbit', 'user'),
                                   password=config.get('rabbit', 'pass'),
                                   host=config.get('rabbit', 'host'),
                                   port=config.getint('rabbit', 'port'))
        self.queue = config.get('rabbit', 'queue')
        self.exchange = config.get('rabbit', 'exchange')
        self.routing_key = config.get('rabbit', 'routing_key')
        self.producer = BasicProducer(self.connector, self.exchange)

        self.shared_secret = config.get('agent', 'shared_secret')
        self.envelope = self._build_message()

        self.stopRequest = False
        self.lock = threading.Lock()