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 2013/02/18 14:41:13 UTC
[PATCH core 3/8] Core: Added possibility to define multiple features for collection
From: Michal Fojtik <mf...@redhat.com>
Instead of:
feature :collection, :name
feature :collection, :second_name
You can now use:
feature :collection, :name, :second_name, ...
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
server/lib/deltacloud/drivers/base_driver.rb | 16 +++++++++-------
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 22 +++++++++++++---------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index 4496a46..61e1989 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -39,13 +39,15 @@ module Deltacloud
@features ||= {}
end
- def self.feature(collection, feature_name)
- return if has_feature?(collection, feature_name)
- constraints[collection] ||= {}
- constraints[collection][feature_name] ||= {}
- constraints[collection][feature_name].merge!(yield) if block_given?
- features[collection] ||= []
- features[collection] << feature_name
+ def self.feature(collection, *feature_list)
+ feature_list.each do |feature_name|
+ next if has_feature?(collection, feature_name)
+ constraints[collection] ||= {}
+ constraints[collection][feature_name] ||= {}
+ constraints[collection][feature_name].merge!(yield) if block_given?
+ features[collection] ||= []
+ features[collection] << feature_name
+ end
end
def self.constraints(opts={})
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 2c86651..62c72cc 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -35,16 +35,20 @@ module Deltacloud
module Ec2
class Ec2Driver < Deltacloud::BaseDriver
- feature :instances, :user_data
- feature :instances, :authentication_key
- feature :instances, :firewalls
- feature :instances, :instance_count
- feature :instances, :metrics
- feature :images, :owner_id
- feature :images, :image_name
- feature :images, :image_description
+ feature :instances,
+ :user_data,
+ :authentication_key,
+ :firewalls,
+ :instance_count,
+ :metrics,
+ :attach_snapshot
+
+ feature :images,
+ :owner_id,
+ :image_name,
+ :image_description
+
feature :buckets, :bucket_location
- feature :instances, :attach_snapshot
DEFAULT_REGION = 'us-east-1'
--
1.8.1.2
Re: [PATCH core 3/8] Core: Added possibility to define multiple
features for collection
Posted by David Lutterkort <lu...@redhat.com>.
On Mon, 2013-02-18 at 14:41 +0100, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
> Instead of:
>
> feature :collection, :name
> feature :collection, :second_name
>
> You can now use:
>
> feature :collection, :name, :second_name, ...
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
> server/lib/deltacloud/drivers/base_driver.rb | 16 +++++++++-------
> server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 22 +++++++++++++---------
> 2 files changed, 22 insertions(+), 16 deletions(-)
ACK