mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix up the 'disk' api
A recent patch to introduce support for creating disks from snapshots had a few problems: 1. Incorrect URL (to the snapshot resource) was being sent 2. Ruby syntax errors. I looked into adding Shindo tests for this, but am not able to since this request relies on a pre-existing snapshot which we use for disk creation.
This commit is contained in:
parent
fffa8dea69
commit
d716ba1c1d
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