Exemple #1
0
    def start(self):
        super(Service, self).start()

        self.conn = rpc.create_connection(new=True)
        LOG.debug(_("Creating Consumer connection for Service %s") %
                  self.topic)

        dispatcher = rpc_dispatcher.RpcDispatcher([self.manager],
                                                  self.serializer)

        # Share this same connection for these Consumers
        self.conn.create_consumer(self.topic, dispatcher, fanout=False)

        node_topic = '%s.%s' % (self.topic, self.host)
        self.conn.create_consumer(node_topic, dispatcher, fanout=False)

        self.conn.create_consumer(self.topic, dispatcher, fanout=True)

        # Hook to allow the manager to do other initializations after
        # the rpc connection is created.
        if callable(getattr(self.manager, 'initialize_service_hook', None)):
            self.manager.initialize_service_hook(self)

        # Consume from all consumers in a thread
        self.conn.consume_in_thread()
Exemple #2
0
    def setup_rpc(self):
        """
        Create a 'crd-consumer' Fanout Queue and listen for delta configuration messages. 
        sends init_consumer message to crd-listener to update the consumer in CRD database
        """
        self.host = get_hostname()
        self.consumer_topic = "crd-consumer"
        self.listener_topic = 'crd-listener'
        # RPC network init
        self.consumer_context = context.RequestContext('crd', 'crd',
                                                       is_admin=False)

        # Handle updates from service
        self.dispatcher = self.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        self.conn = os_rpc.create_connection(new=True)

        LOG.info(_("Creating CONSUMER with topic %s...."), self.consumer_topic)
        self.conn.create_consumer(self.consumer_topic, self.dispatcher, fanout=True)
        self._init_consumer()
        self.conn.consume_in_thread()