mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
42 lines
No EOL
1.2 KiB
Ruby
42 lines
No EOL
1.2 KiB
Ruby
module Fog
|
|
module Rackspace
|
|
class Servers
|
|
|
|
def self.reload
|
|
load "fog/rackspace/requests/servers/get_flavors.rb"
|
|
load "fog/rackspace/requests/servers/get_images.rb"
|
|
load "fog/rackspace/requests/servers/get_servers.rb"
|
|
end
|
|
|
|
def initialize(options={})
|
|
credentials = Fog::Rackspace.authenticate(options)
|
|
@auth_token = credentials['X-Auth-Token']
|
|
uri = URI.parse(credentials['X-Server-Management-Url'])
|
|
@host = uri.host
|
|
@path = uri.path
|
|
@port = uri.port
|
|
@scheme = uri.scheme
|
|
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
|
end
|
|
|
|
def request(params)
|
|
response = @connection.request({
|
|
:body => params[:body],
|
|
:expects => params[:expects],
|
|
:headers => {
|
|
'X-Auth-Token' => @auth_token
|
|
},
|
|
:host => @host,
|
|
:method => params[:method],
|
|
:path => "#{@path}/#{params[:path]}"
|
|
})
|
|
unless response.status == 204
|
|
response.body = JSON.parse(response.body)
|
|
end
|
|
response
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
Fog::Rackspace::Servers.reload |