You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/05/11 11:26:10 UTC
svn commit: r1101798 - in /incubator/deltacloud/trunk:
client/lib/deltacloud.rb server/lib/deltacloud/base_driver/features.rb
server/lib/deltacloud/drivers/ec2/ec2_driver.rb
Author: mfojtik
Date: Wed May 11 09:26:09 2011
New Revision: 1101798
URL: http://svn.apache.org/viewvc?rev=1101798&view=rev
Log:
Attaching EBS snapshot to instance upon creation time
Modified:
incubator/deltacloud/trunk/client/lib/deltacloud.rb
incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb
incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1101798&r1=1101797&r2=1101798&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Wed May 11 09:26:09 2011
@@ -294,6 +294,13 @@ module DeltaCloud
params[:hwp_id] ||= params[:hardware_profile]
end
+ if args[:snapshot_id] and args[:device_name]
+ params.merge!({
+ :snapshot_id => args[:snapshot_id],
+ :device_name => args[:device_name]
+ })
+ end
+
params[:image_id] ||= params[:image_id] || args[0] if args[0].class!=Hash
obj = nil
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb?rev=1101798&r1=1101797&r2=1101798&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb Wed May 11 09:26:09 2011
@@ -232,6 +232,14 @@ module Deltacloud
end
end
+ declare_feature :instances, :attach_snapshot do
+ description "Attach an snapshot to instance on create"
+ operation :create do
+ param :snapshot_id, :string, :optional
+ param :device_name, :string, :optional
+ end
+ end
+
declare_feature :instances, :sandboxing do
description "Allow lanuching sandbox images"
operation :create do
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=1101798&r1=1101797&r2=1101798&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Wed May 11 09:26:09 2011
@@ -43,6 +43,7 @@ module Deltacloud
feature :images, :owner_id
feature :buckets, :bucket_location
feature :instances, :register_to_load_balancer
+ feature :instances, :attach_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[:snapshot_id] and opts[:device_name]
+ instance_options.merge!(:block_device_mappings => [{
+ :snapshot_id => opts[: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