diff --git a/neutron/plugins/vmware/plugins/base.py b/neutron/plugins/vmware/plugins/base.py index d066ba0634..0ad0fc3086 100644 --- a/neutron/plugins/vmware/plugins/base.py +++ b/neutron/plugins/vmware/plugins/base.py @@ -1746,12 +1746,12 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, info = super(NsxPluginV2, self).remove_router_interface( context, router_id, interface_info) - # Ensure the connection to the 'metadata access network' - # is removed (with the network) if this the last subnet - # on the router - self.handle_router_metadata_access( - context, router_id, interface=info) try: + # Ensure the connection to the 'metadata access network' + # is removed (with the network) if this the last subnet + # on the router + self.handle_router_metadata_access( + context, router_id, interface=info) if not subnet: subnet = self._get_subnet(context, subnet_id) router = self._get_router(context, router_id) @@ -1767,10 +1767,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, self.cluster, nsx_router_id, "NoSourceNatRule", max_num_expected=1, min_num_expected=0, destination_ip_addresses=subnet['cidr']) - except api_exc.ResourceNotFound: - raise nsx_exc.NsxPluginException( - err_msg=(_("Logical router resource %s not found " - "on NSX platform") % router_id)) + except n_exc.NotFound: + LOG.error(_("Logical router resource %s not found " + "on NSX platform") % router_id) except api_exc.NsxApiException: raise nsx_exc.NsxPluginException( err_msg=(_("Unable to update logical router" diff --git a/neutron/tests/unit/vmware/test_nsx_plugin.py b/neutron/tests/unit/vmware/test_nsx_plugin.py index 6c0cecc609..4120345902 100644 --- a/neutron/tests/unit/vmware/test_nsx_plugin.py +++ b/neutron/tests/unit/vmware/test_nsx_plugin.py @@ -1111,6 +1111,28 @@ class NeutronNsxOutOfSync(NsxPluginV2TestCase, res = req.get_response(self.ext_api) self.assertEqual(res.status_int, 200) + def test_remove_router_interface_not_in_nsx(self): + # Create internal network and subnet + int_sub_id = self._create_network_and_subnet('10.0.0.0/24')[1] + res = self._create_router('json', 'tenant') + router = self.deserialize('json', res) + # Add interface to router (needed to generate NAT rule) + req = self.new_action_request( + 'routers', + {'subnet_id': int_sub_id}, + router['router']['id'], + "add_router_interface") + res = req.get_response(self.ext_api) + self.assertEqual(res.status_int, 200) + self.fc._fake_lrouter_dict.clear() + req = self.new_action_request( + 'routers', + {'subnet_id': int_sub_id}, + router['router']['id'], + "remove_router_interface") + res = req.get_response(self.ext_api) + self.assertEqual(res.status_int, 200) + def test_update_router_not_in_nsx(self): res = self._create_router('json', 'tenant') router = self.deserialize('json', res)