NotFound neutron errors should have a unique base class
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Expired
|
Undecided
|
Unassigned | ||
python-neutronclient |
Invalid
|
Undecided
|
Unassigned | ||
tempest |
Expired
|
Wishlist
|
Unassigned |
Bug Description
Most of the sever side exception are caught by the client and re-thrown as the general NeutronError. original message and type are still found in the message.
404-{u'
this makes it impossible to catch unique error types such as NotFound.
for instance: in tempest (tempest/
try:
# OpenStack resources are assumed to have a delete()
# method which destroys the resource...
except Exception as e:
# If the resource is already missing, mission accomplished.
if e.__class_
this code should catch and dismiss all not found resources, however, since neutronClient doesn't have a unique NotFound type, it fails to catch here.
Changed in tempest: | |
status: | New → Incomplete |
Changed in tempest: | |
importance: | Undecided → Low |
importance: | Low → Wishlist |
Changed in python-neutronclient: | |
status: | Incomplete → Invalid |
>>> neutron = client. Client( '2.0', endpoint_ url=OS_ URL, token=OS_TOKEN) delete_ security_ group_rule( '122') ception as e: ient.client: 172.16. 108.1:9696/ /v2.0/security- group-rules/ 122.json -X DELETE -H "X-Auth-Token: 71f1495de04c459 f920de6f23cecc0 51" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python- neutronclient"
>>> try:
... neutron.
... except NeutronClientEx
... print e.status_code
...
DEBUG:neutroncl
REQ: curl -i http://
DEBUG:neutroncl ient.client: RESP:{' date': 'Mon, 09 Dec 2013 03:14:55 GMT', 'status': '404', 'content-length': '122', 'content-type': 'application/json; charset=UTF-8'} {"NeutronError": {"message": "Security group rule 122 does not exist", "type": "SecurityGroupR uleNotFound" , "detail": ""}}
DEBUG:neutroncl ient.v2_ 0.client: Error message: {"NeutronError": {"message": "Security group rule 122 does not exist", "type": "SecurityGroupR uleNotFound" , "detail": ""}}
404
you can catch e.status_code==404 error consistently.