From 0ea0706f27cd7b9073d32db63df55a3634bd8059 Mon Sep 17 00:00:00 2001 From: "Jorge L. Williams" Date: Sat, 23 Apr 2011 13:13:32 -0500 Subject: Initial version support. --- keystone/content/version.json.tpl | 33 +++++++++++++++++++++++++++++++++ keystone/content/version.xml.tpl | 23 +++++++++++++++++++++++ keystone/identity2.py | 21 +++++++++++++++++++++ test/IdentitySOAPUI.xml | 8 +++++--- 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 keystone/content/version.json.tpl create mode 100644 keystone/content/version.xml.tpl diff --git a/keystone/content/version.json.tpl b/keystone/content/version.json.tpl new file mode 100644 index 00000000..8fe0e2e1 --- /dev/null +++ b/keystone/content/version.json.tpl @@ -0,0 +1,33 @@ +{ + "version" : { + "id" : "v1.0", + "status" : "{{VERSION_STATUS}}", + "updated" : "{{VERSION_DATE}}", + "links": [ + { + "rel" : "self", + "href" : "http://{{HOST}}:{{PORT}}/v1.0/" + }, + { + "rel" : "describedby", + "type" : "application/pdf", + "href" : "http://{{HOST}}:{{PORT}}/v1.0/idmdevguide.pdf" + }, + { + "rel" : "describedby", + "type" : "application/vnd.sun.wadl+xml", + "href" : "http://{{HOST}}:{{PORT}}/v1.0/identity.wadl" + } + ], + "media-types": [ + { + "base" : "application/xml", + "type" : "application/vnd.openstack.idm-v1.0+xml" + }, + { + "base" : "application/json", + "type" : "application/vnd.openstack.idm-v1.0+json" + } + ] + } +} diff --git a/keystone/content/version.xml.tpl b/keystone/content/version.xml.tpl new file mode 100644 index 00000000..a7ee96b9 --- /dev/null +++ b/keystone/content/version.xml.tpl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/keystone/identity2.py b/keystone/identity2.py index 377f4ce9..f755006f 100644 --- a/keystone/identity2.py +++ b/keystone/identity2.py @@ -23,6 +23,7 @@ from bottle import response from bottle import abort from bottle import error from bottle import static_file +from bottle import template import keystone.logic.service as serv import keystone.logic.types.auth as auth @@ -31,6 +32,9 @@ import keystone.logic.types.fault as fault from os import path +VERSION_STATUS = "ALPHA" +VERSION_DATE = "2011-04-23T00:00:00Z" + bottle.debug(True) service = serv.IDMService() @@ -95,6 +99,23 @@ def send_error(error): else: send_result (fault.IDMFault("Unhandled error", error.__str__())) +@route('/v1.0', method='GET') +@route('/v1.0/', method='GET') +def get_version_info(): + try: + if is_xml_response(): + resp_file = "content/version.xml" + response.content_type = "application/xml" + else: + resp_file = "content/version.json" + response.content_type = "application/json" + + hostname = request.environ.get("SERVER_NAME") + port = request.environ.get("SERVER_PORT") + return template (resp_file, HOST=hostname, PORT=port, VERSION_STATUS=VERSION_STATUS, VERSION_DATE=VERSION_DATE) + except Exception as e: + return send_error (e) + @route('/v1.0/token', method='POST') def authenticate(): try: diff --git a/test/IdentitySOAPUI.xml b/test/IdentitySOAPUI.xml index 438a34cf..19bc312e 100644 --- a/test/IdentitySOAPUI.xml +++ b/test/IdentitySOAPUI.xml @@ -1135,7 +1135,7 @@ is a description of my tenant. Thank you very much.</v1:description></v1:tenant>application/xml200 203v1:versionapplication/json200 203application/xml400v1:badRequestapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json400 -500 503http://localhost:8080SEQUENTIAL<xml-fragment/>http://localhost:8080authfalsefalsetokenfalsefalseuserfalsefalse +500 503<xml-fragment/>http://localhost:8080SEQUENTIAL<xml-fragment/>http://localhost:8080authfalsefalsetokenfalsefalseuserfalsefalse @@ -1348,6 +1348,8 @@ ns1:tenant/@idto_deletefalse<entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/>http://localhost:8080assert(context.response == null) -<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/common/api/v1.0'; +<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/common/api/v1.0'; count(/ns1:extensions)1falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://localhost/v1.0/extensions'; -count(//ns1:extensions)1falsefalse<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse \ No newline at end of file +count(//ns1:extensions)1falsefalse<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/common/api/v1.0'; +count(//ns1:version)1falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://localhost/v1.0'; +count(//ns1:version)1falsefalse \ No newline at end of file -- cgit