From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- 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
