Merge "Revert "Display neutron api error message more precisely""
This commit is contained in:
commit
de32b3345e
@ -70,18 +70,8 @@ def map_exceptions(func):
|
|||||||
url=e.url, method=e.method,
|
url=e.url, method=e.method,
|
||||||
http_status=e.http_status, cause=e)
|
http_status=e.http_status, cause=e)
|
||||||
else:
|
else:
|
||||||
message = e.message
|
|
||||||
details = e.details
|
|
||||||
|
|
||||||
if e.response is not None:
|
|
||||||
body = e.response.json()
|
|
||||||
if 'NeutronError' in body:
|
|
||||||
err_dict = body['NeutronError']
|
|
||||||
message = err_dict.get('message') or message
|
|
||||||
details = err_dict.get('detail') or details
|
|
||||||
|
|
||||||
raise exceptions.HttpException(
|
raise exceptions.HttpException(
|
||||||
message=message, details=details,
|
message=e.message, details=e.details,
|
||||||
response=e.response, request_id=e.request_id,
|
response=e.response, request_id=e.request_id,
|
||||||
url=e.url, method=e.method,
|
url=e.url, method=e.method,
|
||||||
http_status=e.http_status, cause=e)
|
http_status=e.http_status, cause=e)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstack import exceptions
|
|
||||||
from openstack.network.v2 import router
|
from openstack.network.v2 import router
|
||||||
from openstack.tests.functional import base
|
from openstack.tests.functional import base
|
||||||
|
|
||||||
@ -55,20 +54,3 @@ class TestRouter(base.BaseFunctionalTest):
|
|||||||
def test_update(self):
|
def test_update(self):
|
||||||
sot = self.conn.network.update_router(self.ID, name=self.UPDATE_NAME)
|
sot = self.conn.network.update_router(self.ID, name=self.UPDATE_NAME)
|
||||||
self.assertEqual(self.UPDATE_NAME, sot.name)
|
self.assertEqual(self.UPDATE_NAME, sot.name)
|
||||||
|
|
||||||
def test_error(self):
|
|
||||||
destination = "10.10.10.0/24"
|
|
||||||
nexthop = "192.168.0.13"
|
|
||||||
message = "Invalid input for routes. Reason: Invalid data format " \
|
|
||||||
"for hostroute: '{u'destination': u'%s', " \
|
|
||||||
"u'nexthop': u'%s'}'." % (destination, nexthop)
|
|
||||||
|
|
||||||
with self.assertRaises(exceptions.HttpException) as cm:
|
|
||||||
routes = {
|
|
||||||
"destination": destination,
|
|
||||||
"nexthop": nexthop,
|
|
||||||
}
|
|
||||||
|
|
||||||
self.conn.network.update_router(self.ID, routes=routes)
|
|
||||||
|
|
||||||
self.assertEqual(message, cm.exception.message)
|
|
||||||
|
@ -82,28 +82,6 @@ class TestSession(testtools.TestCase):
|
|||||||
self.assertEqual(ksa_exc.http_status, os_exc.http_status)
|
self.assertEqual(ksa_exc.http_status, os_exc.http_status)
|
||||||
self.assertEqual(ksa_exc, os_exc.cause)
|
self.assertEqual(ksa_exc, os_exc.cause)
|
||||||
|
|
||||||
def test_map_exceptions_neutron_exception(self):
|
|
||||||
fake_response = mock.Mock()
|
|
||||||
message = "neutron error message"
|
|
||||||
detail = "neutron detailed message"
|
|
||||||
body = {
|
|
||||||
"NeutronError": {
|
|
||||||
"message": message,
|
|
||||||
"detail": detail,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fake_response.json = mock.Mock(return_value=body)
|
|
||||||
|
|
||||||
ksa_exc = _exceptions.HttpError(response=fake_response)
|
|
||||||
func = mock.Mock(side_effect=ksa_exc)
|
|
||||||
|
|
||||||
os_exc = self.assertRaises(
|
|
||||||
exceptions.HttpException, session.map_exceptions(func))
|
|
||||||
|
|
||||||
self.assertEqual(message, os_exc.message)
|
|
||||||
self.assertEqual(detail, os_exc.details)
|
|
||||||
|
|
||||||
def test_map_exceptions_sdk_exception_1(self):
|
def test_map_exceptions_sdk_exception_1(self):
|
||||||
ksa_exc = _exceptions.ClientException()
|
ksa_exc = _exceptions.ClientException()
|
||||||
func = mock.Mock(side_effect=ksa_exc)
|
func = mock.Mock(side_effect=ksa_exc)
|
||||||
|
Loading…
Reference in New Issue
Block a user