[ec2] run_instances: simplify SecurityGroup, add BlockDeviceMapping support
This commit is contained in:
parent
b554eb0bb4
commit
809ecfc294
|
@ -120,7 +120,7 @@ module Fog
|
|||
options['Placement.AvailabilityZone'] = @availability_zone
|
||||
end
|
||||
unless @groups.empty?
|
||||
options.merge!(AWS.indexed_param("SecurityGroup", @groups))
|
||||
options['SecurityGroup'] = @groups
|
||||
end
|
||||
if @kernel_id
|
||||
options['KernelId'] = @kernel_id
|
||||
|
|
|
@ -18,12 +18,13 @@ module Fog
|
|||
# (by default the maximum for an account is 20)
|
||||
# * options<~Hash>:
|
||||
# * 'Placement.AvailabilityZone'<~String> - Placement constraint for instances
|
||||
# * 'BlockDeviceMapping.n.DeviceName'<~String> - where the volume will be exposed to instance
|
||||
# * 'BlockDeviceMapping.n.VirtualName'<~String> - volume virtual device name
|
||||
# * 'BlockDeviceMapping.n.Ebs.SnapshotId'<~String> - id of snapshot to boot volume from
|
||||
# * 'BlockDeviceMapping.n.Ebs.VolumeSize'<~String> - size of volume in GiBs required unless snapshot is specified
|
||||
# * 'BlockDeviceMapping.n.Ebs.DeleteOnTermination'<~String> - specifies whether or not to delete the volume on instance termination
|
||||
# * 'SecurityGroup.n'<~String> - Indexed names of security groups for instances
|
||||
# * 'BlockDeviceMapping'<~Array>: array of hashes
|
||||
# * 'DeviceName'<~String> - where the volume will be exposed to instance
|
||||
# * 'VirtualName'<~String> - volume virtual device name
|
||||
# * 'Ebs.SnapshotId'<~String> - id of snapshot to boot volume from
|
||||
# * 'Ebs.VolumeSize'<~String> - size of volume in GiBs required unless snapshot is specified
|
||||
# * 'Ebs.DeleteOnTermination'<~String> - specifies whether or not to delete the volume on instance termination
|
||||
# * 'SecurityGroup'<~Array> or <~String> - Name of security group(s) for instances
|
||||
# * 'InstanceInitiatedShutdownBehaviour'<~String> - specifies whether volumes are stopped or terminated when instance is shutdown
|
||||
# * 'InstanceType'<~String> - Type of instance to boot. Valid options
|
||||
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'm2.2xlarge', 'm2.4xlarge']
|
||||
|
@ -76,6 +77,16 @@ module Fog
|
|||
# * 'requestId'<~String> - Id of request
|
||||
# * 'reservationId'<~String> - Id of reservation
|
||||
def run_instances(image_id, min_count, max_count, options = {})
|
||||
if block_device_mapping = options.delete('BlockDeviceMapping')
|
||||
block_device_mapping.each_with_index do |mapping, index|
|
||||
for key, value in mapping
|
||||
options.merge!({ format("BlockDeviceMapping.%d.#{key}", index) => value })
|
||||
end
|
||||
end
|
||||
end
|
||||
if security_groups = [*options.delete('SecurityGroup')]
|
||||
options.merge!(AWS.indexed_params('SecurityGroup', security_groups))
|
||||
end
|
||||
if options['UserData']
|
||||
options['UserData'] = Base64.encode64(options['UserData'])
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue