]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
nicira plugin: load subnet once when adding router interface
authorSalvatore Orlando <salv.orlando@gmail.com>
Fri, 7 Jun 2013 10:33:44 +0000 (12:33 +0200)
committerSalvatore Orlando <salv.orlando@gmail.com>
Fri, 7 Jun 2013 10:35:18 +0000 (12:35 +0200)
Bug 1188562

This patch ensure subnet is loaded only once from the database.
Also, the port is now loaded from the database only if the
corresponding NVP logical port is found.

Change-Id: I1626c7b61ddc8e785d8ce2e39619da78b20ae61e

quantum/plugins/nicira/QuantumPlugin.py

index 9722042d5812d6173b4eb8627a16bb069dbc7cdc..5043ee47dd5578b5a275608c604d9f0869cddd83 100644 (file)
@@ -1613,7 +1613,6 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         # The owner of the router port is always the same as the owner of the
         # router. Use tenant_id from the port instead of fetching more records
         # from the Quantum database
-        port = self._get_port(context, port_id)
         # Find the NVP port corresponding to quantum port_id
         results = nvplib.query_lswitch_lports(
             self.cluster, '*',
@@ -1627,6 +1626,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                            "backend.") % {'port_id': port_id,
                                           'router_id': router_id}))
 
+        port = self._get_port(context, port_id)
         # Create logical router port and patch attachment
         self._create_and_attach_router_port(
             self.cluster, context, router_id, port,
@@ -1642,7 +1642,6 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             # In that case we will consider only the first one
             if gw_port.get('fixed_ips'):
                 snat_ip = gw_port['fixed_ips'][0]['ip_address']
-                subnet = self._get_subnet(context, subnet_id)
                 cidr_prefix = int(subnet['cidr'].split('/')[1])
                 nvplib.create_lrouter_snat_rule(
                     self.cluster, router_id, snat_ip, snat_ip,