Skip to content

Commit

Permalink
Merge pull request fog#44 from adillera/local_development_branch
Browse files Browse the repository at this point in the history
Added request for boot_from_snapshot.
  • Loading branch information
hunter committed Apr 11, 2012
2 parents 93eb7cb + c6630b1 commit 861ba6e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fog/openstack/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class OpenStack < Fog::Service
request :add_fixed_ip
request :remove_fixed_ip
request :server_diagnostics
request :boot_from_snapshot

# Server Extenstions
request :get_console_output
Expand Down
40 changes: 40 additions & 0 deletions lib/fog/openstack/requests/compute/boot_from_snapshot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module Fog
module Compute
class OpenStack
class Real
def boot_from_snapshot(name, image_ref, flavor_ref, options={})
data = {
'server' => {
'flavorRef' => flavor_ref,
'imageRef' => image_ref,
'name' => name
}
}

vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
'availability_zone', 'user_data', 'block_device_mapping']
vanilla_options.select{|o| options[o]}.each do |key|
data['server'][key] = options[key]
end

if options['personality']
data['server']['personality'] = []
for file in options['personality']
data['server']['personality'] << {
'contents' => Base64.encode64(file['contents']),
'path' => file['path']
}
end
end

request(
:body => MultiJson.encode(data),
:expects => [200, 202],
:method => 'POST',
:path => '/os-volumes_boot.json'
)
end
end
end # class OpenStack
end # module Compute
end # module Fog

0 comments on commit 861ba6e

Please sign in to comment.