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/digitalocean/requests/compute/create_server.rb

71 lines
1.7 KiB
Ruby
Raw Normal View History

module Fog
module Compute
class DigitalOcean
class Real
#
# FIXME: missing ssh keys support
#
2013-07-21 11:09:53 -07:00
def create_server( name,
size_id,
image_id,
region_id,
options = {} )
query_hash = {
:name => name,
:size_id => size_id,
:image_id => image_id,
:region_id => region_id
}
if options[:ssh_key_ids]
2013-07-21 11:09:53 -07:00
options[:ssh_key_ids] = options[:ssh_key_ids].join(",") if options[:ssh_key_ids].is_a? Array
query_hash[:ssh_key_ids] = options[:ssh_key_ids]
end
2013-07-21 11:09:53 -07:00
request(
:expects => [200],
:method => 'GET',
:path => 'droplets/new',
:query => query_hash
)
end
end
class Mock
2013-07-21 11:09:53 -07:00
def create_server( name,
size_id,
image_id,
region_id,
options = {} )
response = Excon::Response.new
response.status = 200
mock_data = {
"id" => Fog::Mock.random_numbers(1).to_i,
"event_id" => Fog::Mock.random_numbers(2).to_i,
"name" => name,
"size_id" => size_id,
"image_id" => image_id,
"region_id" => region_id,
2013-07-23 22:04:50 -07:00
"ip_address" => "127.0.0.1",
"status" => 'active'
}
response.body = {
"status" => "OK",
"droplet" => mock_data
}
self.data[:servers] << mock_data
response
end
end
end
end
end