Remove router_type for distributed router
It makes people confused that distributed router is exclusive/shared router. This patch disable router_type configuration when creating router and remove router_type when displaying distributed router. Fixes-bug: #1499248 Change-Id: Ie427dc5fae118567e45b48953e24afbceed6f754
This commit is contained in:
parent
d5e254d4b5
commit
67c2b82875
vmware_nsx/neutron
@ -184,6 +184,10 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
router_type = None
|
||||
if attr.is_attr_set(r.get("distributed")) and r.get("distributed"):
|
||||
router_type = "distributed"
|
||||
if attr.is_attr_set(r.get("router_type")):
|
||||
err_msg = _('Can not support router_type extension for '
|
||||
'distributed router')
|
||||
raise n_exc.InvalidInput(error_message=err_msg)
|
||||
elif attr.is_attr_set(r.get("router_type")):
|
||||
router_type = r.get("router_type")
|
||||
|
||||
@ -1381,6 +1385,12 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
router_driver.delete_router(context, id)
|
||||
super(NsxVPluginV2, self).delete_router(context, id)
|
||||
|
||||
def get_router(self, context, id, fields=None):
|
||||
router = super(NsxVPluginV2, self).get_router(context, id, fields)
|
||||
if router.get("distributed") and 'router_type' in router:
|
||||
del router['router_type']
|
||||
return router
|
||||
|
||||
def _get_external_attachment_info(self, context, router):
|
||||
gw_port = router.gw_port
|
||||
ipaddress = None
|
||||
|
@ -2009,10 +2009,12 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
return router_req.get_response(self.ext_api)
|
||||
|
||||
def _test_router_create_with_distributed(self, dist_input, dist_expected,
|
||||
return_code=201):
|
||||
return_code=201, **kwargs):
|
||||
data = {'tenant_id': 'whatever'}
|
||||
data['name'] = 'router1'
|
||||
data['distributed'] = dist_input
|
||||
for k, v in six.iteritems(kwargs):
|
||||
data[k] = v
|
||||
router_req = self.new_create_request(
|
||||
'routers', {'router': data}, self.fmt)
|
||||
res = router_req.get_response(self.ext_api)
|
||||
@ -2020,9 +2022,16 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
if res.status_int == 201:
|
||||
router = self.deserialize(self.fmt, res)
|
||||
self.assertIn('distributed', router['router'])
|
||||
if dist_input:
|
||||
self.assertNotIn('router_type', router['router'])
|
||||
self.assertEqual(dist_expected,
|
||||
router['router']['distributed'])
|
||||
|
||||
def test_create_router_fails_with_router_type(self):
|
||||
self._test_router_create_with_distributed(True, True,
|
||||
return_code=400,
|
||||
router_type="shared")
|
||||
|
||||
def test_router_create_distributed(self):
|
||||
self._test_router_create_with_distributed(True, True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user