Merge "Fix error while creating l2 gateway services in nvp"

This commit is contained in:
Jenkins 2013-10-27 23:16:38 +00:00 committed by Gerrit Code Review
commit e4f77c7683
3 changed files with 19 additions and 5 deletions

View File

@ -1914,11 +1914,12 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
nvp_res = nvplib.create_l2_gw_service(self.cluster, tenant_id,
gw_data['name'], devices)
nvp_uuid = nvp_res.get('uuid')
except Exception:
raise nvp_exc.NvpPluginException(
err_msg=_("Create_l2_gw_service did not "
"return an uuid for the newly "
"created resource:%s") % nvp_res)
except NvpApiClient.Conflict:
raise nvp_exc.NvpL2GatewayAlreadyInUse(gateway=gw_data['name'])
except NvpApiClient.NvpApiException:
err_msg = _("Unable to create l2_gw_service for: %s") % gw_data
LOG.exception(err_msg)
raise nvp_exc.NvpPluginException(err_msg=err_msg)
gw_data['id'] = nvp_uuid
return super(NvpPluginV2, self).create_network_gateway(context,
network_gateway)

View File

@ -70,6 +70,10 @@ class NvpServicePluginException(q_exc.NeutronException):
"in the NVP Service Plugin: %(err_msg)s")
class NvpL2GatewayAlreadyInUse(q_exc.Conflict):
message = _("Gateway Service %(gateway)s is already in use")
class NvpServiceOverQuota(q_exc.Conflict):
message = _("Quota exceeded for Vcns resource: %(overs)s: %(err_msg)s")

View File

@ -1389,6 +1389,15 @@ class TestNiciraNetworkGateway(test_l2_gw.NetworkGatewayDbTestCase,
devices=[{'id': uuidutils.generate_uuid()}])
self.assertEqual(500, res.status_int)
def test_create_network_gateway_nvp_error_returns_409(self):
with mock.patch.object(nvplib,
'create_l2_gw_service',
side_effect=NvpApiClient.Conflict):
res = self._create_network_gateway(
self.fmt, 'xxx', name='yyy',
devices=[{'id': uuidutils.generate_uuid()}])
self.assertEqual(409, res.status_int)
def test_list_network_gateways(self):
with self._network_gateway(name='test-gw-1') as gw1:
with self._network_gateway(name='test_gw_2') as gw2: