incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/5] Client: Added authentication method for an instance
Date Wed, 03 Aug 2011 12:20:40 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 client/lib/base_object.rb |   15 +++++++++++++++
 client/lib/deltacloud.rb  |    4 ++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/client/lib/base_object.rb b/client/lib/base_object.rb
index 8aec05b..22a0865 100644
--- a/client/lib/base_object.rb
+++ b/client/lib/base_object.rb
@@ -79,6 +79,21 @@ module DeltaCloud
         }
       end
 
+      def add_authentication!(auth_type, values=[])
+        value = { :key => (values/'login/keyname').text.strip } if auth_type == 'key'
+        if auth_type == 'password'
+          value = {
+            :username => (values/'login/username').text.strip,
+            :username => (values/'login/password').text.strip
+          }
+        end
+        @objects << {
+          :type => :collection,
+          :method_name => 'authentication',
+          :values => value
+        }
+      end
+
       # This method define collection of text elements inside REST model
       # XML syntax: <addresses>
       #               <address>127.0.0.1</address>
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 70189aa..6c9c92a 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -238,6 +238,10 @@ module DeltaCloud
           obj.add_addresses!(attribute.name, (attribute/'*')) && next
         end
 
+        if ('authentication'.include? attribute.name)
+          obj.add_authentication!(attribute[:type], (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
-- 
1.7.4.1


Mime
View raw message