You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2012/05/21 10:32:31 UTC

git commit: Adds ordering of hardware profiles returned from the Provider. Ordering is first by cpu and then by memory. Addresses JIRA DTACLOUD_208

Updated Branches:
  refs/heads/master 862c7cbe3 -> ef31a07e4


Adds ordering of hardware profiles returned from the Provider. Ordering is
first by cpu and then by memory. Addresses JIRA DTACLOUD_208

https://issues.apache.org/jira/browse/DTACLOUD-208


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

Branch: refs/heads/master
Commit: ef31a07e467ffae110b1c1d68580a88cdad8d6ce
Parents: 862c7cb
Author: marios <ma...@redhat.com>
Authored: Thu May 17 15:44:30 2012 +0300
Committer: marios <ma...@redhat.com>
Committed: Mon May 21 11:31:07 2012 +0300

----------------------------------------------------------------------
 .../deltacloud/helpers/hardware_profiles_helper.rb |   12 ++++++++++++
 server/lib/deltacloud/server.rb                    |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ef31a07e/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers/hardware_profiles_helper.rb b/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
index af2100e..862d680 100644
--- a/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
+++ b/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
@@ -40,7 +40,19 @@ module HardwareProfilesHelper
     end
   end
 
+  #first by cpu - then by memory
+  def order_hardware_profiles(profiles)
+   #have to deal with opaque hardware profiles
+   uncomparables = profiles.select{|x| x.cpu.nil? or x.memory.nil? }
+   if uncomparables.empty?
+      profiles.sort_by{|a| [a.cpu.default, a.memory.default] }
+   else
+      (profiles - uncomparables).sort_by{|a| [a.cpu.default, a.memory.default] } + uncomparables
+   end
+  end
+
   private
+
   def hardware_property_unit(prop)
     u = ::Deltacloud::HardwareProfile::unit(prop)
     u = "" if ["label", "count"].include?(u)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ef31a07e/server/lib/deltacloud/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
index 46b4d25..bb40bcc 100644
--- a/server/lib/deltacloud/server.rb
+++ b/server/lib/deltacloud/server.rb
@@ -590,6 +590,7 @@ END
     param :architecture,  :string,  :optional,  [ 'i386', 'x86_64' ]
     control do
         @profiles = driver.hardware_profiles(credentials, params)
+        @profiles = order_hardware_profiles(@profiles)
         respond_to do |format|
           format.xml  { haml :'hardware_profiles/index' }
           format.html  { haml :'hardware_profiles/index' }