mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
60 lines
2.6 KiB
Ruby
60 lines
2.6 KiB
Ruby
module Fog
|
|
module AWS
|
|
class EC2
|
|
|
|
# Launch specified instances
|
|
#
|
|
# ==== Parameters
|
|
# * image_id<~String> - Id of machine image to load on instances
|
|
# * min_count<~Integer> - Minimum number of instances to launch. If this
|
|
# exceeds the count of available instances, no instances will be
|
|
# launched. Must be between 1 and maximum allowed for your account
|
|
# (by default the maximum for an account is 20)
|
|
# * max_count<~Integer> - Maximum number of instances to launch. If this
|
|
# exceeds the number of available instances, the largest possible
|
|
# number of instances above min_count will be launched instead. Must
|
|
# be between 1 and maximum allowed for you account
|
|
# (by default the maximum for an account is 20)
|
|
# * options<~Hash>:
|
|
# * :availability_zone<~String> - Placement constraint for instances
|
|
# * :data<~String> - Additional data to provide to booting instances
|
|
# * :device_name<~String> - ?
|
|
# * :encoding<~String> - ?
|
|
# * :group_id<~String> - Name of security group for instances
|
|
# * :instance_type<~String> - Type of instance to boot. Valid options
|
|
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
|
|
# default is 'm1.small'
|
|
# * :kernel_id<~String> - Id of kernel with which to launch
|
|
# * :key_name<~String> - Name of a keypair to add to booting instances
|
|
# * :monitoring_enabled<~Boolean> - Enables monitoring, defaults to
|
|
# disabled
|
|
# * :ramdisk_id<~String> - Id of ramdisk with which to launch
|
|
# * :version<~String> - ?
|
|
# * :virtual_name<~String> - ?
|
|
#
|
|
# ==== Returns
|
|
# FIXME: docs
|
|
def run_instances(image_id, min_count, max_count, options = {})
|
|
request({
|
|
'Action' => 'RunInstances',
|
|
'ImageId' => image_id,
|
|
'MinCount' => min_count,
|
|
'MaxCount' => max_count,
|
|
'AvailabilityZone' => options[:availability_zone],
|
|
'Data' => options[:data],
|
|
'DeviceName' => options[:device_name],
|
|
'Encoding' => options[:encoding],
|
|
'GroupId' => options[:group_id],
|
|
'InstanceType' => options[:instance_type],
|
|
'KernelId' => options[:kernel_id],
|
|
'KeyName' => options[:key_name],
|
|
'Monitoring.Enabled' => options[:monitoring_enabled].nil? ? nil : "#{options[:monitoring_enabled]}",
|
|
'RamdiskId' => options[:ramdisk_id],
|
|
'Version' => options[:version],
|
|
'VirtualName' => options[:virtual_name]
|
|
}, Fog::Parsers::AWS::EC2::RunInstances.new)
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|