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

54 lines
1.9 KiB
Ruby
Raw Normal View History

2009-10-10 22:05:17 -04:00
module Fog
module Rackspace
class Servers
def self.reload
load "fog/rackspace/models/servers/server.rb"
load "fog/rackspace/models/servers/servers.rb"
2009-10-16 01:22:27 -04:00
load "fog/rackspace/requests/servers/create_image.rb"
2009-10-14 01:36:35 -04:00
load "fog/rackspace/requests/servers/create_server.rb"
2009-10-16 01:24:42 -04:00
load "fog/rackspace/requests/servers/delete_image.rb"
2009-10-14 01:36:35 -04:00
load "fog/rackspace/requests/servers/delete_server.rb"
2009-10-15 16:33:54 -04:00
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"
2009-10-19 20:57:47 -04:00
load "fog/rackspace/requests/servers/list_images_detail.rb"
load "fog/rackspace/requests/servers/list_servers.rb"
2009-10-19 20:55:57 -04:00
load "fog/rackspace/requests/servers/list_servers_detail.rb"
2009-10-17 17:24:34 -04:00
load "fog/rackspace/requests/servers/reboot_server.rb"
load "fog/rackspace/requests/servers/update_server.rb"
2009-10-10 22:05:17 -04:00
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]}"
})
2009-10-14 01:36:35 -04:00
unless response.body.empty?
2009-10-11 16:37:25 -04:00
response.body = JSON.parse(response.body)
end
2009-10-10 22:05:17 -04:00
response
end
end
end
end
Fog::Rackspace::Servers.reload