def create_rpc_dispatcher(self): '''Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method. ''' return dispatcher.RpcDispatcher([self])
def setup_rpc(self): self.host = socket.gethostname() self.agent_id = 'nec-q-agent.%s' % self.host LOG.info(_("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.context = q_context.get_admin_context_without_session() self.plugin_rpc = NECPluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.sg_agent = SecurityGroupAgentRpc(self.context) # RPC network init # Handle updates from service self.callback_nec = NECAgentRpcCallback(self.context, self, self.sg_agent) self.callback_sg = SecurityGroupAgentRpcCallback( self.context, self.sg_agent) self.dispatcher = dispatcher.RpcDispatcher( [self.callback_nec, self.callback_sg]) # Define the listening consumer for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.dispatcher, self.topic, consumers) report_interval = config.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
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]) # 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) # Consume from all consumers in a thread self.conn.consume_in_thread()
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]) # 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()
def _create_rpc_dispatcher(self): return dispatcher.RpcDispatcher([self])
def _setup_rpc(self): self.conn = rpc.create_connection(new=True) self.callback = DhcpRpcCallbackMixin() self.dispatcher = dispatcher.RpcDispatcher([self.callback]) self.conn.create_consumer(topics.PLUGIN, self.dispatcher, fanout=False) self.conn.consume_in_thread()