netaddr.AddrFormatError) as e:
LOG.exception(_('%s failed'), action)
e = translate(e, language)
- body = serializer.serialize({'NeutronError': e})
+ # following structure is expected by python-neutronclient
+ err_data = {'type': e.__class__.__name__,
+ 'message': e, 'detail': ''}
+ body = serializer.serialize({'NeutronError': err_data})
kwargs = {'body': body, 'content_type': content_type}
for fault in faults:
if isinstance(e, fault):
instance.get_networks_count.assert_called_with(mock.ANY,
filters=mock.ANY)
self.assertIn("Quota exceeded for resources",
- res.json['NeutronError'])
+ res.json['NeutronError']['message'])
def test_create_network_quota_no_counts(self):
cfg.CONF.set_override('quota_network', 1, group='QUOTAS')
instance.get_networks_count.assert_called_with(mock.ANY,
filters=mock.ANY)
self.assertIn("Quota exceeded for resources",
- res.json['NeutronError'])
+ res.json['NeutronError']['message'])
def test_create_network_quota_without_limit(self):
cfg.CONF.set_override('quota_network', -1, group='QUOTAS')
class TestException(q_exc.NeutronException):
message = msg
- expected_res = {'body': {'NeutronError': msg}}
+ expected_res = {'body': {
+ 'NeutronError': {
+ 'type': 'TestException',
+ 'message': msg,
+ 'detail': ''}}}
controller = mock.MagicMock()
controller.test.side_effect = TestException()
class TestException(q_exc.NeutronException):
message = msg
- expected_res = {'body': {'NeutronError': msg}}
+ expected_res = {'body': {
+ 'NeutronError': {
+ 'type': 'TestException',
+ 'message': msg,
+ 'detail': ''}}}
controller = mock.MagicMock()
controller.test.side_effect = TestException()
class TestException(q_exc.NeutronException):
message = msg
- expected_res = {'body': {'NeutronError': msg}}
+ expected_res = {'body': {
+ 'NeutronError': {
+ 'type': 'TestException',
+ 'message': msg,
+ 'detail': ''}}}
controller = mock.MagicMock()
controller.test.side_effect = TestException()
class TestException(q_exc.NeutronException):
message = msg
- expected_res = {'body': {'NeutronError': msg}}
+ expected_res = {'body': {
+ 'NeutronError': {
+ 'type': 'TestException',
+ 'message': msg,
+ 'detail': ''}}}
controller = mock.MagicMock()
controller.test.side_effect = TestException()
res = self._create_port(self.fmt, id)
data = self.deserialize(self.fmt, res)
msg = str(q_exc.IpAddressGenerationFailure(net_id=id))
- self.assertEqual(data['NeutronError'], msg)
+ self.assertEqual(data['NeutronError']['message'], msg)
self.assertEqual(res.status_int, webob.exc.HTTPConflict.code)
def test_update_port_update_ip(self):
data = self.deserialize(self.fmt, res)
self.assertEqual(res.status_int, webob.exc.HTTPConflict.code)
msg = str(q_exc.SubnetInUse(subnet_id=id))
- self.assertEqual(data['NeutronError'], msg)
+ self.assertEqual(data['NeutronError']['message'], msg)
def test_delete_network(self):
gateway_ip = '10.0.0.1'