Module: Fog::Image::OpenStack::Common

Includes:
OpenStack::Core
Included in:
V1::Real, V2::Real
Defined in:
lib/fog/openstack/image.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.



21
22
23
# File 'lib/fog/openstack/image.rb', line 21

def unscoped_token
  @unscoped_token
end

Instance Method Details

#request(params) ⇒ Object



25
26
27
28
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
# File 'lib/fog/openstack/image.rb', line 25

def request(params)
  retried = false
  begin
    std_headers = {
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'X-Auth-Token' => @auth_token
    }
    param_headers = params.fetch(:headers,{})

    response = @connection.request(params.merge({
      :headers => std_headers.merge(param_headers),
      :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::Image::OpenStack::NotFound.slurp(error)
            else
              error
          end
  end
  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body) unless params[:raw_body]
  end
  response
end