Can't set gateway on no subnet network

1. check to avoid update gateway on network with no subnet
2. fixed set gateway no subnet failed unit test case

TBD add in new unit test - skip that so that we can unblock the gate
Change-Id: I1e7aed4b6d0e98bf326b73f68640f6554628efdc
This commit is contained in:
linb 2016-06-16 18:07:46 +08:00 committed by Gary Kotton
parent b2467e9889
commit 5e79efbcf3
2 changed files with 12 additions and 0 deletions

View File

@ -1851,6 +1851,12 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
msg = (_("Network '%s' is not a valid external network") %
network_id)
raise n_exc.BadRequest(resource='router', msg=msg)
subnets = self._get_subnets_by_network(context, network_id)
if not subnets:
msg = _("Cannot update gateway on Network '%s' "
"with no subnet") % network_id
raise n_exc.BadRequest(resource='router', msg=msg)
return gw_info
def _validate_router_size(self, router):

View File

@ -1897,6 +1897,12 @@ class L3NatTest(test_l3_plugin.L3BaseForIntTests, NsxVPluginV2TestCase):
def test_floatingip_association_on_unowned_router(self):
self.skipTest("Currently no support in plugin for this")
def test_router_add_gateway_no_subnet(self):
self.skipTest('No support for no subnet gateway set')
def test_router_add_gateway_no_subnet_forbidden(self):
self.skipTest('TBD - unblock gate')
class L3NatTestCaseBase(test_l3_plugin.L3NatTestCaseMixin):