Skip to content

Commit

Permalink
makes volume versions display properly
Browse files Browse the repository at this point in the history
 * The compute versions controller changed during a refactor and broke
   the volume versions controller (since we are using it as a base class)
 * Added naive test
 * fixes bug 963357

Change-Id: Ica9c65952b800d316d264db11f89e369e56bcade
  • Loading branch information
vishvananda committed Mar 23, 2012
1 parent 81ac4e7 commit aa29a67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
22 changes: 13 additions & 9 deletions nova/api/openstack/volume/versions.py
Expand Up @@ -56,15 +56,19 @@


class Versions(versions.Versions):
def dispatch(self, request, *args):
"""Respond to a request for all OpenStack API versions."""
builder = views_versions.get_view_builder(request)
if request.path == '/':
# List Versions
return builder.build_versions(VERSIONS)
else:
# Versions Multiple Choice
return builder.build_choices(VERSIONS, request)
@wsgi.serializers(xml=versions.VersionsTemplate,
atom=versions.VersionsAtomSerializer)
def index(self, req):
"""Return all versions."""
builder = views_versions.get_view_builder(req)
return builder.build_versions(VERSIONS)

@wsgi.serializers(xml=versions.ChoicesTemplate)
@wsgi.response(300)
def multi(self, req):
"""Return multiple choices."""
builder = views_versions.get_view_builder(req)
return builder.build_choices(VERSIONS, req)


class VolumeVersionV1(object):
Expand Down
9 changes: 9 additions & 0 deletions nova/tests/api/openstack/volume/test_router.py
Expand Up @@ -17,6 +17,7 @@
from nova.api.openstack import volume
from nova.api.openstack.volume import snapshots
from nova.api.openstack.volume import volumes
from nova.api.openstack.volume import versions
from nova.api.openstack import wsgi
from nova import flags
from nova import log as logging
Expand Down Expand Up @@ -60,6 +61,14 @@ def test_versions(self):
response = req.get_response(self.app)
self.assertEqual(200, response.status_int)

def test_versions_dispatch(self):
req = fakes.HTTPRequest.blank('/')
req.method = 'GET'
req.content_type = 'application/json'
resource = versions.Versions()
result = resource.dispatch(resource.index, req, {})
self.assertTrue(result)

def test_volumes(self):
req = fakes.HTTPRequest.blank('/fake/volumes')
req.method = 'GET'
Expand Down

0 comments on commit aa29a67

Please sign in to comment.