Permalink
Browse files

[ec2] simplify server model create process

  • Loading branch information...
geemus committed May 18, 2010
1 parent 04aaecd commit b450dda27c033392798b9c6d7db5e3fa94f84cb3
Showing with 12 additions and 22 deletions.
  1. +12 −22 lib/fog/aws/models/ec2/server.rb
@@ -115,28 +115,18 @@ def reboot
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

0 comments on commit b450dda

Please sign in to comment.