NSX|V: Fix distributed router validation

Validation over router size was wrong

Change-Id: I4eb8160552fe071795804021f1f002f844f43584
This commit is contained in:
asarfaty 2019-12-08 10:13:30 +02:00 committed by Adit Sarfaty
parent dc5a0dedfb
commit e8db3dee16
2 changed files with 14 additions and 3 deletions

View File

@ -25,6 +25,7 @@ from neutron_lib.exceptions import l3 as l3_exc
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.extensions import routersize
from vmware_nsx.plugins.nsx_v.drivers import (
abstract_router_driver as router_driver)
from vmware_nsx.plugins.nsx_v import plugin as nsx_v
@ -83,8 +84,7 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
availability_zone=az)
def _validate_no_size(self, router):
if (validators.is_attr_set(router.get('routes')) and
len(router['routes']) > 0):
if validators.is_attr_set(router.get(routersize.ROUTER_SIZE)):
msg = _("Cannot specify router-size for distributed router")
raise n_exc.InvalidInput(error_message=msg)

View File

@ -4652,6 +4652,17 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
p['port']['id'],
expected_code=exp_code)
def test_router_update_with_size_fail(self):
"""Distributed router currently does not support router size update
"""
with self.router() as r:
router_id = r['router']['id']
body = self._show('routers', router_id)
body['router']['router_size'] = 'small'
self._update('routers', router_id, body,
expected_code=400,
neutron_context=context.get_admin_context())
class TestNSXvAllowedAddressPairs(NsxVPluginV2TestCase,
test_addr_pair.TestAllowedAddressPairs):
@ -5851,7 +5862,7 @@ class TestSharedRouterTestCase(L3NatTest, L3NatTestCaseBase,
self._test_create_router_with_az_hint(False)
def test_router_update_with_size_fail(self):
"""Shared router currently does not support static routes
"""Shared router currently does not support router size update
"""
with self.router() as r:
router_id = r['router']['id']