class Moniker::Base

Public Class Methods

headers() click to toggle source

Set the X-Auth-Token header if the OpenStack authentication token is present Set the X-Moniker-Sudo-Tenant-ID if a Moniker administrative access is required

# File lib/moniker/base.rb, line 31
def self.headers
  if defined?(@headers)
    _headers = @headers
  elsif self != Moniker::Base && superclass.headers
    _headers = superclass.headers
  else
    _headers = @headers || {}
  end

  if self.token.present?
    _headers['X-Auth-Token'] = self.token
  end

  if self.sudo_tenant.present?
    _headers['X-Moniker-Sudo-Tenant-ID'] = self.sudo_tenant
  end

  _headers
end
site() click to toggle source

Get the Moniker endpoint

Calls superclass method
# File lib/moniker/base.rb, line 54
def self.site
  if self == OpenStack::Nova::Compute::Base
    Thread.current[:moniker_site]
  else
    super
  end
end
site=(site) click to toggle source

Set the Moniker endpoint

Calls superclass method
# File lib/moniker/base.rb, line 63
def self.site=(site)
  super(site)
  Thread.current[:moniker_site] = @site
  # Regenerate the prefix method
  default = @site.path
  default << '/' unless default[-1..-1] == '/'
  # generate the actual method based on the current site path
  self.prefix = default

  @site
end

Protected Class Methods

sudo_tenant() click to toggle source

Get the current sudo-tenant for administrative access

# File lib/moniker/base.rb, line 96
def self.sudo_tenant
  # Trying to be thread safe here...
  Thread.current[:moniker_sudo_tenant]
end
sudo_tenant=(tenant) click to toggle source

Set the sudo-tenant for administrative access

# File lib/moniker/base.rb, line 90
def self.sudo_tenant=(tenant)
  # Trying to be thread safe here...
  Thread.current[:moniker_sudo_tenant] = token.is_a?(OpenStack::Keystone::Admin::Tenant) ? tenant.id : tenant
end
token() click to toggle source

Get the current authentication token

# File lib/moniker/base.rb, line 84
def self.token
  # Trying to be thread safe here...
  Thread.current[:open_stack_token]
end
token=(token) click to toggle source

Set the authentication token

# File lib/moniker/base.rb, line 78
def self.token=(token)
  # Trying to be thread safe here...
  Thread.current[:open_stack_token] = token.is_a?(OpenStack::Keystone::Public::Auth::Token) ? token.id : token
end