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 2011/01/07 11:27:54 UTC

[PATCH core] Added use_config! and changed initializer to use Hash options

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

---
 client/lib/deltacloud.rb |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 6985d5c..e8d6375 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -34,9 +34,15 @@ module DeltaCloud
   # @param [String, password] API password
   # @param [String, user_name] API URL (eg. http://localhost:3001/api)
   # @return [DeltaCloud::API]
-  def self.new(user_name, password, api_url, opts={}, &block)
-    opts ||= {}
-    API.new(user_name, password, api_url, opts, &block)
+  #def self.new(user_name, password, api_url, opts={}, &block)
+  #  opts ||= {}
+  #  API.new(user_name, password, api_url, opts, &block)
+  #end
+
+  def self.new(opts={}, &block)
+    opts ||={}
+    client = API.new(opts[:username], opts[:password], opts[:url], opts, &block)
+    client.use_driver(opts[:driver], opts) if opts[:driver]
   end
 
   # Check given credentials if their are valid against
@@ -256,6 +262,11 @@ module DeltaCloud
       return self
     end
 
+    def use_config!(opts={})
+      @api_uri = URI.parse(opts[:url]) if opts[:url]
+      use_driver(opts[:driver], opts)
+    end
+
     def extended_headers
       headers = {}
       headers["X-Deltacloud-Driver"] = @api_driver.to_s if @api_driver
-- 
1.7.3.4