From 0d9b04b1046727abfbebaa3febaf56814d5f526e Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Tue, 17 Apr 2012 20:31:47 +0800 Subject: [PATCH] [openstack|identity] Correction in Roles#all method User#roles should be calling Service#list_roles_for_user_on_tenant directly and not use Roles#all since the latter is actually a method for getting all roles in the Identity Service --- lib/fog/openstack/models/identity/roles.rb | 7 +------ lib/fog/openstack/models/identity/user.rb | 10 ++-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/fog/openstack/models/identity/roles.rb b/lib/fog/openstack/models/identity/roles.rb index de8b44380..75c288b58 100644 --- a/lib/fog/openstack/models/identity/roles.rb +++ b/lib/fog/openstack/models/identity/roles.rb @@ -7,13 +7,8 @@ module Fog class Roles < Fog::Collection model Fog::Identity::OpenStack::Role - attribute :user - attribute :tenant - def all - requires :user, :tenant - load(connection. - list_roles_for_user_on_tenant(tenant.id, user.id).body['roles']) + load(connection.list_roles.body['roles']) end def get(id) diff --git a/lib/fog/openstack/models/identity/user.rb b/lib/fog/openstack/models/identity/user.rb index c4ed49e77..dd898567e 100644 --- a/lib/fog/openstack/models/identity/user.rb +++ b/lib/fog/openstack/models/identity/user.rb @@ -54,14 +54,8 @@ module Fog true end - def roles - return Array.new unless tenant_id - tenant = Fog::Identity::OpenStack::Tenant. - new(connection.get_tenant(tenant_id).body['tenant']) - - connection.roles( - :tenant => tenant, - :user => self) + def roles(tenant_id = self.tenant_id) + connection.list_roles_for_user_on_tenant(tenant_id, self.id).body['roles'] end end # class User end # class OpenStack