]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ovs: remove several unneeded object attributes from setup_rpc()
authorIhar Hrachyshka <ihrachys@redhat.com>
Tue, 13 Oct 2015 16:11:29 +0000 (18:11 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Tue, 20 Oct 2015 15:32:18 +0000 (17:32 +0200)
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

neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py

index e63392ddded944365405ab7511913b6f7d392ed3..21cde8d4bf0175671dbadff6c4b3e38a38b6b5b1 100644 (file)
@@ -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)