From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/deltacloud/base_driver/features.rb | 8 ++++++++ server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 7 +++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb index f978640..33ab61d 100644 --- a/server/lib/deltacloud/base_driver/features.rb +++ b/server/lib/deltacloud/base_driver/features.rb @@ -232,6 +232,14 @@ module Deltacloud end end + declare_feature :instances, :attach_ebs_snapshot do + description "Number of instances to be launch with at once" + operation :create do + param :ebs_snapshot_id, :string, :optional + param :device_name, :string, :optional + end + end + declare_feature :instances, :sandboxing do description "Allow lanuching sandbox images" operation :create do diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb index dcf16fe..8ff2144 100644 --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb @@ -43,6 +43,7 @@ module Deltacloud feature :images, :owner_id feature :buckets, :bucket_location feature :instances, :register_to_load_balancer + feature :instances, :attach_ebs_snapshot DEFAULT_REGION = 'us-east-1' @@ -205,6 +206,12 @@ module Deltacloud :min_count => opts[:instance_count], :max_count => opts[:instance_count] ) if opts[:instance_count] and opts[:instance_count].length!=0 + if opts[:ebs_snapshot_id] and opts[:device_name] + instance_options.merge!(:block_device_mappings => [{ + :ebs_snapshot_id => opts[:ebs_snapshot_id], + :device_name => opts[:device_name] + }]) + end safely do new_instance = convert_instance(ec2.launch_instances(image_id, instance_options).first) # TODO: Rework this to use client_id for name instead of tag -- 1.7.4.1
