For the same action, cinderclient will raise a different exception depending on how the cinderclient object was created.
Example that shows this behaviour:
http://paste.openstack.org/show/176913/
Expected exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/v1/volumes.py", line 187, in create
return self._create('/volumes', body, 'volume')
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/base.py", line 157, in _create
resp, body = self.api.client.post(url, body=body)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 305, in post
return self._cs_request(url, 'POST', **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 269, in _cs_request
**kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 252, in request
raise exceptions.from_response(resp, body)
cinderclient.exceptions.BadRequest: Invalid input received: Volume size 0 must be an integer and greater than 0 (HTTP 400) (Request-ID: req-a60d45b2-3b8f-4e45-8a79-7b3157c0c973)
Exception when using a keystone session:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/v1/volumes.py", line 187, in create
return self._create('/volumes', body, 'volume')
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/base.py", line 157, in _create
resp, body = self.api.client.post(url, body=body)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 91, in post
return self._cs_request(url, 'POST', **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 85, in _cs_request
return self.request(url, method, **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/cinderclient/client.py", line 80, in request
return super(SessionClient, self).request(*args, **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/keystoneclient/adapter.py", line 158, in request
resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/keystoneclient/adapter.py", line 88, in request
return self.session.request(url, method, **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/keystoneclient/utils.py", line 318, in inner
return func(*args, **kwargs)
File "/home/sergio/code/env/local/lib/python2.7/site-packages/keystoneclient/session.py", line 354, in request
raise exceptions.from_response(resp, method, url)
keystoneclient.openstack.common.apiclient.exceptions.BadRequest: Bad Request (HTTP 400) (Request-ID: req-86c3e79d-ad38-43d8-a6fb-99a709d2b04d)
The second exception (keystoneclient.openstack.common.apiclient.exceptions.BadRequest) is an instance of keystoneclient.exceptions.BadRequest, which seems to me like that should only be exceptions coming from keystoneclient.
Related issue: https:/ /bugs.launchpad .net/python- cinderclient/ +bug/1412583
Possibly the fix for it will also fix this issue.