deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/7] CIMI: Improved 'store_attributes_for' to be more smart with properties
Date Wed, 02 Jan 2013 12:23:53 GMT
From: Michal Fojtik <mfojtik@redhat.com>

* In JSON the field is called 'properties', but in XML the XmlSimple parser
  call it 'property'. This patch will learn the store_attributes_for method
  how to deal with this.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/cimi/helpers/database_helper.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
index 090f6d8..b581c7b 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -44,7 +44,11 @@ module Deltacloud
 
         entity.description = extract_attribute_value('description', attrs) if attrs.has_key?
'description'
         entity.name = extract_attribute_value('name', attrs) if attrs.has_key? 'name'
-        entity.ent_properties = extract_attribute_value('properties', attrs).to_json if attrs.has_key?
'properties'
+        if attrs.has_key? 'properties'
+          entity.ent_properties = extract_attribute_value('properties', attrs).to_json
+        elsif attrs.has_key? 'property'
+          entity.ent_properties = extract_attribute_value('property', attrs).to_json
+        end
 
         entity.save! && entity
       end
-- 
1.8.0.2


Mime
View raw message