class OpenStack::Keystone::Admin::Tenant

An OpenStack Tenant (“admin view”)

Attributes

Public Class Methods

find_by_name(name) click to toggle source

List of tenant with a given name

Attributes

  • name - A string

# File lib/open_stack/keystone/admin/tenant.rb, line 75
def self.find_by_name(name)
  all.detect { |x| x.name == name }
end

Public Instance Methods

add_role_to_user(role, user) click to toggle source

Adds a role to a user in this tenant

Attributes

# File lib/open_stack/keystone/admin/tenant.rb, line 111
def add_role_to_user(role, user)
  role_id = role.is_a?(OpenStack::Keystone::Admin::Role) ? role.id : role
  user_id = user.is_a?(OpenStack::Keystone::Admin::User) ? user.id : user

  put("users/#{user_id}/roles/OS-KSADM/#{role_id}", {}, "null")
end
delete_role_from_user(role, user) click to toggle source

Removes a role to a user in this tenant

Attributes

# File lib/open_stack/keystone/admin/tenant.rb, line 123
def delete_role_from_user(role, user)
  role_id = role.is_a?(OpenStack::Keystone::Admin::Role) ? role.id : role
  user_id = user.is_a?(OpenStack::Keystone::Admin::User) ? user.id : user

  delete("users/#{user_id}/roles/OS-KSADM/#{role_id}")
end
description=(description) click to toggle source

Returns a filtered description for this tenant

# File lib/open_stack/keystone/admin/tenant.rb, line 131
def description=(description)
  @attributes[:description] = description.gsub /[^\w\s\.\-:@+,'"]/, '_' if description

end
user(id) click to toggle source

Returns the instance of OpenStack::Keystone::Admin::User with the given id

Attributes

  • id - A string

# File lib/open_stack/keystone/admin/tenant.rb, line 91
def user(id)
  users(id)
end
user_roles(user, scope = :all) click to toggle source

List if roles in this tenant for a given instance of OpenStack::Keystone::Admin::User or user id

Attributes

# File lib/open_stack/keystone/admin/tenant.rb, line 100
def user_roles(user, scope = :all)
  user_id = user.is_a?(OpenStack::Keystone::Admin::User) ? user.id : user

  Role.find(scope, :params => {:tenant_id => self.id, :user_id => user_id})
end
users(scope = :all) click to toggle source

List of Users (instances of OpenStack::Keystone::Admin::User) in this tenant

Attributes

# File lib/open_stack/keystone/admin/tenant.rb, line 83
def users(scope = :all)
  User.find(scope, :params => {:tenant_id => self.id})
end

Protected Instance Methods

initialize(params = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/open_stack/keystone/admin/tenant.rb, line 44
def initialize(params = {}, persisted = false) # :notnew:
  super(params, persisted)

  self.description = description
end