2009-10-10 22:05:17 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
|
2010-02-12 02:41:40 -05:00
|
|
|
def self.dependencies
|
|
|
|
[
|
|
|
|
'fog/rackspace/files.rb',
|
|
|
|
'fog/rackspace/servers.rb'
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2009-10-10 22:05:17 -04:00
|
|
|
def self.reload
|
2010-02-12 02:41:40 -05:00
|
|
|
self.dependencies.each {|dependency| load(dependency)}
|
2009-10-10 22:05:17 -04:00
|
|
|
end
|
|
|
|
|
2009-11-08 01:29:25 -05:00
|
|
|
unless Fog.mocking?
|
|
|
|
|
|
|
|
def self.authenticate(options)
|
2010-01-22 23:50:59 -05:00
|
|
|
unless @rackspace_api_key = options[:rackspace_api_key]
|
2010-01-24 19:41:39 -05:00
|
|
|
raise ArgumentError.new('rackspace_api_key is required to access rackspace')
|
2010-01-22 23:50:59 -05:00
|
|
|
end
|
|
|
|
unless @rackspace_username = options[:rackspace_username]
|
2010-01-24 19:41:39 -05:00
|
|
|
raise ArgumentError.new('rackspace_username is required to access rackspace')
|
2010-01-22 23:50:59 -05:00
|
|
|
end
|
2009-11-08 01:29:25 -05:00
|
|
|
connection = Fog::Connection.new("https://auth.api.rackspacecloud.com")
|
|
|
|
response = connection.request({
|
|
|
|
:expects => 204,
|
|
|
|
:headers => {
|
2010-01-22 23:50:59 -05:00
|
|
|
'X-Auth-Key' => @rackspace_api_key,
|
|
|
|
'X-Auth-User' => @rackspace_username
|
2009-11-08 01:29:25 -05:00
|
|
|
},
|
|
|
|
: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)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
def self.authenticate(options)
|
|
|
|
{
|
|
|
|
'X-Auth_Token' => '01234567-0123-0123-0123-01234',
|
|
|
|
'X-CDN-Management-Url' => 'https://cdn.cloaddrive.com/v1/CloudFS_01234-0123',
|
|
|
|
'X-Server-Management-Url' => 'https://servers.api.rackspacecloud.com/v1.0/01234',
|
|
|
|
'X-Storage-Url' => 'https://storage.clouddrive.com/v1/CloudFS_01234-0123'
|
|
|
|
}
|
2009-10-10 22:05:17 -04:00
|
|
|
end
|
2009-11-08 01:29:25 -05:00
|
|
|
|
|
|
|
srand(Time.now.to_i)
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
end
|
|
|
|
|
2009-10-10 22:05:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2010-02-12 02:41:40 -05:00
|
|
|
|
|
|
|
Fog::Rackspace.dependencies.each {|dependency| require(dependency)}
|