# This will be useful for setting the value if the API request
# did not specify any value for the 'distributed' attribute
r['distributed'] = lrouter['distributed']
+ except nvp_exc.NvpInvalidVersion:
+ msg = _("Cannot create a distributed router with the NVP "
+ "platform currently in execution. Please, try "
+ "without specifying the 'distributed' attribute.")
+ LOG.exception(msg)
+ raise q_exc.BadRequest(resource='router', msg=msg)
except NvpApiClient.NvpApiException:
raise nvp_exc.NvpPluginException(
err_msg=_("Unable to create logical router on NVP Platform"))
def test_router_create_with_gwinfo_and_l3_ext_net_with_vlan(self):
self._test_router_create_with_gwinfo_and_l3_ext_net(444)
- def _test_router_create_with_distributed(self, dist_input, dist_expected):
+ def _test_router_create_with_distributed(self, dist_input, dist_expected,
+ version='3.1', return_code=201):
self.mock_instance.return_value.get_nvp_version.return_value = (
- NvpApiClient.NVPVersion('3.1'))
+ NvpApiClient.NVPVersion(version))
data = {'tenant_id': 'whatever'}
data['name'] = 'router1'
'routers', {'router': data}, self.fmt)
try:
res = router_req.get_response(self.ext_api)
- router = self.deserialize(self.fmt, res)
- self.assertIn('distributed', router['router'])
- self.assertEqual(dist_expected,
- router['router']['distributed'])
+ self.assertEqual(return_code, res.status_int)
+ if res.status_int == 201:
+ router = self.deserialize(self.fmt, res)
+ self.assertIn('distributed', router['router'])
+ self.assertEqual(dist_expected,
+ router['router']['distributed'])
finally:
- self._delete('routers', router['router']['id'])
+ if res.status_int == 201:
+ self._delete('routers', router['router']['id'])
def test_router_create_distributed(self):
self._test_router_create_with_distributed(True, True)
def test_router_create_distributed_unspecified(self):
self._test_router_create_with_distributed(None, False)
+ def test_router_create_distributed_returns_400(self):
+ self._test_router_create_with_distributed(True, None, '3.0', 400)
+
def test_router_create_nvp_error_returns_500(self, vlan_id=None):
with mock.patch.object(nvplib,
'create_router_lport',