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 q_rpc.PluginRpcDispatcher( [self, agents_db.AgentExtRpcCallback()])
def _register_one_dhcp_agent(self): """Register one DHCP agent.""" dhcp_host = { 'binary': 'quantum-dhcp-agent', 'host': DHCP_HOST1, 'topic': 'DHCP_AGENT', 'configurations': { 'dhcp_driver': 'dhcp_driver', 'use_namespaces': True, }, 'agent_type': constants.AGENT_TYPE_DHCP } callback = agents_db.AgentExtRpcCallback() callback.report_state(self.adminContext, agent_state={'agent_state': dhcp_host}, time=timeutils.strtime()) return [dhcp_host]
def setup_rpc(self): self.topic = topics.PLUGIN self.conn = rpc.create_connection(new=True) self.notifier = NECPluginV2AgentNotifierApi(topics.AGENT) self.dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI() self.l3_agent_notifier = l3_rpc_agent_api.L3AgentNotify # NOTE: callback_sg is referred to from the sg unit test. self.callback_sg = SecurityGroupServerRpcCallback() callbacks = [ NECPluginV2RPCCallbacks(self), DhcpRpcCallback(), L3RpcCallback(), self.callback_sg, agents_db.AgentExtRpcCallback() ] self.dispatcher = q_rpc.PluginRpcDispatcher(callbacks) self.conn.create_consumer(self.topic, self.dispatcher, fanout=False) # Consume from all consumers in a thread self.conn.consume_in_thread()
def _register_agent_states(self): """Register two L3 agents and two DHCP agents.""" l3_hosta = { 'binary': 'quantum-l3-agent', 'host': L3_HOSTA, 'topic': topics.L3_AGENT, 'configurations': { 'use_namespaces': True, 'router_id': None, 'handle_internal_only_routers': True, 'gateway_external_network_id': None, 'interface_driver': 'interface_driver', }, 'agent_type': constants.AGENT_TYPE_L3 } l3_hostb = copy.deepcopy(l3_hosta) l3_hostb['host'] = L3_HOSTB dhcp_hosta = { 'binary': 'quantum-dhcp-agent', 'host': DHCP_HOSTA, 'topic': 'DHCP_AGENT', 'configurations': { 'dhcp_driver': 'dhcp_driver', 'use_namespaces': True, }, 'agent_type': constants.AGENT_TYPE_DHCP } dhcp_hostc = copy.deepcopy(dhcp_hosta) dhcp_hostc['host'] = DHCP_HOSTC callback = agents_db.AgentExtRpcCallback() callback.report_state(self.adminContext, agent_state={'agent_state': l3_hosta}, time=timeutils.strtime()) callback.report_state(self.adminContext, agent_state={'agent_state': l3_hostb}, time=timeutils.strtime()) callback.report_state(self.adminContext, agent_state={'agent_state': dhcp_hosta}, time=timeutils.strtime()) callback.report_state(self.adminContext, agent_state={'agent_state': dhcp_hostc}, time=timeutils.strtime()) return [l3_hosta, l3_hostb, dhcp_hosta, dhcp_hostc]
def _register_one_agent_state(self, agent_state): callback = agents_db.AgentExtRpcCallback() callback.report_state(self.adminContext, agent_state={'agent_state': agent_state}, time=timeutils.strtime())