deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Core: Pass all query params to :index operation
Date Mon, 08 Oct 2012 11:23:40 GMT
Updated Branches:
  refs/heads/master f8542cf49 -> 25665e9b5


Core: Pass all query params to :index operation

* Fixes problem when feature with extra param is defined
  and this params is not correctly passed to the driver
  method.


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

Branch: refs/heads/master
Commit: 25665e9b5d268840f7a8c2ef1e22e05efac2fdf2
Parents: f8542cf
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Mon Oct 8 13:13:59 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Oct 8 13:16:06 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/features.rb          |    7 +++++++
 server/lib/deltacloud/drivers/mock/mock_driver.rb  |    4 +++-
 server/lib/deltacloud/helpers/deltacloud_helper.rb |   14 +++-----------
 3 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/25665e9b/server/lib/deltacloud/drivers/features.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/features.rb b/server/lib/deltacloud/drivers/features.rb
index bc8bb5b..5fc8cfd 100644
--- a/server/lib/deltacloud/drivers/features.rb
+++ b/server/lib/deltacloud/drivers/features.rb
@@ -65,6 +65,13 @@ module Deltacloud
         end
       end
 
+      feature :realm_filter, :for => :instances do
+        description "Filter instances by realm"
+        operation :index do
+          param :realm_id, :string, :optional
+        end
+      end
+
       feature :user_name, :for => :instances do
         description "Allow to set user-defined name for the instance"
         operation :create do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/25665e9b/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index e765a9f..e50d4b1 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -80,6 +80,7 @@ module Deltacloud::Drivers::Mock
     feature :instances, :user_data
     feature :instances, :authentication_key
     feature :instances, :metrics
+    feature :instances, :realm_filter
     feature :images, :user_name
     feature :images, :user_description
 
@@ -162,12 +163,13 @@ module Deltacloud::Drivers::Mock
       end
     end
 
-    def instances(credentials, opts=nil)
+    def instances(credentials, opts={})
       check_credentials( credentials )
       instances = @client.build_all(Instance)
       instances = filter_on( instances, :owner_id, :owner_id => credentials.user )
       instances = filter_on( instances, :id, opts )
       instances = filter_on( instances, :state, opts )
+      instances = filter_on( instances, :realm_id, opts)
       instances
     end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/25665e9b/server/lib/deltacloud/helpers/deltacloud_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 69d74a3..ab4a0c0 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -33,18 +33,10 @@ module Deltacloud::Helpers
     end
 
     def filter_all(model)
-      filter = {}
-      filter.merge!(:id => params[:id]) if params[:id]
-      filter.merge!(:architecture => params[:architecture]) if params[:architecture]
-      filter.merge!(:owner_id => params[:owner_id]) if params[:owner_id]
-      filter.merge!(:state => params[:state]) if params[:state]
-      filter = {} if filter.keys.size.eql?(0)
       begin
-        @benchmark = Benchmark.measure do
-          @elements = driver.send(model.to_sym, credentials, filter)
-        end
-      rescue
-        @exception = $!
+        @benchmark = Benchmark.measure { @elements = driver.send(model.to_sym, credentials,
params) }
+      rescue => e
+        @exception = e
       end
       if @elements
         headers['X-Backend-Runtime'] = @benchmark.real.to_s


Mime
View raw message