Пример #1
0
 def delete_tenant(self, tenant):
     """
     ADMIN ONLY. Removes the tenant from the system. There is no 'undo'
     available, so you should be certain that the tenant specified is the
     tenant you wish to delete.
     """
     tenant_id = utils.get_id(tenant)
     uri = "tenants/%s" % tenant_id
     resp, resp_body = self.method_delete(uri)
     if resp.status_code == 404:
         raise exc.TenantNotFound("Tenant '%s' does not exist." % tenant)
Пример #2
0
 def _list_tenants(self, admin):
     """
     Returns either a list of all tenants (admin=True), or the tenant for
     the currently-authenticated user (admin=False).
     """
     resp, resp_body = self.method_get("tenants", admin=admin)
     if 200 <= resp.status_code < 300:
         tenants = resp_body.get("tenants", [])
         return [Tenant(self, tenant) for tenant in tenants]
     elif resp.status_code in (401, 403):
         raise exc.AuthorizationFailure("You are not authorized to list "
                 "tenants.")
     else:
         raise exc.TenantNotFound("Could not get a list of tenants.")