1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #2068 from maginatics/gce_fix_disk_from_snapshot

[google|compute] Fix up the 'disk' api
This commit is contained in:
Akshay Moghe 2013-08-13 14:39:34 -07:00
commit 46d18dd7cd
2 changed files with 7 additions and 5 deletions

View file

@ -26,7 +26,7 @@ module Fog
end end
def resource_url def resource_url
"#{self.project}/global/snapshots/#{name}" "#{self.service.project}/global/snapshots/#{name}"
end end
end end

View file

@ -30,14 +30,16 @@ module Fog
# These must be present if image_name is not specified # These must be present if image_name is not specified
if image_name.nil? if image_name.nil?
unless opts.has_key?(:sourceSnapshot) and opts.has_key?(:sizeGb) unless opts.has_key?('sourceSnapshot') and opts.has_key?('sizeGb')
raise ArgumentError.new('Must specify image OR snapshot and '\ raise ArgumentError.new('Must specify image OR snapshot and '\
'disk size when creating a disk.') 'disk size when creating a disk.')
end end
body_object['sizeGb'] = opts['sizeGb'].delete body_object['sizeGb'] = opts.delete('sizeGb')
# TODO 'get' the sourceSnapshot to validate that it exists?
body_object['sourceSnapshot'] = opts['sourceSnapshot'].delete snap = snapshots.get(opts.delete('sourceSnapshot'))
raise ArgumentError.new('Invalid source snapshot') unless snap
body_object['sourceSnapshot'] = @api_url + snap.resource_url
end end
# Merge in any remaining options (only 'description' should remain) # Merge in any remaining options (only 'description' should remain)