deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] Fixes to logic in CIMI entity_metadata from features - collects all feature params individually
Date Tue, 03 Jan 2012 16:20:23 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@redhat.com>
---
 server/lib/cimi/model/entity_metadata.rb |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/server/lib/cimi/model/entity_metadata.rb b/server/lib/cimi/model/entity_metadata.rb
index b5d692e..2611873 100644
--- a/server/lib/cimi/model/entity_metadata.rb
+++ b/server/lib/cimi/model/entity_metadata.rb
@@ -53,7 +53,7 @@ text :type_uri
   def self.metadata_from_deltacloud_features(cimi_entity, dcloud_entity, context)
       deltacloud_features = context.driver.features(dcloud_entity)
       metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
-      from_feature(cimi_entity, context, metadata_attributes)
+      from_feature(cimi_entity, context, metadata_attributes.flatten!)
   end
 
   def includes_attribute?(attribute)
@@ -63,11 +63,16 @@ text :type_uri
   private
 
   def self.attributes_from_feature(feature)
-    { :name=>(feature.name == :user_name ? :name : feature.name),
-      :type=> "xs:string",
-      :required=>(feature.operations.first.params[feature.name].type == :optional ? "false"
: "true"),
-      :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description):
feature.constraints)
-    }
+    attributes = []
+    feature.operations.first.params.each_key do |param|
+      attributes << {
+        :name=>(feature.name == :user_name ? :name : param),
+        :type=> "xs:string",
+        :required=>(feature.operations.first.params[param].type == :optional ? "false"
: "true"),
+        :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" :
feature.description): feature.constraints)
+                    }
+    end
+    attributes
   end
 
   def self.from_feature(cimi_entity, context, metadata_attributes)
-- 
1.7.6.4


Mime
View raw message