Return-Path: Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: (qmail 8303 invoked from network); 16 Mar 2011 23:22:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Mar 2011 23:22:12 -0000 Received: (qmail 11332 invoked by uid 500); 16 Mar 2011 23:22:12 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 11312 invoked by uid 500); 16 Mar 2011 23:22:12 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 11304 invoked by uid 99); 16 Mar 2011 23:22:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 23:22:12 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lutter@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 23:22:05 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2GNLhZS013597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Mar 2011 19:21:44 -0400 Received: from [10.3.113.31] (ovpn-113-31.phx2.redhat.com [10.3.113.31]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2GNLhVu007451 for ; Wed, 16 Mar 2011 19:21:43 -0400 Subject: Re: Possible bug in filter of hardware_profiles From: David Lutterkort To: deltacloud-dev@incubator.apache.org In-Reply-To: References: <1300234011.24760.111.camel@avon.watzmann.net> Content-Type: text/plain; charset="ISO-8859-15" Organization: Red Hat Inc Date: Wed, 16 Mar 2011 16:21:43 -0700 Message-ID: <1300317703.30990.4.camel@avon.watzmann.net> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Virus-Checked: Checked by ClamAV on apache.org 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 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