incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: Possible bug in filter of hardware_profiles
Date Wed, 16 Mar 2011 23:21:43 GMT
On Wed, 2011-03-16 at 12:23 -0300, Felipe Cardoso Martins wrote:
> David,
> 
> reading the source I understand the problem, look the source
> "deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb"
> 
>     def filter_hardware_profiles(profiles, opts)
>       if opts
>         if v = opts[:architecture]
>           profiles = profiles.select { |hwp| hwp.include?(:architecture, v) }
>         end
>         if v = opts[:name]
>           profiles = profiles.select { |hwp| hwp.name == v }
>         end
>       end
>       profiles
>     end
> 
> What is wrong, source or documentation?

The source - we advertise that you can filter by id in the API, so we
need to make sure that's what the code does. The patch below fixes that.
Unfortunately, I can't get all the tests to run (client tests segfault,
and feature tests abort rake, not sure yet what's happening there)

David

>From ba2e74cba6d6eb0b981f3b799406b111b938858c Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter@redhat.com>
Date: Wed, 16 Mar 2011 16:13:42 -0700
Subject: [PATCH] Make filtering of HWP by id work

---
 server/lib/deltacloud/base_driver/base_driver.rb |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/base_driver.rb b/server/lib/deltacloud/base_driver/base_driver.rb
index 2442385..77257ee 100644
--- a/server/lib/deltacloud/base_driver/base_driver.rb
+++ b/server/lib/deltacloud/base_driver/base_driver.rb
@@ -68,7 +68,7 @@ module Deltacloud
     end
 
     def hardware_profile(credentials, name)
-      hardware_profiles(credentials, :name => name).first
+      hardware_profiles(credentials, :id => name).first
     end
 
     def filter_hardware_profiles(profiles, opts)
@@ -76,7 +76,8 @@ module Deltacloud
         if v = opts[:architecture]
           profiles = profiles.select { |hwp| hwp.include?(:architecture, v) }
         end
-        if v = opts[:name]
+        # As a request param, we call 'name' 'id'
+        if v = opts[:id]
           profiles = profiles.select { |hwp| hwp.name == v }
         end
       end
@@ -86,7 +87,7 @@ module Deltacloud
     def find_hardware_profile(credentials, name, image_id)
       hwp = nil
       if name
-        unless hwp = hardware_profiles(credentials, :name => name).first
+        unless hwp = hardware_profiles(credentials, :id => name).first
           raise BackendError.new(400, "bad-hardware-profile-name",
             "Hardware profile '#{name}' does not exist", nil)
         end
-- 
1.7.4




Mime
View raw message