You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/05/09 13:34:41 UTC
Attaching EBS snapshot to instance support
Hi,
this patch will add support for attaching a EBS snapshot to instance
on creation time.
This is done by feature called 'attach_ebs_snapshot'. Feature add two
additional params 'ebs_snapshot_id' and 'device_name'.
NOTE: For this you need an 'aws' gem version > 2.5.1
-- Michal
Re: [PATCH core 1/2] Attaching EBS snapshot to instance upon
creation time
Posted by David Lutterkort <lu...@redhat.com>.
On Tue, 2011-05-10 at 11:46 +0200, Michal Fojtik wrote:
> On May 10, 2011, at 1:39 AM, David Lutterkort wrote:
>
> Hi,
>
> > Additionally, this only exposes a small part of the EC2
> > BlockDeviceMapping feature; we don't need to expose everything right
> > now, but how will we evolve the API to support things like mapping
> > multiple volumes ?
>
> Yes, the question is how we will do that :-) Right now there are several
> things using '.n' convention to perform 'multiple' operations.
>
> I'm thinking of using 'matrix' params to handle this, but dunno how these
> params should be exposed through API (or defined Rabbit). Maybe something
> like:
>
> param :device_mappings, :array, :optional
>
> What do you think?
Maybe with this, we're at the point where we need to go beyond simple
request parameters, and make POST /api/instances accept an XML body that
describes the instance; with that, there'd be enough flexibility to
accept a list of BlockDeviceMappings.
It just seems wrong to encode data structures in request params.
David
Re: [PATCH core 1/2] Attaching EBS snapshot to instance upon creation time
Posted by Michal Fojtik <mf...@redhat.com>.
On May 10, 2011, at 1:39 AM, David Lutterkort wrote:
Hi,
> Additionally, this only exposes a small part of the EC2
> BlockDeviceMapping feature; we don't need to expose everything right
> now, but how will we evolve the API to support things like mapping
> multiple volumes ?
Yes, the question is how we will do that :-) Right now there are several
things using '.n' convention to perform 'multiple' operations.
I'm thinking of using 'matrix' params to handle this, but dunno how these
params should be exposed through API (or defined Rabbit). Maybe something
like:
param :device_mappings, :array, :optional
What do you think?
-- Michal
------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
Re: [PATCH core 1/2] Attaching EBS snapshot to instance upon
creation time
Posted by David Lutterkort <lu...@redhat.com>.
On Mon, 2011-05-09 at 13:34 +0200, mfojtik@redhat.com wrote:
> 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"
Cut & paste error ? ;)
> + operation :create do
> + param :ebs_snapshot_id, :string, :optional
> + param :device_name, :string, :optional
> + end
> + end
Can we drop the 'ebs' from the parameter (and feature) name ? I would
hope that other clouds would provide this functionality in a very
similar way ;)
Additionally, this only exposes a small part of the EC2
BlockDeviceMapping feature; we don't need to expose everything right
now, but how will we evolve the API to support things like mapping
multiple volumes ?
David
[PATCH core 1/2] Attaching EBS snapshot to instance upon creation time
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
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
[PATCH core 2/2] Attaching EBS snapshot support for client
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
client/lib/deltacloud.rb | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index e2db0ba..26ed9ae 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -294,6 +294,13 @@ module DeltaCloud
params[:hwp_id] ||= params[:hardware_profile]
end
+ if args[:ebs_snapshot_id] and args[:device_name]
+ params.merge!({
+ :ebs_snapshot_id => args[:ebs_snapshot_id],
+ :device_name => args[:device_name]
+ })
+ end
+
params[:image_id] ||= params[:image_id] || args[0] if args[0].class!=Hash
obj = nil
--
1.7.4.1