diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-03-23 20:27:34 +0000 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-03-23 21:53:27 +0000 |
| commit | aa29a67d5cecfa320f98fa9989bf0b9179240016 (patch) | |
| tree | 645a95015d32f18baa794c3748c66335a8c6218a | |
| parent | 81ac4e729c0ca9e8fdb8064db30ae05eb8ce74a7 (diff) | |
| download | nova-aa29a67d5cecfa320f98fa9989bf0b9179240016.tar.gz nova-aa29a67d5cecfa320f98fa9989bf0b9179240016.tar.xz nova-aa29a67d5cecfa320f98fa9989bf0b9179240016.zip | |
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
| -rw-r--r-- | nova/api/openstack/volume/versions.py | 22 | ||||
| -rw-r--r-- | nova/tests/api/openstack/volume/test_router.py | 9 |
2 files changed, 22 insertions, 9 deletions
diff --git a/nova/api/openstack/volume/versions.py b/nova/api/openstack/volume/versions.py index f1c39a59c..68d34b1f9 100644 --- a/nova/api/openstack/volume/versions.py +++ b/nova/api/openstack/volume/versions.py @@ -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): diff --git a/nova/tests/api/openstack/volume/test_router.py b/nova/tests/api/openstack/volume/test_router.py index 1f37ab7a1..8d6cf1e78 100644 --- a/nova/tests/api/openstack/volume/test_router.py +++ b/nova/tests/api/openstack/volume/test_router.py @@ -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' |
