makes volume versions display properly

* 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
This commit is contained in:
Vishvananda Ishaya 2012-03-23 20:27:34 +00:00
parent 81ac4e729c
commit aa29a67d5c
2 changed files with 22 additions and 9 deletions

View File

@ -56,15 +56,19 @@ VERSIONS = {
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):

View File

@ -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
@ -60,6 +61,14 @@ class VolumeRouterTestCase(test.TestCase):
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'