Skip to content

Commit ebe322d

Browse files
committed
Revert "Display neutron api error message more precisely"
This reverts commit 23f4aa8. This patch is problematic, it is breaking cases that are not Neutron related. The problem is that when there are HttpError thrown, we cannot guarantee that the body contains a valid JSON, the .response.json line is wrong. Need to rework it. Change-Id: Ie513c0869bb253680dfe3a08b1c5f09c2d4783a5
1 parent 23f4aa8 commit ebe322d

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

openstack/session.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,8 @@ def map_exceptions_wrapper(*args, **kwargs):
7070
url=e.url, method=e.method,
7171
http_status=e.http_status, cause=e)
7272
else:
73-
message = e.message
74-
details = e.details
75-
76-
if e.response is not None:
77-
body = e.response.json()
78-
if 'NeutronError' in body:
79-
err_dict = body['NeutronError']
80-
message = err_dict.get('message') or message
81-
details = err_dict.get('detail') or details
82-
8373
raise exceptions.HttpException(
84-
message=message, details=details,
74+
message=e.message, details=e.details,
8575
response=e.response, request_id=e.request_id,
8676
url=e.url, method=e.method,
8777
http_status=e.http_status, cause=e)

openstack/tests/functional/network/v2/test_router.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import uuid
1414

15-
from openstack import exceptions
1615
from openstack.network.v2 import router
1716
from openstack.tests.functional import base
1817

@@ -55,20 +54,3 @@ def test_list(self):
5554
def test_update(self):
5655
sot = self.conn.network.update_router(self.ID, name=self.UPDATE_NAME)
5756
self.assertEqual(self.UPDATE_NAME, sot.name)
58-
59-
def test_error(self):
60-
destination = "10.10.10.0/24"
61-
nexthop = "192.168.0.13"
62-
message = "Invalid input for routes. Reason: Invalid data format " \
63-
"for hostroute: '{u'destination': u'%s', " \
64-
"u'nexthop': u'%s'}'." % (destination, nexthop)
65-
66-
with self.assertRaises(exceptions.HttpException) as cm:
67-
routes = {
68-
"destination": destination,
69-
"nexthop": nexthop,
70-
}
71-
72-
self.conn.network.update_router(self.ID, routes=routes)
73-
74-
self.assertEqual(message, cm.exception.message)

openstack/tests/unit/test_session.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,6 @@ def test_map_exceptions_http_exception(self):
8282
self.assertEqual(ksa_exc.http_status, os_exc.http_status)
8383
self.assertEqual(ksa_exc, os_exc.cause)
8484

85-
def test_map_exceptions_neutron_exception(self):
86-
fake_response = mock.Mock()
87-
message = "neutron error message"
88-
detail = "neutron detailed message"
89-
body = {
90-
"NeutronError": {
91-
"message": message,
92-
"detail": detail,
93-
}
94-
}
95-
96-
fake_response.json = mock.Mock(return_value=body)
97-
98-
ksa_exc = _exceptions.HttpError(response=fake_response)
99-
func = mock.Mock(side_effect=ksa_exc)
100-
101-
os_exc = self.assertRaises(
102-
exceptions.HttpException, session.map_exceptions(func))
103-
104-
self.assertEqual(message, os_exc.message)
105-
self.assertEqual(detail, os_exc.details)
106-
10785
def test_map_exceptions_sdk_exception_1(self):
10886
ksa_exc = _exceptions.ClientException()
10987
func = mock.Mock(side_effect=ksa_exc)

0 commit comments

Comments
 (0)