mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ec2] simplify server model create process
This commit is contained in:
parent
04aaecd9cb
commit
b450dda27c
1 changed files with 12 additions and 22 deletions
|
@ -115,28 +115,18 @@ module Fog
|
|||
def save
|
||||
requires :image_id
|
||||
|
||||
options = {'InstanceType' => flavor.id}
|
||||
if @availability_zone
|
||||
options['Placement.AvailabilityZone'] = @availability_zone
|
||||
end
|
||||
unless @groups.empty?
|
||||
options['SecurityGroup'] = @groups
|
||||
end
|
||||
if @kernel_id
|
||||
options['KernelId'] = @kernel_id
|
||||
end
|
||||
if @key_name
|
||||
options['KeyName'] = @key_name
|
||||
end
|
||||
if @monitoring
|
||||
options['Monitoring.Enabled'] = @monitoring
|
||||
end
|
||||
if @ramdisk_id
|
||||
options['RamdiskId'] = @ramdisk_id
|
||||
end
|
||||
if @user_data
|
||||
options['UserData'] = @user_data
|
||||
end
|
||||
options = {
|
||||
'BlockDeviceMapping' => @block_device_mapping,
|
||||
'InstanceType' => flavor.id,
|
||||
'KernelId' => @kernel_id,
|
||||
'KeyName' => @key_name,
|
||||
'Monitoring.Enabled' => @monitoring,
|
||||
'Placement.AvailabilityZone' => @availability_zone,
|
||||
'RamdiskId' => @ramdisk_id,
|
||||
'SecurityGroup' => @groups,
|
||||
'UserData' => @user_data
|
||||
}
|
||||
|
||||
data = connection.run_instances(@image_id, 1, 1, options)
|
||||
merge_attributes(data.body['instancesSet'].first)
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue