Module: Fog::Identity::OpenStack::Common

Includes:
OpenStack::Core
Included in:
V2::Real, V3::Real
Defined in:
lib/fog/openstack/identity.rb

Instance Attribute Summary collapse

Attributes included from OpenStack::Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_domain_id, #openstack_domain_name, #openstack_project_domain, #openstack_project_domain_id, #openstack_user_domain, #openstack_user_domain_id

Instance Method Summary collapse

Methods included from OpenStack::Core

#credentials, #initialize_identity, #reload

Instance Attribute Details

#unscoped_tokenObject (readonly)

Returns the value of attribute unscoped_token



25
26
27
# File 'lib/fog/openstack/identity.rb', line 25

def unscoped_token
  @unscoped_token
end

Instance Method Details

#request(params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/openstack/identity.rb', line 29

def request(params)
  retried = false
  begin
    response = @connection.request(params.merge({
      :headers => params.fetch(:headers,{}).merge({
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'X-Auth-Token' => @auth_token
      }),
      :path => "#{@path}/#{params[:path]}"
    }))
  rescue Excon::Errors::Unauthorized => error
    raise if retried
    retried = true

    @openstack_must_reauthenticate = true
    authenticate
    retry
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
            when Excon::Errors::NotFound
              Fog::Identity::OpenStack::NotFound.slurp(error)
            else
              error
          end
  end
  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end