Module: Fog::Rackspace

Extended by:
Provider
Defined in:
lib/fog/providers/rackspace.rb

Class Method Summary collapse

Methods included from Provider

extended, service, services

Class Method Details

.authenticate(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/providers/rackspace.rb', line 12

def self.authenticate(options)
  rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com"
  url = rackspace_auth_url.match(/^https?:/) ? \
            rackspace_auth_url : 'https://' + rackspace_auth_url
  connection = Fog::Connection.new(url)
  @rackspace_api_key  = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  response = connection.request({
    :expects  => 204,
    :headers  => {
      'X-Auth-Key'  => @rackspace_api_key,
      'X-Auth-User' => @rackspace_username
    },
    :host     => rackspace_auth_url,
    :method   => 'GET',
    :path     => 'v1.0'
  })
  response.headers.reject do |key, value|
    !['X-Server-Management-Url', 'X-Storage-Url', 'X-CDN-Management-Url', 'X-Auth-Token'].include?(key)
  end
end