Class: Moniker::Base

Inherits:
ActiveResource::Base show all
Defined in:
lib/moniker/base.rb

Direct Known Subclasses

Common

Class Method Summary collapse

Methods inherited from ActiveResource::Base

#load

Class Method Details

.headersObject

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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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

.siteObject

Get the Moniker endpoint



54
55
56
57
58
59
60
# 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) ⇒ Object

Set the Moniker endpoint



63
64
65
66
67
68
69
70
71
72
73
# 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