Skip to content

Commit

Permalink
Merge pull request fog#3631 from dhague/master
Browse files Browse the repository at this point in the history
[openstack] Add support for hierarchical projects in Identity v3
  • Loading branch information
geemus committed Jul 15, 2015
2 parents 41b327a + aff41b7 commit a0cf9aa
Show file tree
Hide file tree
Showing 5 changed files with 781 additions and 5 deletions.
7 changes: 7 additions & 0 deletions lib/fog/openstack/models/identity_v3/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def revoke_role_from_group(role_id, group_id)
service.revoke_project_group_role(self.id, group_id, role_id)
end

def subtree
@attributes['subtree']
end

def parents
@attributes['parents']
end
end
end
end
Expand Down
9 changes: 6 additions & 3 deletions lib/fog/openstack/models/identity_v3/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ def auth_projects(options = {})
load(service.auth_projects(options).body['projects'])
end

def find_by_id(id)
cached_project = self.find { |project| project.id == id }
def find_by_id(id, options=[]) # options can include :subtree_as_ids, :subtree_as_list, :parents_as_ids, :parents_as_list
if options.is_a? Symbol # Deal with a single option being passed on its own
options = [options]
end
cached_project = self.find { |project| project.id == id } if options.empty?
return cached_project if cached_project
project_hash = service.get_project(id).body['project']
project_hash = service.get_project(id, options).body['project']
Fog::Identity::OpenStack::V3::Project.new(
project_hash.merge(:service => service))
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/openstack/requests/identity_v3/get_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Identity
class OpenStack
class V3
class Real
def get_project(id)
def get_project(id, options=[])
request(
:expects => [200],
:method => 'GET',
:path => "projects/#{id}"
:path => "projects/#{id}?#{options.join '&'}"
)
end
end
Expand Down
Loading

0 comments on commit a0cf9aa

Please sign in to comment.