1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[openstack|identity] Update Fog to Accomodate Tenant Deletion Workaround

Workflow

Signed-off-by: Nelvin Driz <nelvindriz@live.com>
This commit is contained in:
Nelvin Driz 2012-04-02 15:26:45 +08:00
parent d46c886f67
commit e47c5eb9c4
7 changed files with 36 additions and 6 deletions

View file

@ -38,6 +38,7 @@ module Fog
request :get_user_by_id
request :get_user_by_name
request :add_user_to_tenant
request :remove_user_from_tenant
request :list_endpoints_for_token
request :list_roles_for_user_on_tenant

View file

@ -20,6 +20,11 @@ module Fog
:user => user)
end
def users
requires :id
connection.users(:tenant => self)
end
def destroy
requires :id
connection.delete_tenant(self.id)

View file

@ -7,8 +7,11 @@ module Fog
class Users < Fog::Collection
model Fog::Identity::OpenStack::User
attribute :tenant
def all
load(connection.list_users.body['users'])
tenant_id = tenant.id || nil
load(connection.list_users(tenant_id).body['users'])
end
def find_by_id(id)

View file

@ -4,7 +4,7 @@ module Fog
class Real
def delete_tenant(id)
request(
:expects => [200],
:expects => [200, 204],
:method => 'DELETE',
:path => "tenants/#{id}"
)

View file

@ -2,17 +2,18 @@ module Fog
module Identity
class OpenStack
class Real
def list_users
def list_users(tenant_id = nil)
path = tenant_id ? "tenants/#{tenant_id}/users" : 'users'
request(
:expects => [200, 204],
:method => 'GET',
:path => 'users'
:path => path
)
end
end # class Real
class Mock
def list_users
def list_users(tenant_id = nil)
response = Excon::Response.new
response.status = 200
response.body = { 'users' => self.data[:users].values }

View file

@ -0,0 +1,20 @@
module Fog
module Identity
class OpenStack
class Real
def remove_user_from_tenant(tenant_id, user_id, role_id)
request(
:expects => [200, 204],
:method => 'DELETE',
:path => "/tenants/#{tenant_id}/users/#{user_id}/roles/OS-KSADM/#{role_id}"
)
end
end # class Real
class Mock
def remove_user_from_tenant(tenant_id, user_id, role_id)
end # def remove_user_from_tenant
end # class Mock
end # class OpenStack
end # module Identity
end