]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Isolate use of fixed_ips[0] to avoid confusion
authorCarl Baldwin <carl.baldwin@hp.com>
Tue, 26 May 2015 20:33:56 +0000 (20:33 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Wed, 27 May 2015 15:48:37 +0000 (15:48 +0000)
I was looking at the assumption around using fixed_ips[0] in a recent
patch [1].  I thought at the least, the usage of fixed_ips[0] should
be isolated with the comment explaining why it is okay.

I thought that we could also use this patch as an opportunity to vet
the validity of the claim made in the comment.

[1] If4a310da06f9b0076a9f62926a16b574a8c109ce

Change-Id: Iba5713dd7d852429997ff43d98266a9f022d5d86

neutron/plugins/openvswitch/agent/ovs_dvr_neutron_agent.py

index db7a41cd4dc7a39fbde1e0923a64baa3e92c2c5c..3c4f7886d713c11f8cffb7dbdef65c6ae675cb2a 100644 (file)
@@ -407,9 +407,10 @@ class OVSDVRNeutronAgent(object):
 
     def _bind_distributed_router_interface_port(self, port, lvm,
                                                 fixed_ips, device_owner):
-        # since router port must have only one fixed IP, directly
-        # use fixed_ips[0]
-        subnet_uuid = fixed_ips[0]['subnet_id']
+        # since distributed router port must have only one fixed
+        # IP, directly use fixed_ips[0]
+        fixed_ip = fixed_ips[0]
+        subnet_uuid = fixed_ip['subnet_id']
         csnat_ofport = constants.OFPORT_INVALID
         ldm = None
         if subnet_uuid in self.local_dvr_map:
@@ -595,24 +596,25 @@ class OVSDVRNeutronAgent(object):
 
     def _bind_centralized_snat_port_on_dvr_subnet(self, port, lvm,
                                                   fixed_ips, device_owner):
+        # since centralized-SNAT (CSNAT) port must have only one fixed
+        # IP, directly use fixed_ips[0]
+        fixed_ip = fixed_ips[0]
         if port.vif_id in self.local_ports:
             # throw an error if CSNAT port is already on a different
             # dvr routed subnet
             ovsport = self.local_ports[port.vif_id]
             subs = list(ovsport.get_subnets())
-            if subs[0] == fixed_ips[0]['subnet_id']:
+            if subs[0] == fixed_ip['subnet_id']:
                 return
             LOG.error(_LE("Centralized-SNAT port %(port)s on subnet "
                           "%(port_subnet)s already seen on a different "
                           "subnet %(orig_subnet)s"), {
                 "port": port.vif_id,
-                "port_subnet": fixed_ips[0]['subnet_id'],
+                "port_subnet": fixed_ip['subnet_id'],
                 "orig_subnet": subs[0],
             })
             return
-        # since centralized-SNAT (CSNAT) port must have only one fixed
-        # IP, directly use fixed_ips[0]
-        subnet_uuid = fixed_ips[0]['subnet_id']
+        subnet_uuid = fixed_ip['subnet_id']
         ldm = None
         subnet_info = None
         if subnet_uuid not in self.local_dvr_map: