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.
For the same action, cinderclient will raise a different exception depending on how the cinderclient object was created.
Example that shows this behaviour:
from keystoneclient. auth.identity import v2 session import Session
from keystoneclient.
from cinderclient.v1 import client as cinder_client
username = "admin" 127.0.0. 1:5000/ v2.0/"
password = "password"
project_name = "admin"
auth_url = "http://
cinder = cinder_ client. Client( username, password, project_name, auth_url) volumes. create( 0) # raises cinderclient. exceptions. BadRequest
cinder.
auth = v2.Password( auth_url= auth_url, username=username, password=password, tenant_ name=project_ name) client. Client( session= session) volumes. create( 0) # raises keystoneclient. openstack. common. apiclient. exceptions. BadRequest
session = Session(auth=auth)
cinder = cinder_
cinder.
Expected exception: sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ v1/volumes. py", line 187, in create '/volumes' , body, 'volume') sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ base.py" , line 157, in _create client. post(url, body=body) sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 305, in post request( url, 'POST', **kwargs) sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 269, in _cs_request sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 252, in request from_response( resp, body) 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-7b3157c0c9 73)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/
return self._create(
File "/home/
resp, body = self.api.
File "/home/
return self._cs_
File "/home/
**kwargs)
File "/home/
raise exceptions.
cinderclient.
Exception when using a keystone session: sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ v1/volumes. py", line 187, in create '/volumes' , body, 'volume') sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ base.py" , line 157, in _create client. post(url, body=body) sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 91, in post request( url, 'POST', **kwargs) sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 85, in _cs_request sergio/ code/env/ local/lib/ python2. 7/site- packages/ cinderclient/ client. py", line 80, in request ient, self).request( *args, **kwargs) sergio/ code/env/ local/lib/ python2. 7/site- packages/ keystoneclient/ adapter. py", line 158, in request nAdapter, self).request( *args, **kwargs) sergio/ code/env/ local/lib/ python2. 7/site- packages/ keystoneclient/ adapter. py", line 88, in request request( url, method, **kwargs) sergio/ code/env/ local/lib/ python2. 7/site- packages/ keystoneclient/ utils.py" , line 318, in inner sergio/ code/env/ local/lib/ python2. 7/site- packages/ keystoneclient/ session. py", line 354, in request from_response( resp, method, url) openstack. common. apiclient. exceptions. BadRequest: Bad Request (HTTP 400) (Request-ID: req-86c3e79d- ad38-43d8- a6fb-99a709d2b0 4d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/
return self._create(
File "/home/
resp, body = self.api.
File "/home/
return self._cs_
File "/home/
return self.request(url, method, **kwargs)
File "/home/
return super(SessionCl
File "/home/
resp = super(LegacyJso
File "/home/
return self.session.
File "/home/
return func(*args, **kwargs)
File "/home/
raise exceptions.
keystoneclient.
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.