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/08/09 18:39:40 UTC

svn commit: r1155430 - in /incubator/deltacloud/trunk/client/lib: base_object.rb deltacloud.rb

Author: mfojtik
Date: Tue Aug  9 16:39:40 2011
New Revision: 1155430

URL: http://svn.apache.org/viewvc?rev=1155430&view=rev
Log:
Client: Added support for addresses types

Signed-off-by: Michal fojtik <mf...@redhat.com>

Modified:
    incubator/deltacloud/trunk/client/lib/base_object.rb
    incubator/deltacloud/trunk/client/lib/deltacloud.rb

Modified: incubator/deltacloud/trunk/client/lib/base_object.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/base_object.rb?rev=1155430&r1=1155429&r2=1155430&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/base_object.rb (original)
+++ incubator/deltacloud/trunk/client/lib/base_object.rb Tue Aug  9 16:39:40 2011
@@ -84,6 +84,19 @@ module DeltaCloud
       #               <address>127.0.0.1</address>
       #               <address>127.0.0.2</address>
       #             </addresses>
+      def add_addresses!(collection_name, values=[])
+        @objects << {
+          :type => :collection,
+          :method_name => collection_name.sanitize,
+          :values => values.collect { |v| { :address => v.text.strip, :type => v[:type] }}
+        }
+      end
+
+      # This method define collection of text elements inside REST model
+      # XML syntax: <addresses>
+      #               <address>127.0.0.1</address>
+      #               <address>127.0.0.2</address>
+      #             </addresses>
       def add_collection!(collection_name, values=[])
         @objects << {
           :type => :collection,

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1155430&r1=1155429&r2=1155430&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Tue Aug  9 16:39:40 2011
@@ -23,7 +23,7 @@ require 'logger'
 require 'hwp_properties'
 require 'instance_state'
 require 'documentation'
-require 'base_object'
+require 'lib/base_object'
 require 'client_bucket_methods'
 
 module DeltaCloud
@@ -225,7 +225,7 @@ module DeltaCloud
         end
 
         #deal with blob metadata
-        if(attribute.name == 'user_metadata')
+        if (attribute.name == 'user_metadata')
           meta = {}
           attribute.children.select {|x| x.name=="entry" }.each  do |element|
             value = element.content.gsub!(/(\n) +/,'')
@@ -234,6 +234,10 @@ module DeltaCloud
           obj.add_collection!(attribute.name, meta.inspect) && next
         end
 
+        if (['public_addresses', 'private_addresses'].include? attribute.name)
+          obj.add_addresses!(attribute.name, (attribute/'*')) && next
+        end
+
         # Deal with collections like public-addresses, private-addresses
         if (attribute/'./*').length > 0
           obj.add_collection!(attribute.name, (attribute/'*').collect { |value| value.text }) && next