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:
parent
d46c886f67
commit
e47c5eb9c4
7 changed files with 36 additions and 6 deletions
|
@ -38,6 +38,7 @@ module Fog
|
||||||
request :get_user_by_id
|
request :get_user_by_id
|
||||||
request :get_user_by_name
|
request :get_user_by_name
|
||||||
request :add_user_to_tenant
|
request :add_user_to_tenant
|
||||||
|
request :remove_user_from_tenant
|
||||||
|
|
||||||
request :list_endpoints_for_token
|
request :list_endpoints_for_token
|
||||||
request :list_roles_for_user_on_tenant
|
request :list_roles_for_user_on_tenant
|
||||||
|
|
|
@ -20,6 +20,11 @@ module Fog
|
||||||
:user => user)
|
:user => user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def users
|
||||||
|
requires :id
|
||||||
|
connection.users(:tenant => self)
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_tenant(self.id)
|
connection.delete_tenant(self.id)
|
||||||
|
|
|
@ -7,8 +7,11 @@ module Fog
|
||||||
class Users < Fog::Collection
|
class Users < Fog::Collection
|
||||||
model Fog::Identity::OpenStack::User
|
model Fog::Identity::OpenStack::User
|
||||||
|
|
||||||
|
attribute :tenant
|
||||||
|
|
||||||
def all
|
def all
|
||||||
load(connection.list_users.body['users'])
|
tenant_id = tenant.id || nil
|
||||||
|
load(connection.list_users(tenant_id).body['users'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_by_id(id)
|
def find_by_id(id)
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
def delete_tenant(id)
|
def delete_tenant(id)
|
||||||
request(
|
request(
|
||||||
:expects => [200],
|
:expects => [200, 204],
|
||||||
:method => 'DELETE',
|
:method => 'DELETE',
|
||||||
:path => "tenants/#{id}"
|
:path => "tenants/#{id}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,17 +2,18 @@ module Fog
|
||||||
module Identity
|
module Identity
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Real
|
class Real
|
||||||
def list_users
|
def list_users(tenant_id = nil)
|
||||||
|
path = tenant_id ? "tenants/#{tenant_id}/users" : 'users'
|
||||||
request(
|
request(
|
||||||
:expects => [200, 204],
|
:expects => [200, 204],
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => 'users'
|
:path => path
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end # class Real
|
end # class Real
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_users
|
def list_users(tenant_id = nil)
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
response.body = { 'users' => self.data[:users].values }
|
response.body = { 'users' => self.data[:users].values }
|
||||||
|
|
|
@ -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
|
Loading…
Add table
Reference in a new issue