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:
commit
46d18dd7cd
2 changed files with 7 additions and 5 deletions
|
@ -26,7 +26,7 @@ module Fog
|
|||
end
|
||||
|
||||
def resource_url
|
||||
"#{self.project}/global/snapshots/#{name}"
|
||||
"#{self.service.project}/global/snapshots/#{name}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -30,14 +30,16 @@ module Fog
|
|||
|
||||
# These must be present if image_name is not specified
|
||||
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 '\
|
||||
'disk size when creating a disk.')
|
||||
end
|
||||
|
||||
body_object['sizeGb'] = opts['sizeGb'].delete
|
||||
# TODO 'get' the sourceSnapshot to validate that it exists?
|
||||
body_object['sourceSnapshot'] = opts['sourceSnapshot'].delete
|
||||
body_object['sizeGb'] = opts.delete('sizeGb')
|
||||
|
||||
snap = snapshots.get(opts.delete('sourceSnapshot'))
|
||||
raise ArgumentError.new('Invalid source snapshot') unless snap
|
||||
body_object['sourceSnapshot'] = @api_url + snap.resource_url
|
||||
end
|
||||
|
||||
# Merge in any remaining options (only 'description' should remain)
|
||||
|
|
Loading…
Reference in a new issue