class OpenStack::Base

Public Class Methods

headers() click to toggle source

Set the X-Auth-Token header if the OpenStack authentication token is present

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

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

  _headers
end

Protected Class Methods

token() click to toggle source

Get the current authentication token

# File lib/open_stack/base.rb, line 65
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/open_stack/base.rb, line 59
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