deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: CIMI: Fixed undefined 'default_frontend' error in CIMI tests
Date Tue, 12 Feb 2013 11:10:38 GMT
Updated Branches:
  refs/heads/master fdbdb7cde -> 573bb7da2


CIMI: Fixed undefined 'default_frontend' error in CIMI tests

In case when db/provider model is accessed outside the Deltacloud
server context (CIMI tests, CIMI client, etc...) the
Deltacloud.default_frontend method is not set, because 'deltacloud_rack'
is not required.

This patch will add 'fallback' mode where if you use this model outside
server context, we try to get the default driver in same way as we
get the provider value.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/573bb7da
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/573bb7da
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/573bb7da

Branch: refs/heads/master
Commit: 573bb7da2df6ad43a31dfc3f8f3ff43219687e14
Parents: fdbdb7c
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Feb 12 11:01:59 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Feb 12 12:10:21 2013 +0100

----------------------------------------------------------------------
 server/lib/db/provider.rb |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/573bb7da/server/lib/db/provider.rb
----------------------------------------------------------------------
diff --git a/server/lib/db/provider.rb b/server/lib/db/provider.rb
index ee3e138..59c90ec 100644
--- a/server/lib/db/provider.rb
+++ b/server/lib/db/provider.rb
@@ -15,7 +15,22 @@ module Deltacloud
       # Find the DB provider set in the environment/request
       def self.lookup
         prov = Thread.current[:provider] || ENV['API_PROVIDER'] || 'default'
-        find_or_create(:driver => self.driver_symbol.to_s, :url => prov)
+        find_or_create(:driver => current_driver_name, :url => prov)
+      end
+
+      private
+
+      # In case this model is used outside the Deltacloud server (CIMI tests, CIMI
+      # client, etc), the 'Deltacloud.default_frontend' is not initialized.
+      # In that case we have to use the 'fallback' way to retrieve current
+      # driver name.
+      #
+      def self.current_driver_name
+        if Deltacloud.respond_to?(:default_frontend)
+          self.driver_symbol.to_s
+        else
+          Thread.current[:driver] || ENV['API_DRIVER'] || 'mock'
+        end
       end
     end
 


Mime
View raw message