Skip to content

Commit

Permalink
create image now supports block device mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Stonfer committed Oct 1, 2012
1 parent 77c8999 commit 4275a4b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/fog/aws/requests/compute/create_image.rb
Expand Up @@ -20,15 +20,22 @@ class Real
# * 'requestId'<~String> - Id of request.
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html]
def create_image(instance_id, name, description, no_reboot = false)
request(
def create_image(instance_id, name, description, no_reboot = false, attributes={})
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.DeviceName', attributes['DeviceName']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.NoDevice', attributes['NoDevice']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.VirtualName', attributes['VirtualName']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.SnapshotId', attributes['Ebs.SnapshotId']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.DeleteOnTermination', attributes['Ebs.DeleteOnTermination']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.VolumeType', attributes['Ebs.VolumeType']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.Iops', attributes['Ebs.Iops']))
request({
'Action' => 'CreateImage',
'InstanceId' => instance_id,
'Name' => name,
'Description' => description,
'NoReboot' => no_reboot.to_s,
:parser => Fog::Parsers::Compute::AWS::CreateImage.new
)
}.merge!(params))
end
end

Expand All @@ -39,7 +46,14 @@ class Mock
# AWS[:compute].create_image("i-ac65ee8c", "test", "something")
#

def create_image(instance_id, name, description, no_reboot = false)
def create_image(instance_id, name, description, no_reboot = false, attributes = {})
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.DeviceName', attributes['DeviceName']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.NoDevice', attributes['NoDevice']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.VirtualName', attributes['VirtualName']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.SnapshotId', attributes['Ebs.SnapshotId']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.DeleteOnTermination', attributes['Ebs.DeleteOnTermination']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.VolumeType', attributes['Ebs.VolumeType']))
params.merge!(Fog::AWS.indexed_param('BlockDeviceMapping.%d.Ebs.Iops', attributes['Ebs.Iops']))
response = Excon::Response.new
if instance_id && !name.empty?
response.status = 200
Expand Down

0 comments on commit 4275a4b

Please sign in to comment.