summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-07-25 15:28:06 -0400
committerWilliam Wolf <throughnothing@gmail.com>2011-07-25 15:28:06 -0400
commit810d4b89cbbfa9388fb61f9069ea0104a7d77752 (patch)
tree421c2782f265d2d40658d1555118396dd5283410 /nova/api
parent99bc14f16bce9f125715fbe436b7fc0969b62420 (diff)
removed prints, got versions detail tests passing, still need to do xml/atom
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py2
-rw-r--r--nova/api/openstack/versions.py96
2 files changed, 84 insertions, 14 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index fb6f5515e..a6a8b4595 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -118,7 +118,7 @@ class APIRouter(base_wsgi.Router):
mapper.connect("versions", "/",
controller=versions.create_resource(version),
- action="index")
+ action="detail")
mapper.resource("console", "consoles",
controller=consoles.create_resource(),
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py
index 445a14372..5655edcfc 100644
--- a/nova/api/openstack/versions.py
+++ b/nova/api/openstack/versions.py
@@ -88,6 +88,7 @@ class Versions(wsgi.Resource):
return dict(versions=versions)
def _versions_multi_choice(self, request):
+ #TODO
version_objs = [
{
"id": "v1.1",
@@ -109,18 +110,87 @@ class Versions(wsgi.Resource):
class VersionV10(object):
- def index(self, req):
- return "test index 1.0"
+ def detail(self, req):
+ #TODO
+ return {
+ "version" : {
+ "id": "v1.0",
+ "status": "CURRENT",
+ "updated": "2011-01-21T11:33:21-06:00",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.0/"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/pdf",
+ "href": "http://docs.rackspacecloud.com/"
+ "servers/api/v1.0/cs-devguide-20110125.pdf"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/vnd.sun.wadl+xml",
+ "href": "http://docs.rackspacecloud.com/"
+ "servers/api/v1.0/application.wadl"
+ },
+ ],
+ "media-types": [
+ {
+ "base" : "application/xml",
+ "type" : "application/vnd.openstack.compute-v1.0+xml"
+ },
+ {
+ "base" : "application/json",
+ "type" : "application/vnd.openstack.compute-v1.0+json"
+ }
+ ],
+ },
+ }
class VersionV11(object):
- def index(self, req):
- return "test index 1.1"
+ def detail(self, req):
+ return {
+ "version" : {
+ "id": "v1.1",
+ "status": "CURRENT",
+ "updated": "2011-01-21T11:33:21-06:00",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/pdf",
+ "href": "http://docs.rackspacecloud.com/"
+ "servers/api/v1.1/cs-devguide-20110125.pdf"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/vnd.sun.wadl+xml",
+ "href": "http://docs.rackspacecloud.com/"
+ "servers/api/v1.1/application.wadl"
+ },
+ ],
+ "media-types": [
+ {
+ "base" : "application/xml",
+ "type" : "application/vnd.openstack.compute-v1.1+xml"
+ },
+ {
+ "base" : "application/json",
+ "type" : "application/vnd.openstack.compute-v1.1+json"
+ }
+ ],
+ },
+ }
+
class VersionsRequestDeserializer(wsgi.RequestDeserializer):
def get_action_args(self, request_environment):
"""Parse dictionary created by routes library."""
-
args = {}
if request_environment['PATH_INFO'] == '/':
args['action'] = 'index'
@@ -129,6 +199,7 @@ class VersionsRequestDeserializer(wsgi.RequestDeserializer):
return args
+
class VersionsXMLSerializer(wsgi.XMLDictSerializer):
def _versions_to_xml(self, versions):
root = self._xml_doc.createElement('versions')
@@ -158,6 +229,9 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer):
return self.to_xml_string(node)
+ def detail(self,data):
+ return "<xml></xml>"
+
def multi(self, data):
self._xml_doc = minidom.Document()
node = self._versions_to_xml(data['versions'])
@@ -167,6 +241,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer):
class VersionsAtomSerializer(wsgi.XMLDictSerializer):
def __init__(self, metadata=None, xmlns=None):
+ self.metadata = metadata or {}
if not xmlns:
self.xmlns = ATOM_XMLNS
else:
@@ -260,14 +335,9 @@ class VersionsAtomSerializer(wsgi.XMLDictSerializer):
return self.to_xml_string(node)
- def multi(self, data):
- self._xml_doc = minidom.Document()
- node = self._xml_doc.createElementNS(self.xmlns, 'feed')
- self._create_meta(node, data['versions'])
- self._create_version_entries(node, data['versions'])
-
- return self.to_xml_string(node)
-
+ def detail(self, data):
+ #TODO
+ pass
def create_resource(version='1.0'):
controller = {