Ensure that Conflict errors are not masked; also ensure
that coding errors do not mask NVP API errors.
Fixes bug #
1244259
Change-Id: I27586d72af89fd39f6443dbab33f0e4e762b0c99
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)
"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")
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: