Module: Fog::OpenStack::Auth::Token

Included in:
V2, V3
Defined in:
lib/fog/openstack/auth/token.rb,
lib/fog/openstack/auth/token/v2.rb,
lib/fog/openstack/auth/token/v3.rb

Defined Under Namespace

Classes: CredentialsError, ExpiryError, StandardError, URLError, V2, V3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#catalogObject (readonly)

Returns the value of attribute catalog.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def catalog
  @catalog
end

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def data
  @data
end

#expiresObject (readonly)

Returns the value of attribute expires.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def expires
  @expires
end

#tenantObject (readonly)

Returns the value of attribute tenant.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def tenant
  @tenant
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def token
  @token
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/fog/openstack/auth/token.rb', line 10

def user
  @user
end

Class Method Details

.build(auth, options) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/auth/token.rb', line 16

def self.build(auth, options)
  if auth[:openstack_identity_api_version] =~ /(v)*2(\.0)*/i ||
     auth[:openstack_tenant_id] || auth[:openstack_tenant]
    Fog::OpenStack::Auth::Token::V2.new(auth, options)
  else
    Fog::OpenStack::Auth::Token::V3.new(auth, options)
  end
end

Instance Method Details

#getObject



35
36
37
38
# File 'lib/fog/openstack/auth/token.rb', line 35

def get
  set(authenticate(@creds, {})) if expired?
  @token
end

#initialize(auth, options) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/auth/token.rb', line 25

def initialize(auth, options)
  raise URLError, 'No URL provided' if auth[:openstack_auth_url].nil? || auth[:openstack_auth_url].empty?
  @creds = {
    :data => build_credentials(auth),
    :uri  => URI.parse(auth[:openstack_auth_url])
  }
  response = authenticate(@creds, options)
  set(response)
end