volumes python api calls route incorrectly

Bug #1431154 reported by melanie witt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
High
melanie witt

Bug Description

The following code calling volumes.list(), for example, fails with a 404 error:

>>> from novaclient import client
>>> c = client.Client(2, "admin", 'a', 'admin', auth_url='http://localhost:5000/v2.0')
>>> c.servers.list()
[<Server: hi>]
>>> c.volumes.list()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/volumes.py", line 97, in list
    return self._list("/volumes/detail%s" % query_string, "volumes")
  File "/usr/local/lib/python2.7/dist-packages/novaclient/base.py", line 64, in _list
    _resp, body = self.api.client.get(url)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 440, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 418, in _cs_request
    resp, body = self._time_request(url, method, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 392, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 386, in request
    raise exceptions.from_response(resp, body, url, method)
novaclient.exceptions.NotFound: Not found (HTTP 404) (Request-ID: req-9bf24a56-ba43-4ba6-bf54-f5d77dffa4e9)

because the code in v2/volumes.py is erroneously calling /volumes instead of /os-volumes to call the nova volumes proxy api.

The cli works (e.g. 'nova volume-list') because the cli has logic in it to call cinder directly instead of calling the nova volumes proxy api.

Revision history for this message
melanie witt (melwitt) wrote :

I'm going to try to fix this by moving logic the cli does to call directly to cinder, to the volumes python api.

Changed in python-novaclient:
assignee: nobody → melanie witt (melwitt)
Revision history for this message
melanie witt (melwitt) wrote :

The cli function do_volume_list is decorated to set service_type = 'volume', which will route to the cinder endpoint. The code in the VolumeManager simply tacks on '/volumes/...' to the endpoint, which works fine for the cinder endpoint, but not the nova endpoint. Nova endpoint would need '/os-volumes/...'

Things work fine if you specify service_type='volume' when you instantiate a client object:

>>> c = client.Client(2, 'demo', 'a', 'demo', auth_url='http://localhost:5000/v2.0', service_type='volume')
>>> c.volumes.list()
[]

summary: - volumes python api calls are broken
+ volumes python api calls route incorrectly
Revision history for this message
melanie witt (melwitt) wrote :

Downgrading to High as there is a workaround.

Changed in python-novaclient:
importance: Critical → High
Revision history for this message
melanie witt (melwitt) wrote :

Note that with the workaround, you must use two client objects if you wish to work with both the nova endpoint and the volumes endpoint at the same time.

With:

c = client.Client(2, 'demo', 'a', 'demo', auth_url='http://localhost:5000/v2.0', service_type='volume')

calls like c.servers.list() will not work because they will be sent to the volume service (e.g. cinder) endpoint.

With:

c = client.Client(2, 'demo', 'a', 'demo', auth_url='http://localhost:5000/v2.0')

calls like c.volumes.list() will not work because they will be sent to the compute service (nova) endpoint.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/164321

Changed in python-novaclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/164321
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=e0f5072907a00d48a183dd8fc91a6cf6038ca279
Submitter: Jenkins
Branch: master

commit e0f5072907a00d48a183dd8fc91a6cf6038ca279
Author: melanie witt <email address hidden>
Date: Sat Mar 14 23:39:05 2015 +0000

    Ensure the use of volume endpoint in volumes apis

    Currently, several of the volumes apis depend on callers to pass
    service_type='volume' as a parameter when creating a client object,
    to route correctly. The problem is, it makes it impossible for
    callers to work with both the compute and volume endpoints at the
    same time. They can either work with compute and have volumes.* calls
    return 404, or they can work with volume and have servers.* images.*
    flavors.* calls return 404.

    The CLI sets service_type='volume' for client objects for the
    following commands via a decorator:

    volume-list
    volume-show
    volume-create
    volume-delete
    volume-snapshot-list
    volume-snapshot-show
    volume-snapshot-create
    volume-snapshot-delete
    volume-type-list
    volume-type-create
    volume-type-delete

    With this change, the service_type 'volume' is set in the api,
    so the decorators on the shell commands are no longer needed.

    Closes-Bug: #1431154

    Change-Id: I11b48ac14fa4c64d8aae528552ec5b363be384c5

Changed in python-novaclient:
status: In Progress → Fix Committed
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.23.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.