From d671bada20e7f0a1a7bf587f40489a12551c717c Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 7 Jun 2013 12:33:44 +0200 Subject: [PATCH] nicira plugin: load subnet once when adding router interface 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/quantum/plugins/nicira/QuantumPlugin.py b/quantum/plugins/nicira/QuantumPlugin.py index 9722042d5..5043ee47d 100644 --- a/quantum/plugins/nicira/QuantumPlugin.py +++ b/quantum/plugins/nicira/QuantumPlugin.py @@ -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, -- 2.45.2