Merge "NSX: Fix router-interface-delete returns 404 when router not in nsx"

This commit is contained in:
Jenkins 2014-03-20 10:22:43 +00:00 committed by Gerrit Code Review
commit 8c10ad5a02
2 changed files with 30 additions and 9 deletions

View File

@ -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"

View File

@ -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)