summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-09-20 21:38:38 +0000
committerTarmac <>2010-09-20 21:38:38 +0000
commitd8861d04a85044ae57ffd7eb9ab682879beecf7d (patch)
treea2151052c36ee84e6b7e1b6b0c62e6783dee6753 /nova
parentb9b65e76858f4a154b9e6bd8ff7cb1a715696894 (diff)
parentfc93548e99dea561dbf2f198b0fccc84467dbf8b (diff)
Support querying version list, per the RS API spec. Fixes bug 613117.
Diffstat (limited to 'nova')
-rw-r--r--nova/api/__init__.py13
-rw-r--r--nova/tests/api/__init__.py5
2 files changed, 16 insertions, 2 deletions
diff --git a/nova/api/__init__.py b/nova/api/__init__.py
index b9b9e3988..9f116dada 100644
--- a/nova/api/__init__.py
+++ b/nova/api/__init__.py
@@ -21,6 +21,7 @@ Root WSGI middleware for all API controllers.
"""
import routes
+import webob.dec
from nova import wsgi
from nova.api import ec2
@@ -32,6 +33,18 @@ class API(wsgi.Router):
def __init__(self):
mapper = routes.Mapper()
+ mapper.connect("/", controller=self.versions)
mapper.connect("/v1.0/{path_info:.*}", controller=rackspace.API())
mapper.connect("/ec2/{path_info:.*}", controller=ec2.API())
super(API, self).__init__(mapper)
+
+ @webob.dec.wsgify
+ def versions(self, req):
+ """Respond to a request for all OpenStack API versions."""
+ response = {
+ "versions": [
+ dict(status="CURRENT", id="v1.0")]}
+ metadata = {
+ "application/xml": {
+ "attributes": dict(version=["status", "id"])}}
+ return wsgi.Serializer(req.environ, metadata).to_content_type(response)
diff --git a/nova/tests/api/__init__.py b/nova/tests/api/__init__.py
index 59c4adc3d..4682c094e 100644
--- a/nova/tests/api/__init__.py
+++ b/nova/tests/api/__init__.py
@@ -52,8 +52,9 @@ class Test(unittest.TestCase):
result = webob.Request.blank('/test/cloud').get_response(api.API())
self.assertNotEqual(result.body, "/cloud")
- def test_query_api_version(self):
- pass
+ def test_query_api_versions(self):
+ result = webob.Request.blank('/').get_response(api.API())
+ self.assertTrue('CURRENT' in result.body)
if __name__ == '__main__':
unittest.main()