Browse Source

Merge "NSX|V3+P: Improve router interface actions performance" into stable/stein

changes/36/680936/1
Zuul 2 weeks ago
parent
commit
88956e3a7e

+ 4
- 13
vmware_nsx/plugins/common/plugin.py View File

@@ -131,14 +131,15 @@ class NsxPluginBase(db_base_plugin_v2.NeutronDbPluginV2,
131 131
         return subnetpool.get('address_scope_id', '')
132 132
 
133 133
     def _validate_address_scope_for_router_interface(self, context, router_id,
134
-                                                     gw_network_id, subnet_id):
134
+                                                     gw_network_id, subnet_id,
135
+                                                     subnet=None):
135 136
         """Validate that the GW address scope is the same as the interface"""
136 137
         gw_address_scope = self._get_network_address_scope(context,
137 138
                                                            gw_network_id)
138 139
         if not gw_address_scope:
139 140
             return
140
-        subnet_address_scope = self._get_subnet_address_scope(context,
141
-                                                              subnet_id)
141
+        subnet_address_scope = self._get_subnet_address_scope(
142
+            context, subnet_id, subnet=subnet)
142 143
         if (not subnet_address_scope or
143 144
             subnet_address_scope != gw_address_scope):
144 145
             raise nsx_exc.NsxRouterInterfaceDoesNotMatchAddressScope(
@@ -397,16 +398,6 @@ class NsxPluginBase(db_base_plugin_v2.NeutronDbPluginV2,
397 398
         if qos_policy_id:
398 399
             qos_com_utils.validate_policy_accessable(context, qos_policy_id)
399 400
 
400
-    def _get_interface_network(self, context, interface_info):
401
-        is_port, is_sub = self._validate_interface_info(interface_info)
402
-        if is_port:
403
-            net_id = self.get_port(context,
404
-                                   interface_info['port_id'])['network_id']
405
-        elif is_sub:
406
-            net_id = self.get_subnet(context,
407
-                                     interface_info['subnet_id'])['network_id']
408
-        return net_id
409
-
410 401
     def _process_extra_attr_router_create(self, context, router_db, r):
411 402
         for extra_attr in l3_attrs_db.get_attr_info().keys():
412 403
             if (extra_attr in r and

+ 17
- 6
vmware_nsx/plugins/common_v3/plugin.py View File

@@ -50,6 +50,7 @@ from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
50 50
 from neutron_lib.api.definitions import availability_zone as az_def
51 51
 from neutron_lib.api.definitions import external_net as extnet_apidef
52 52
 from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
53
+from neutron_lib.api.definitions import l3 as l3_apidef
53 54
 from neutron_lib.api.definitions import port_security as psec
54 55
 from neutron_lib.api.definitions import portbindings as pbin
55 56
 from neutron_lib.api.definitions import provider_net as pnet
@@ -273,7 +274,10 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
273 274
         if subnet_id:
274 275
             return self.get_subnet(context, subnet_id)
275 276
 
276
-    def _get_interface_network(self, context, interface_info):
277
+    def _get_interface_network_id(self, context, interface_info, subnet=None):
278
+        if subnet:
279
+            return subnet['network_id']
280
+
277 281
         is_port, is_sub = self._validate_interface_info(interface_info)
278 282
         if is_port:
279 283
             net_id = self.get_port(context,
@@ -296,15 +300,14 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
296 300
              sg_rule[sg_prefix.LOCAL_IP_PREFIX].startswith('::/'))):
297 301
             sg_rule[sg_prefix.LOCAL_IP_PREFIX] = None
298 302
 
299
-    def _validate_interface_address_scope(self, context,
300
-                                          router_db, interface_info):
303
+    def _validate_interface_address_scope(self, context, router_db,
304
+                                          interface_subnet):
301 305
         gw_network_id = (router_db.gw_port.network_id if router_db.gw_port
302 306
                          else None)
303
-
304
-        subnet = self.get_subnet(context, interface_info['subnet_ids'][0])
305 307
         if not router_db.enable_snat and gw_network_id:
306 308
             self._validate_address_scope_for_router_interface(
307
-                context.elevated(), router_db.id, gw_network_id, subnet['id'])
309
+                context.elevated(), router_db.id, gw_network_id,
310
+                interface_subnet['id'], subnet=interface_subnet)
308 311
 
309 312
     def _validate_address_pairs(self, address_pairs):
310 313
         for pair in address_pairs:
@@ -1246,6 +1249,10 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
1246 1249
         """
1247 1250
         pass
1248 1251
 
1252
+    def _get_router_gw_info(self, context, router_id):
1253
+        router = self.get_router(context, router_id)
1254
+        return router.get(l3_apidef.EXTERNAL_GW_INFO, {})
1255
+
1249 1256
     def _validate_router_gw_and_tz(self, context, router_id, info,
1250 1257
                                    org_enable_snat, router_subnets):
1251 1258
         # Ensure that a router cannot have SNAT disabled if there are
@@ -1266,6 +1273,10 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
1266 1273
                 self._validate_router_tz(context, new_tier0_uuid,
1267 1274
                                          router_subnets)
1268 1275
 
1276
+    def _get_tier0_uuid_by_router(self, context, router):
1277
+        network_id = router.gw_port_id and router.gw_port.network_id
1278
+        return self._get_tier0_uuid_by_net_id(context, network_id)
1279
+
1269 1280
     def _validate_gw_overlap_interfaces(self, context, gateway_net,
1270 1281
                                         interfaces_networks):
1271 1282
         # Ensure that interface subnets cannot overlap with the GW subnet

+ 34
- 41
vmware_nsx/plugins/nsx_p/plugin.py View File

@@ -877,9 +877,9 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
877 877
         return updated_net
878 878
 
879 879
     def _update_slaac_on_router(self, context, router_id,
880
-                                subnet, delete=False):
881
-        # TODO(annak): for vlan networks it should be possible
882
-        # to enable slaac on interface basis
880
+                                subnet, router_subnets, delete=False):
881
+        # TODO(annak): redesign when policy supports downlink-level
882
+        # ndra profile attachment
883 883
 
884 884
         # This code is optimised to deal with concurrency challenges
885 885
         # (which can not be always solved by lock because the plugin
@@ -896,12 +896,9 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
896 896
             profile_id = SLAAC_NDRA_PROFILE_ID
897 897
 
898 898
         if delete:
899
-
900
-            rtr_subnets = self._load_router_subnet_cidrs_from_db(
901
-                context.elevated(), router_id)
902 899
             # check if there is another slaac overlay subnet that needs
903 900
             # advertising (vlan advertising is attached on interface level)
904
-            slaac_subnets = [s for s in rtr_subnets
901
+            slaac_subnets = [s for s in router_subnets
905 902
                              if s['id'] != subnet['id'] and
906 903
                              s.get('ipv6_address_mode') == 'slaac' and
907 904
                              self._is_overlay_network(context,
@@ -1430,10 +1427,6 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1430 1427
         return (ports if not fields else
1431 1428
                 [db_utils.resource_fields(port, fields) for port in ports])
1432 1429
 
1433
-    def _get_tier0_uuid_by_router(self, context, router):
1434
-        network_id = router.gw_port_id and router.gw_port.network_id
1435
-        return self._get_tier0_uuid_by_net_id(context, network_id)
1436
-
1437 1430
     def _add_subnet_snat_rule(self, context, router_id, subnet,
1438 1431
                               gw_address_scope, gw_ip):
1439 1432
         if not self._need_router_snat_rules(context, router_id, subnet,
@@ -1765,9 +1758,15 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1765 1758
         return self.get_router(context, router['id'])
1766 1759
 
1767 1760
     def delete_router(self, context, router_id):
1768
-        router = self.get_router(context, router_id)
1769
-        if router.get(l3_apidef.EXTERNAL_GW_INFO):
1770
-            self._update_router_gw_info(context, router_id, {})
1761
+        gw_info = self._get_router_gw_info(context, router_id)
1762
+        if gw_info:
1763
+            try:
1764
+                self._update_router_gw_info(context, router_id, {})
1765
+            except nsx_lib_exc.NsxLibException as e:
1766
+                LOG.error("Failed to remove router %s gw info before "
1767
+                          "deletion, but going on with the deletion anyway: "
1768
+                          "%s", router_id, e)
1769
+
1771 1770
         ret_val = super(NsxPolicyPlugin, self).delete_router(
1772 1771
             context, router_id)
1773 1772
 
@@ -1872,16 +1871,17 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1872 1871
         return "%s/%s" % (subnet['gateway_ip'], cidr_prefix)
1873 1872
 
1874 1873
     def add_router_interface(self, context, router_id, interface_info):
1875
-        network_id = self._get_interface_network(context, interface_info)
1874
+        # NOTE: In dual stack case, neutron would create a separate interface
1875
+        # for each IP version
1876
+        # We only allow one subnet per IP version
1877
+        subnet = self._get_interface_subnet(context, interface_info)
1878
+        network_id = self._get_interface_network_id(context, interface_info,
1879
+                                                    subnet=subnet)
1876 1880
         extern_net = self._network_is_external(context, network_id)
1877 1881
         overlay_net = self._is_overlay_network(context, network_id)
1878 1882
         router_db = self._get_router(context, router_id)
1879 1883
         gw_network_id = (router_db.gw_port.network_id if router_db.gw_port
1880 1884
                          else None)
1881
-        # NOTE: In dual stack case, neutron would create a separate interface
1882
-        # for each IP version
1883
-        # We only allow one subnet per IP version
1884
-        subnet = self._get_interface_subnet(context, interface_info)
1885 1885
 
1886 1886
         with locking.LockManager.get_lock(str(network_id)):
1887 1887
             # disallow more than one subnets belong to same network being
@@ -1908,28 +1908,25 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1908 1908
 
1909 1909
             # Update the interface of the neutron router
1910 1910
             info = super(NsxPolicyPlugin, self).add_router_interface(
1911
-                 context, router_id, interface_info)
1911
+                context, router_id, interface_info)
1912 1912
 
1913 1913
         try:
1914 1914
             # If it is a no-snat router, interface address scope must be the
1915 1915
             # same as the gateways
1916
-            self._validate_interface_address_scope(context, router_db, info)
1916
+            self._validate_interface_address_scope(context, router_db, subnet)
1917 1917
 
1918 1918
             # Check GW & subnets TZ
1919
-            subnets = self._load_router_subnet_cidrs_from_db(
1920
-                context.elevated(), router_id)
1921 1919
             tier0_uuid = self._get_tier0_uuid_by_router(
1922 1920
                 context.elevated(), router_db)
1923
-            #TODO(asarfaty): it is enough to validate only the new subnet,
1924
-            # and not all
1925
-            self._validate_router_tz(context.elevated(), tier0_uuid, subnets)
1921
+            self._validate_router_tz(context.elevated(), tier0_uuid, [subnet])
1926 1922
 
1927 1923
             segment_id = self._get_network_nsx_segment_id(context, network_id)
1928
-            subnet = self.get_subnet(context, info['subnet_ids'][0])
1924
+            rtr_subnets = self._load_router_subnet_cidrs_from_db(
1925
+                context.elevated(), router_id)
1929 1926
             if overlay_net:
1930 1927
                 # overlay interface
1931 1928
                 pol_subnets = []
1932
-                for rtr_subnet in subnets:
1929
+                for rtr_subnet in rtr_subnets:
1933 1930
                     # For dual stack, we allow one v4 and one v6
1934 1931
                     # subnet per network
1935 1932
                     if rtr_subnet['network_id'] == network_id:
@@ -1944,11 +1941,11 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1944 1941
 
1945 1942
                 # will update the router only if needed
1946 1943
                 self._update_slaac_on_router(context, router_id,
1947
-                                             subnet)
1944
+                                             subnet, rtr_subnets)
1948 1945
             else:
1949 1946
                 # Vlan interface
1950 1947
                 pol_subnets = []
1951
-                for rtr_subnet in subnets:
1948
+                for rtr_subnet in rtr_subnets:
1952 1949
                     if rtr_subnet['network_id'] == network_id:
1953 1950
                         prefix_len = int(rtr_subnet['cidr'].split('/')[1])
1954 1951
                         pol_subnets.append(policy_defs.InterfaceSubnet(
@@ -1978,7 +1975,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1978 1975
                 # if this is an ipv6 subnet and router has GW,
1979 1976
                 # we need to add advertisement rule
1980 1977
                 self._update_router_advertisement_rules(
1981
-                    router_id, subnets, True)
1978
+                    router_id, rtr_subnets, True)
1982 1979
 
1983 1980
             # update firewall rules
1984 1981
             self.update_router_firewall(context, router_id, router_db)
@@ -1994,7 +1991,6 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
1994 1991
         return info
1995 1992
 
1996 1993
     def remove_router_interface(self, context, router_id, interface_info):
1997
-        LOG.info("Removing router %s interface %s", router_id, interface_info)
1998 1994
         # find the subnet - it is need for removing the SNAT rule
1999 1995
         subnet = subnet_id = None
2000 1996
         if 'port_id' in interface_info:
@@ -2014,13 +2010,13 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
2014 2010
         overlay_net = self._is_overlay_network(context, network_id)
2015 2011
         segment_id = self._get_network_nsx_segment_id(context, network_id)
2016 2012
 
2017
-        subnets = self._load_router_subnet_cidrs_from_db(context.elevated(),
2018
-                                                         router_id)
2013
+        rtr_subnets = self._load_router_subnet_cidrs_from_db(
2014
+            context.elevated(), router_id)
2019 2015
         try:
2020 2016
             if overlay_net:
2021 2017
                 # Remove the tier1 router from this segment on the NSX
2022 2018
                 pol_subnets = []
2023
-                for rtr_subnet in subnets:
2019
+                for rtr_subnet in rtr_subnets:
2024 2020
                     # For dual stack, we allow one v4 and one v6
2025 2021
                     # subnet per network
2026 2022
                     if rtr_subnet['network_id'] == network_id:
@@ -2039,12 +2035,12 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
2039 2035
 
2040 2036
                 # will update the router only if needed
2041 2037
                 self._update_slaac_on_router(context, router_id,
2042
-                                             subnet, delete=True)
2038
+                                             subnet, rtr_subnets, delete=True)
2043 2039
 
2044 2040
             else:
2045 2041
                 # VLAN interface
2046 2042
                 pol_subnets = []
2047
-                for rtr_subnet in subnets:
2043
+                for rtr_subnet in rtr_subnets:
2048 2044
                     if rtr_subnet['network_id'] == network_id:
2049 2045
                         prefix_len = int(rtr_subnet['cidr'].split('/')[1])
2050 2046
                         pol_subnets.append(policy_defs.InterfaceSubnet(
@@ -2060,9 +2056,6 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
2060 2056
                     self.nsxpolicy.tier1.remove_segment_interface(
2061 2057
                         router_id, segment_id)
2062 2058
 
2063
-            # will update the router only if needed
2064
-            self._update_slaac_on_router(context, router_id,
2065
-                                         subnet, delete=True)
2066 2059
             # try to delete the SNAT/NO_DNAT rules of this subnet
2067 2060
             router_db = self._get_router(context, router_id)
2068 2061
             if (subnet and router_db.gw_port and router_db.enable_snat and
@@ -2074,7 +2067,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
2074 2067
                 # if this is an ipv6 subnet and router has GW,
2075 2068
                 # we need to remove advertisement rule
2076 2069
                 self._update_router_advertisement_rules(
2077
-                    router_id, subnets, True)
2070
+                    router_id, rtr_subnets, True)
2078 2071
 
2079 2072
             # update firewall rules
2080 2073
             self.update_router_firewall(context, router_id, router_db)

+ 25
- 29
vmware_nsx/plugins/nsx_v3/plugin.py View File

@@ -2081,10 +2081,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2081 2081
         return (ports if not fields else
2082 2082
                 [db_utils.resource_fields(port, fields) for port in ports])
2083 2083
 
2084
-    def _get_tier0_uuid_by_router(self, context, router):
2085
-        network_id = router.gw_port_id and router.gw_port.network_id
2086
-        return self._get_tier0_uuid_by_net_id(context, network_id)
2087
-
2088 2084
     def _validate_router_tz(self, context, tier0_uuid, subnets):
2089 2085
         # make sure the related GW (Tier0 router) belongs to the same TZ
2090 2086
         # as the subnets attached to the Tier1 router
@@ -2364,8 +2360,8 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2364 2360
         if not cfg.CONF.nsx_v3.native_dhcp_metadata:
2365 2361
             nsx_rpc.handle_router_metadata_access(self, context, router_id,
2366 2362
                                                   interface=None)
2367
-        router = self.get_router(context, router_id)
2368
-        if router.get(l3_apidef.EXTERNAL_GW_INFO):
2363
+        gw_info = self._get_router_gw_info(context, router_id)
2364
+        if gw_info:
2369 2365
             self._update_router_gw_info(context, router_id, {})
2370 2366
         nsx_router_id = nsx_db.get_nsx_router_id(context.session,
2371 2367
                                                  router_id)
@@ -2696,15 +2692,16 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2696 2692
                  context, router_id, interface_info)
2697 2693
 
2698 2694
     def add_router_interface(self, context, router_id, interface_info):
2699
-        network_id = self._get_interface_network(context, interface_info)
2695
+        # In case on dual stack, neutron creates a separate interface per
2696
+        # IP version
2697
+        subnet = self._get_interface_subnet(context, interface_info)
2698
+        network_id = self._get_interface_network_id(context, interface_info,
2699
+                                                    subnet=subnet)
2700 2700
         extern_net = self._network_is_external(context, network_id)
2701 2701
         overlay_net = self._is_overlay_network(context, network_id)
2702 2702
         router_db = self._get_router(context, router_id)
2703 2703
         gw_network_id = (router_db.gw_port.network_id if router_db.gw_port
2704 2704
                          else None)
2705
-        # In case on dual stack, neutron creates a separate interface per
2706
-        # IP version
2707
-        subnet = self._get_interface_subnet(context, interface_info)
2708 2705
 
2709 2706
         with locking.LockManager.get_lock(str(network_id)):
2710 2707
             # disallow more than one subnets belong to same network being
@@ -2733,14 +2730,12 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2733 2730
             info = self._add_router_interface_wrapper(context, router_id,
2734 2731
                                                       interface_info)
2735 2732
         try:
2736
-            subnet = self.get_subnet(context, info['subnet_ids'][0])
2737
-            port = self.get_port(context, info['port_id'])
2738 2733
             nsx_net_id, nsx_port_id = nsx_db.get_nsx_switch_and_port_id(
2739
-                context.session, port['id'])
2734
+                context.session, info['port_id'])
2740 2735
 
2741 2736
             # If it is a no-snat router, interface address scope must be the
2742 2737
             # same as the gateways
2743
-            self._validate_interface_address_scope(context, router_db, info)
2738
+            self._validate_interface_address_scope(context, router_db, subnet)
2744 2739
 
2745 2740
             nsx_router_id = nsx_db.get_nsx_router_id(context.session,
2746 2741
                                                      router_id)
@@ -2749,7 +2744,8 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2749 2744
             display_name = utils.get_name_and_uuid(
2750 2745
                 subnet['name'] or 'subnet', subnet['id'])
2751 2746
             tags = self.nsxlib.build_v3_tags_payload(
2752
-                port, resource_type='os-neutron-rport-id',
2747
+                {'id': info['port_id'], 'project_id': context.project_id},
2748
+                resource_type='os-neutron-rport-id',
2753 2749
                 project_name=context.tenant_name)
2754 2750
             tags.append({'scope': 'os-subnet-id', 'tag': subnet['id']})
2755 2751
 
@@ -2762,12 +2758,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2762 2758
             resource_type = (None if overlay_net else
2763 2759
                              nsxlib_consts.LROUTERPORT_CENTRALIZED)
2764 2760
 
2765
-            # If this is an ENS case - check GW & subnets
2766
-            subnets = self._load_router_subnet_cidrs_from_db(
2767
-                context.elevated(), router_id)
2761
+            # Validate the TZ of the new subnet match the one of the router
2768 2762
             tier0_uuid = self._get_tier0_uuid_by_router(context.elevated(),
2769 2763
                                                         router_db)
2770
-            self._validate_router_tz(context.elevated(), tier0_uuid, subnets)
2764
+            self._validate_router_tz(context.elevated(), tier0_uuid, [subnet])
2771 2765
 
2772 2766
             # create the interface ports on the NSX
2773 2767
             self.nsxlib.router.create_logical_router_intf_port_by_ls_id(
@@ -2821,14 +2815,17 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2821 2815
         return info
2822 2816
 
2823 2817
     def remove_router_interface(self, context, router_id, interface_info):
2818
+        self._validate_interface_info(interface_info, for_removal=True)
2819
+        # Get the interface port & subnet
2824 2820
         subnet = None
2825 2821
         subnet_id = None
2826 2822
         port_id = None
2827
-        self._validate_interface_info(interface_info, for_removal=True)
2823
+        network_id = None
2828 2824
         if 'port_id' in interface_info:
2829 2825
             port_id = interface_info['port_id']
2830 2826
             # find subnet_id - it is need for removing the SNAT rule
2831 2827
             port = self._get_port(context, port_id)
2828
+            network_id = port['network_id']
2832 2829
             if port.get('fixed_ips'):
2833 2830
                 for fip in port['fixed_ips']:
2834 2831
                     subnet_id = fip['subnet_id']
@@ -2843,11 +2840,9 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2843 2840
             self._confirm_router_interface_not_in_use(
2844 2841
                 context, router_id, subnet_id)
2845 2842
             subnet = self._get_subnet(context, subnet_id)
2846
-            rport_qry = context.session.query(models_v2.Port)
2847
-            ports = rport_qry.filter_by(
2848
-                device_id=router_id,
2849
-                device_owner=l3_db.DEVICE_OWNER_ROUTER_INTF,
2850
-                network_id=subnet['network_id'])
2843
+            network_id = subnet['network_id']
2844
+            ports = self._get_router_interface_ports_by_network(
2845
+                context, router_id, network_id)
2851 2846
             for p in ports:
2852 2847
                 fip_subnet_ids = [fixed_ip['subnet_id']
2853 2848
                                   for fixed_ip in p['fixed_ips']]
@@ -2866,10 +2861,11 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2866 2861
 
2867 2862
             nsx_net_id, _nsx_port_id = nsx_db.get_nsx_switch_and_port_id(
2868 2863
                 context.session, port_id)
2869
-            subnet = self.get_subnet(context, subnet_id)
2864
+            if not subnet:
2865
+                subnet = self._get_subnet(context, subnet_id)
2870 2866
             ports, address_groups = self._get_ports_and_address_groups(
2871
-                context, router_id, subnet['network_id'],
2872
-                exclude_sub_ids=[subnet['id']])
2867
+                context, router_id, network_id,
2868
+                exclude_sub_ids=[subnet_id])
2873 2869
             nsx_router_id = nsx_db.get_nsx_router_id(
2874 2870
                 context.session, router_id)
2875 2871
             if len(ports) >= 1:
@@ -2898,7 +2894,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
2898 2894
             LOG.error("router port on router %(router_id)s for net "
2899 2895
                       "%(net_id)s not found at the backend",
2900 2896
                       {'router_id': router_id,
2901
-                       'net_id': subnet['network_id']})
2897
+                       'net_id': network_id})
2902 2898
 
2903 2899
         # inform the FWaaS that interface port was removed
2904 2900
         if self.fwaas_callbacks:

Loading…
Cancel
Save