You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/02/23 14:56:02 UTC

[PATCH core 6/7] CIMI: Added support for X-Deltacloud-Provider and Driver to client

From: Michal Fojtik <mf...@redhat.com>

With this patch, client should be able to change default
CIMI driver. In addition this change will make API_PROVIDER
change possible.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 clients/cimi/lib/client.rb |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/clients/cimi/lib/client.rb b/clients/cimi/lib/client.rb
index 3b8bc34..0fd85e4 100644
--- a/clients/cimi/lib/client.rb
+++ b/clients/cimi/lib/client.rb
@@ -41,9 +41,17 @@ module CIMI
         client["%s/%s/%s" % [entity_type, id, action.to_s]].post(body, auth_header(credentials))
       end
 
+      def provider_header(credentials)
+        return Hash.new unless credentials.driver
+        {
+          :'X-Deltacloud-Driver' => credentials.driver,
+          :'X-Deltacloud-Provider' => credentials.provider
+        }
+      end
+
       def auth_header(credentials)
         encoded_credentials = ["#{credentials.user}:#{credentials.password}"].pack("m0").gsub(/\n/,'')
-        { :authorization => "Basic " + encoded_credentials }
+        { :authorization => "Basic " + encoded_credentials }.merge(provider_header(credentials))
       end
 
     end
-- 
1.7.9.1