From dc22758ba8869a1fd8e50447d29227d04141ecbb Mon Sep 17 00:00:00 2001 From: "Jorge L. Williams" Date: Sat, 23 Apr 2011 08:33:14 -0500 Subject: Initial delete tenant. --- keystone/identity2.py | 7 +++++++ keystone/logic/service.py | 9 ++++++++- test/IdentitySOAPUI.xml | 22 ++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/keystone/identity2.py b/keystone/identity2.py index 3d811eef..60f19820 100644 --- a/keystone/identity2.py +++ b/keystone/identity2.py @@ -142,4 +142,11 @@ def get_tenant(tenant_id): except Exception as e: return send_error (e) +@route('/v1.0/tenants/:tenant_id', method='DELETE') +def delete_tenant(tenant_id): + try: + return send_result(service.delete_tenant(get_auth_token(), tenant_id), 204) + except Exception as e: + return send_error (e) + run(host='localhost', port=8080) diff --git a/keystone/logic/service.py b/keystone/logic/service.py index b95a08a3..6dae57a8 100644 --- a/keystone/logic/service.py +++ b/keystone/logic/service.py @@ -135,7 +135,14 @@ class IDMService(object): True def delete_tenant(self, admin_token, tenant_id): - True + self.__validate_token(admin_token) + + dtenant = db_api.tenant_get(tenant_id) + if dtenant == None: + raise fault.ItemNotFoundFault("The tenant cloud not be found") + + db_api.tenant_delete(dtenant.id) + return None # # Private Operations diff --git a/test/IdentitySOAPUI.xml b/test/IdentitySOAPUI.xml index ee22aabe..7fddabab 100644 --- a/test/IdentitySOAPUI.xml +++ b/test/IdentitySOAPUI.xml @@ -1114,7 +1114,10 @@ xmlns="http://docs.openstack.org/idm/api/v1.0"/> application/xmlv1:tenantapplication/jsonapplication/xml200v1:tenantapplication/json200application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml404v1:itemNotFoundapplication/xml400v1:badRequestapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json401 403 404 400 500 503http://localhost:8080application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml400v1:badRequestapplication/xml404v1:itemNotFoundapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json400 -401 403 404 500 503http://localhost:8080markerQUERYxs:stringlimitQUERYxs:intapplication/xml200 +401 403 404 500 503<entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/>http://localhost:8080 + + +markerQUERYxs:stringlimitQUERYxs:intapplication/xml200 203v1:tenantsapplication/json200 203application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml400v1:badRequestapplication/xml404v1:itemNotFoundapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json400 401 403 404 500 503<xml-fragment/>http://localhost:8080application/xmlv1:tenantapplication/jsonapplication/xml201v1:tenantapplication/json201application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml @@ -1256,7 +1259,7 @@ ns1:Response/ns1:tenant/ns1:id = "JGroup65" and ns1:Response/ns1:tenant/ns1:desc } }400falsefalsebadRequestfalsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; count(//ns1:tenant)8falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://localhost/v1.0/tenants'; -count(//ns1:e)8falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +count(//ns1:e)8falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; ns1:tenant/@id1234falsefalsedeclare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; /ns1:tenant/@enabled and /ns1:tenant/ns1:descriptiontruefalsefalse @@ -1269,4 +1272,19 @@ ns1:Response/ns1:tenant/ns1:id1234fals <xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse +<xml-fragment/>http://localhost:8080<v1:tenant enabled="true" id="to_delete" + xmlns:v1="http://docs.openstack.org/idm/api/v1.0"> + <v1:description>To Be Deleted</v1:description> +</v1:tenant>declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +/ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_delete" and /ns1:tenant/ns1:description = "To Be Deleted"truefalsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +ns1:tenant/@idto_deletefalsefalsedeclare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +/ns1:tenant/@enabled and /ns1:tenant/ns1:descriptiontruefalsefalse + + +<entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/>http://localhost:8080assert(context.response == null) + + +<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse + + \ No newline at end of file -- cgit