Ziads changes and fixes for them.

Change-Id: I86f3dc08ffb602c74491821d37adab0088fe3948

PEP8

Change-Id: Ia4db15cbcf6bdcd8e5537943d94b371c7260a9dc
This commit is contained in:
Yogeshwar Srikrishnan 2011-08-14 02:30:06 -05:00 committed by Ziad Sawalha
parent a9d5441ac8
commit dd346967e1
15 changed files with 1889 additions and 1337 deletions

View File

@ -0,0 +1,56 @@
<!--
A collection of common faults, these are pretty much expected
in every request.
-->
<!ENTITY commonFaults
'
<response xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:identityFault"/>
<representation mediaType="application/json"/>
</response>
<response status="503" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:serviceUnavailable"/>
<representation mediaType="applicaiton/json"/>
</response>
<response status="401" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:unauthorized"/>
<representation mediaType="applicaiton/json"/>
</response>
<response status="403" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:forbidden"/>
<representation mediaType="applicaiton/json"/>
</response>
<response status="400" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:badRequest"/>
<representation mediaType="applicaiton/json"/>
</response>
<response status="405" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:badMethod"/>
<representation mediaType="applicaiton/json"/>
</response>
<response status="413" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:overLimit"/>
<representation mediaType="applicaiton/json"/>
</response>
'>
<!--
Faults on GET
-->
<!ENTITY getFaults
'
<response status="404" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:itemNotFound"/>
<representation mediaType="applicaiton/json"/>
</response>
'>
<!--
Faults on POST/PUT
-->
<!ENTITY postPutFaults
'
<response status="415" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="identity:badMediaType"/>
<representation mediaType="applicaiton/json"/>
</response>
'>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -4,34 +4,44 @@
"id":"asdasdasd-adsasdads-asdasdasd-adsadsasd",
"expires":"2010-11-01T03:32:15-05:00"
},
"serviceCatalog":{
"service1":[
{
"region":"DFW",
"publicURL":"https://service1-public/v1/blah-blah",
"internalURL":"https://service1-internal/v1/blah-blah"
},
{
"region":"ORD",
"publicURL":"https://service1-public-ord/v1/blah-blah",
"internalURL":"https://service1-internal-ord/v1/blah-blah"
}
],
"service2":[
{
"region":"DFW",
"publicURL":"https://service2-public-dfw/v1/blah-blah"
},
{
"region":"ORD",
"publicURL":"https://service2-public-orf/v1/blah-blah"
}
],
"service3":[
{
"publicURL":"https://service3-public/v1/blah-blah"
}
]
"serviceCatalog": [{
"name": "Cloud Servers",
"type": "compute",
"endpoints": [{
"publicURL": "https://compute.north.host/v1/blah-blah",
"internalURL": "https://compute.north.host/v1/blah-blah",
"region": "North",
"versionId": "1.0",
"versionInfo": "uri",
"versionList": "uri"
}, {
"publicURL": "https://compute.north.host/v1.1/blah-blah",
"internalURL": "https://compute.north.host/v1.1/blah-blah",
"region": "North",
"versionId": "1.1",
"versionInfo": "https://compute.north.host/v1.1/",
"versionList": "https://compute.north.host/"
}]
}, {
"name": "Cloud Files",
"type": "object store",
"endpoints": [{
"publicURL": "https://compute.north.host/v1/blah-blah",
"internalURL": "https://compute.north.host/v1/blah-blah",
"region": "South",
"versionId": "1.0",
"versionInfo": "uri",
"versionList": "uri"
}, {
"publicURL": "https://compute.north.host/v1.1/blah-blah",
"internalURL": "https://compute.north.host/v1.1/blah-blah",
"region": "South",
"versionId": "1.1",
"versionInfo": "https://compute.north.host/v1.1/",
"versionList": "https://compute.north.host/"
}],
"endpoint_links": [{"rel": "next", "href": "https://identity.north.host/v2.0/endpoints?marker=2"}]
}],
"serviceCatalog_links": [{"rel": "next", "href": "uri"}]
}
}
}

View File

@ -3,27 +3,54 @@
<token expires="2010-11-01T03:32:15-05:00"
id="ab48a9efdfedb23ty3494"/>
<serviceCatalog>
<service name="service1">
<service type="compute" name="Computers in the Cloud">
<endpoint
region="DFW"
publicURL="https://service1.public.com/v2.0/blah-blah"
internalURL="https://service1.internal.com/v2.0/blah-blah"/>
region="North"
publicURL="https://north.compute.public.com/v2.0/account1"
internalURL="https://north.compute.internal.com/v2.0/account1">
<version
id="2.0"
info="https://north.compute.public.com/v2.0/"
list="https://north.compute.public.com/" />
</endpoint>
<endpoint
region="ORD"
publicURL="https://service1.public.com/v2.0/blah-blah"
internalURL="https://service1.internal.com/v2.0/blah-blah"/>
region="South"
publicURL="https://south.compute.public.com/v2.0/account1"
internalURL="https://south.compute.internal.com/v2.0/account1">
<version
id="2.0"
info="https://south.compute.public.com/v2.0/"
list="https://south.compute.public.com/" />
</endpoint>
</service>
<service name="service2">
<service type="object-store" name="HTTP Object Store">
<endpoint
region="DFW"
publicURL="https://service2.public.com/v2.0/blah-blah"/>
region="North"
publicURL="https://north.object-store.public.com/v1/account1"
internalURL="https://north.object-store.internal.com/v1/account1">
<version
id="1"
info="https://north.object-store.public.com/v1/"
list="https://north.object-store.public.com/" />
</endpoint>
<endpoint
region="ORD"
publicURL="https://service2.public.com/v2.0/blah-blah"/>
region="South"
publicURL="https://south.object-store.public.com/v2.0/account1"
internalURL="https://south.object-store.internal.com/v2.0/account1">
<version
id="2.0"
info="https://south.object-store.public.com/v1/"
list="https://south.object-store.public.com/" />
</endpoint>
</service>
<service name="service3">
<service type="dns" name="DNS-as-a-Service">
<endpoint
publicURL="https://service3.public.com/v2.0/blah-blah"/>
publicURL="https://dns.public.com/v2.0/blah-blah">
<version
id="2.0"
info="https://dns.public.com/v2.0/"
list="https://dns.public.com/" />
</endpoint>
</service>
</serviceCatalog>
</auth>

View File

@ -0,0 +1,33 @@
{
"version" : {
"id" : "v2.0",
"status" : "{{VERSION_STATUS}}",
"updated" : "{{VERSION_DATE}}",
"links": [
{
"rel" : "self",
"href" : "http://{{HOST}}:{{PORT}}/v2.0/"
},
{
"rel" : "describedby",
"type" : "application/pdf",
"href" : "http://{{HOST}}:{{PORT}}/v2.0/identityadminguide.pdf"
},
{
"rel" : "describedby",
"type" : "application/vnd.sun.wadl+xml",
"href" : "http://{{HOST}}:{{PORT}}/v2.0/identity-admin.wadl"
}
],
"media-types": [
{
"base" : "application/xml",
"type" : "application/vnd.openstack.identity-v2.0+xml"
},
{
"base" : "application/json",
"type" : "application/vnd.openstack.identity-v2.0+json"
}
]
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<version xmlns="http://docs.openstack.org/common/api/v2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
id="v2.0" status="{{VERSION_STATUS}}" updated="{{VERSION_DATE}}">
<media-types>
<media-type base="application/xml"
type="application/vnd.openstack.identity-v2.0+xml"/>
<media-type base="application/json"
type="application/vnd.openstack.identity-v2.0+json"/>
</media-types>
<atom:link rel="self"
href="http://{{HOST}}:{{PORT}}/v2.0/"/>
<atom:link rel="describedby"
type="application/pdf"
href="http://{{HOST}}:{{PORT}}/v2.0/identitydevguide.pdf" />
<atom:link rel="describedby"
type="application/vnd.sun.wadl+xml"
href="http://{{HOST}}:{{PORT}}/v2.0/identity-admin.wadl" />
</version>

View File

@ -18,25 +18,25 @@
<!-- Elements -->
<element name="services" type="identity:ServiceList">
<annotation>
<documentation
<xsd:documentation
xml:lang="EN"
xmlns="http://www.w3.org/1999/xhtml">
<p>
A list of services.
</p>
</documentation>
</xsd:documentation>
</annotation>
</element>
<element name="service" type="identity:Service" >
<annotation>
<documentation
<xsd:documentation
xml:lang="EN"
xmlns="http://www.w3.org/1999/xhtml">
<p>
A service.
</p>
</documentation>
</xsd:documentation>
</annotation>
</element>

View File

@ -7,6 +7,7 @@
xmlns:identity="http://docs.openstack.org/identity/api/v2.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
xmlns:xsdxt="http://docs.rackspacecloud.com/xsd-ext/v1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
targetNamespace="http://docs.openstack.org/identity/api/v2.0"
>
@ -17,13 +18,13 @@
<!-- Elements -->
<element name="tenant" type="identity:Tenant">
<annotation>
<documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml">
<xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml">
<p>
A container used to group or isolate resources and/or identity
objects. Depending on the service operator, a tenant may map to a customer,
account, organization, or project.
</p>
</documentation>
</xsd:documentation>
<xsd:appinfo>
<xsdxt:samples>
         <xsdxt:sample>
@ -51,7 +52,7 @@
<!-- Complex Types -->
<complexType name="Tenants">
<sequence>
<element name="tenant" type="identity:Tenant" maxOccurs="1000"/>
<element name="tenant" type="identity:Tenant" maxOccurs="100"/>
<element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded" />
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</sequence>

View File

@ -28,15 +28,15 @@ class StaticFilesController(wsgi.Controller):
self.options = options
@utils.wrap_error
def get_pdf_contract(self, req):
def get_pdf_contract(self, req, pdf):
resp = Response()
return template.static_file(resp, req, "content/identitydevguide.pdf",
return template.static_file(resp, req, "content/" + pdf,
root=utils.get_app_root(), mimetype="application/pdf")
@utils.wrap_error
def get_wadl_contract(self, req):
def get_wadl_contract(self, req, wadl):
resp = Response()
return template.static_file(resp, req, "content/identity.wadl",
return template.static_file(resp, req, "content/" + wadl,
root=utils.get_app_root(), mimetype="application/vnd.sun.wadl+xml")
@utils.wrap_error

View File

@ -20,17 +20,16 @@ class VersionController(wsgi.Controller):
self.options = options
@utils.wrap_error
def get_version_info(self, req):
def get_version_info(self, req, file="version"):
resp = Response()
resp.charset = 'UTF-8'
if utils.is_xml_response(req):
resp_file = os.path.join(possible_topdir,
"keystone/content/version.xml.tpl")
"keystone/content/%s.xml.tpl" % file)
resp.content_type = "application/xml"
else:
resp_file = os.path.join(possible_topdir,
"keystone/content/version.json.tpl")
"keystone/content/%s.json.tpl" % file)
resp.content_type = "application/json"
hostname = req.environ.get("SERVER_NAME")

View File

@ -159,18 +159,22 @@ class AdminApi(wsgi.Router):
# Miscellaneous Operations
version_controller = VersionController(options)
mapper.connect("/", controller=version_controller,
action="get_version_info",
action="get_version_info", file="version-admin",
conditions=dict(method=["GET"]))
# Static Files Controller
static_files_controller = StaticFilesController(options)
mapper.connect("/identitydevguide.pdf",
mapper.connect("/identityadminguide.pdf",
controller=static_files_controller,
action="get_pdf_contract",
action="get_pdf_contract", pdf="identityadminguide.pdf",
conditions=dict(method=["GET"]))
mapper.connect("/identity.wadl",
mapper.connect("/identity-admin.wadl",
controller=static_files_controller,
action="get_wadl_contract",
action="get_wadl_contract", wadl="identity-admin.wadl",
conditions=dict(method=["GET"]))
mapper.connect("/common.ent",
controller=static_files_controller,
action="get_wadl_contract", wadl="common.ent",
conditions=dict(method=["GET"]))
mapper.connect("/xsd/{xsd}",
controller=static_files_controller,
@ -183,15 +187,20 @@ class AdminApi(wsgi.Router):
# Services Controller
services_controller = ServicesController(options)
mapper.connect("/services", controller=services_controller,
action="get_services", conditions=dict(method=["GET"]))
mapper.connect("/services", controller=services_controller,
action="create_service", conditions=dict(method=["POST"]))
mapper.connect("/services/{service_id}", \
controller=services_controller,
action="delete_service", conditions=dict(method=["DELETE"]))
mapper.connect("/services",
controller=services_controller,
action="get_services",
conditions=dict(method=["GET"]))
mapper.connect("/services",
controller=services_controller,
action="create_service",
conditions=dict(method=["POST"]))
mapper.connect("/services/{service_id}",
controller=services_controller,
action="get_service",
conditions=dict(method=["GET"]))
controller=services_controller,
action="delete_service",
conditions=dict(method=["DELETE"]))
mapper.connect("/services/{service_id}",
controller=services_controller,
action="get_service",
conditions=dict(method=["GET"]))
super(AdminApi, self).__init__(mapper)

View File

@ -42,35 +42,40 @@ class ServiceApi(wsgi.Router):
mapper.connect("/ec2tokens", controller=auth_controller,
action="authenticate_ec2",
conditions=dict(method=["POST"]))
# Tenant Operations
tenant_controller = TenantController(options)
mapper.connect("/tenants", controller=tenant_controller,
action="get_tenants", conditions=dict(method=["GET"]))
mapper.connect("/tenants",
controller=tenant_controller,
action="get_tenants",
conditions=dict(method=["GET"]))
# Miscellaneous Operations
version_controller = VersionController(options)
mapper.connect("/", controller=version_controller,
action="get_version_info",
conditions=dict(method=["GET"]))
mapper.connect("/",
controller=version_controller,
action="get_version_info",
conditions=dict(method=["GET"]))
# Static Files Controller
static_files_controller = StaticFilesController(options)
mapper.connect("/identitydevguide.pdf",
controller=static_files_controller,
action="get_pdf_contract",
conditions=dict(method=["GET"]))
controller=static_files_controller,
action="get_pdf_contract", pdf="identitydevguide.pdf",
conditions=dict(method=["GET"]))
mapper.connect("/identity.wadl",
controller=static_files_controller,
action="get_wadl_contract", wadl="identity.wadl",
conditions=dict(method=["GET"]))
mapper.connect("/common.ent",
controller=static_files_controller,
action="get_wadl_contract",
action="get_wadl_contract", wadl="common.ent",
conditions=dict(method=["GET"]))
mapper.connect("/xsd/{xsd}",
controller=static_files_controller,
action="get_xsd_contract",
conditions=dict(method=["GET"]))
controller=static_files_controller,
action="get_xsd_contract",
conditions=dict(method=["GET"]))
mapper.connect("/xsd/atom/{xsd}",
controller=static_files_controller,
action="get_xsd_atom_contract",
conditions=dict(method=["GET"]))
controller=static_files_controller,
action="get_xsd_atom_contract",
conditions=dict(method=["GET"]))
super(ServiceApi, self).__init__(mapper)

View File

@ -4,11 +4,29 @@ from common import KeystoneTestCase
class TestStaticFiles(KeystoneTestCase):
def test_pdf_contract(self):
r = self.admin_request(path='/identitydevguide.pdf')
r = self.service_request(path='/identitydevguide.pdf')
self.assertTrue('pdf' in r.getheader('Content-Type'))
def test_wadl_contract(self):
r = self.admin_request(path='/identity.wadl')
r = self.service_request(path='/identity.wadl')
self.assertTrue('xml' in r.getheader('Content-Type'))
def test_xsd_contract(self):
r = self.service_request(path='/xsd/api.xsd')
self.assertTrue('xml' in r.getheader('Content-Type'))
def test_xsd_atom_contract(self):
r = self.service_request(path='/xsd/atom/atom.xsd')
self.assertTrue('xml' in r.getheader('Content-Type'))
class TestAdminStaticFiles(KeystoneTestCase):
def test_pdf_contract(self):
r = self.admin_request(path='/identityadminguide.pdf')
self.assertTrue('pdf' in r.getheader('Content-Type'))
def test_wadl_contract(self):
r = self.admin_request(path='/identity-admin.wadl')
self.assertTrue('xml' in r.getheader('Content-Type'))
def test_xsd_contract(self):
@ -19,6 +37,5 @@ class TestStaticFiles(KeystoneTestCase):
r = self.admin_request(path='/xsd/atom/atom.xsd')
self.assertTrue('xml' in r.getheader('Content-Type'))
if __name__ == '__main__':
unittest.main()