Merge "NSX|v: Distributed router type update failure"

This commit is contained in:
Jenkins 2017-05-09 14:25:00 +00:00 committed by Gerrit Code Review
commit 812101b3ef
2 changed files with 25 additions and 1 deletions

View File

@ -2980,7 +2980,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

@ -3886,6 +3886,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')