NSX|v: Distributed router type update failure

Changing the type of a distributed router is not supported.
Make sure we fail with the appropriate message in this case.

Change-Id: I5bab1c8ad447c6a9ec5df68826f653ef0a1919a4
This commit is contained in:
Adit Sarfaty 2017-05-09 09:06:08 +03:00
parent de7ff11d02
commit 79f4bca30e
2 changed files with 25 additions and 1 deletions

View File

@ -2857,7 +2857,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Toggling router type is supported only for non-distributed router
elif 'router_type' in router['router']:
r = self.get_router(context, router_id)
if r['router_type'] != router['router']['router_type']:
if r.get('router_type') != router['router']['router_type']:
if r["distributed"]:
err_msg = _('Unable to update distributed mode')
raise n_exc.InvalidInput(error_message=err_msg)

View File

@ -3778,6 +3778,30 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
with self.subnet(network=net, enable_dhcp=False):
self._make_floatingip(self.fmt, net_id)
def test_router_update_type_fails(self):
"""Check distributed router cannot change it's type
"""
# create a distributed router
tenant_id = _uuid()
res = self._create_router(self.fmt, tenant_id, distributed=True)
r = self.deserialize(self.fmt, res)
router_id = r['router']['id']
# make sure changing the type fails
self._update('routers', router_id,
{'router': {'router_type': 'shared'}},
expected_code=400)
self._update('routers', router_id,
{'router': {'router_type': 'exclusive'}},
expected_code=400)
self._update('routers', router_id,
{'router': {'distributed': False}},
expected_code=400)
# make sure keeping the type is ok
self._update('routers', router_id,
{'router': {'distributed': True}},
expected_code=200)
def test_router_add_interface_multiple_ipv4_subnets(self):
self.skipTest('TBD')