From d95283a731c3078c10173822e248c5f39be0b1fa Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 13 Oct 2015 18:11:29 +0200 Subject: [PATCH] ovs: remove several unneeded object attributes from setup_rpc() It's currently not clear what the interactions and interdependencies between existing attributes set inside setup_rpc() and other code are. This complicates its perception. So reduce the complexity a bit by using local variables instead of object attributes where applies; and moving agent_id calculation out of setup_rpc() since it's not related to AMQP. Change-Id: I6ad156a7dd686ab2a2349704a34385db1ee9681c --- .../openvswitch/agent/ovs_neutron_agent.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index e63392ddd..21cde8d4b 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -201,6 +201,9 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.arp_responder_enabled = arp_responder and self.l2_pop self.prevent_arp_spoofing = prevent_arp_spoofing + host = self.conf.host + self.agent_id = 'ovs-agent-%s' % host + if tunnel_types: self.enable_tunneling = True else: @@ -261,13 +264,13 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.phys_ofports, self.patch_int_ofport, self.patch_tun_ofport, - self.conf.host, + host, self.enable_tunneling, self.enable_distributed_routing) self.agent_state = { 'binary': 'neutron-openvswitch-agent', - 'host': self.conf.host, + 'host': host, 'topic': n_const.L2_AGENT_TOPIC, 'configurations': {'bridge_mappings': bridge_mappings, 'tunnel_types': self.tunnel_types, @@ -362,8 +365,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, local_vlan) def setup_rpc(self): - self.agent_id = 'ovs-agent-%s' % self.conf.host - self.topic = topics.AGENT self.plugin_rpc = OVSPluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.dvr_plugin_rpc = dvr_rpc.DVRServerRpcApi(topics.PLUGIN) @@ -371,8 +372,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, # RPC network init self.context = context.get_admin_context_without_session() - # Handle updates from service - self.endpoints = [self] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.PORT, topics.DELETE], @@ -383,8 +382,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, [topics.NETWORK, topics.UPDATE]] if self.l2_pop: consumers.append([topics.L2POPULATION, topics.UPDATE]) - self.connection = agent_rpc.create_consumers(self.endpoints, - self.topic, + self.connection = agent_rpc.create_consumers([self], + topics.AGENT, consumers, start_listening=False) -- 2.45.2