2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/rackspace/files'
|
|
|
|
require 'fog/rackspace/servers'
|
|
|
|
|
2009-10-10 22:05:17 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
|
2010-03-19 21:29:42 -04:00
|
|
|
def self.authenticate(options)
|
|
|
|
unless @rackspace_api_key = options[:rackspace_api_key]
|
|
|
|
raise ArgumentError.new('rackspace_api_key is required to access rackspace')
|
2009-11-08 01:29:25 -05:00
|
|
|
end
|
2010-03-19 21:29:42 -04:00
|
|
|
unless @rackspace_username = options[:rackspace_username]
|
|
|
|
raise ArgumentError.new('rackspace_username is required to access rackspace')
|
2009-10-10 22:05:17 -04:00
|
|
|
end
|
2010-03-19 21:29:42 -04:00
|
|
|
connection = Fog::Connection.new("https://auth.api.rackspacecloud.com")
|
|
|
|
response = connection.request({
|
|
|
|
:expects => 204,
|
|
|
|
:headers => {
|
|
|
|
'X-Auth-Key' => @rackspace_api_key,
|
|
|
|
'X-Auth-User' => @rackspace_username
|
|
|
|
},
|
|
|
|
:host => 'auth.api.rackspacecloud.com',
|
|
|
|
: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)
|
2009-11-08 01:29:25 -05:00
|
|
|
end
|
2009-10-10 22:05:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|