1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/servers.rb
2009-10-19 17:57:47 -07:00

54 lines
No EOL
1.9 KiB
Ruby

module Fog
module Rackspace
class Servers
def self.reload
load "fog/rackspace/models/servers/server.rb"
load "fog/rackspace/models/servers/servers.rb"
load "fog/rackspace/requests/servers/create_image.rb"
load "fog/rackspace/requests/servers/create_server.rb"
load "fog/rackspace/requests/servers/delete_image.rb"
load "fog/rackspace/requests/servers/delete_server.rb"
load "fog/rackspace/requests/servers/get_server_details.rb"
load "fog/rackspace/requests/servers/list_flavors.rb"
load "fog/rackspace/requests/servers/list_images.rb"
load "fog/rackspace/requests/servers/list_images_detail.rb"
load "fog/rackspace/requests/servers/list_servers.rb"
load "fog/rackspace/requests/servers/list_servers_detail.rb"
load "fog/rackspace/requests/servers/reboot_server.rb"
load "fog/rackspace/requests/servers/update_server.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.body.empty?
response.body = JSON.parse(response.body)
end
response
end
end
end
end
Fog::Rackspace::Servers.reload