deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [8/50] [abbrv] git commit: Adds ordering of hardware profiles returned from the Provider. Ordering is first by cpu and then by memory. Addresses JIRA DTACLOUD_208 Note: This patch was backported from non-modular
Date Tue, 22 May 2012 20:19:37 GMT
Adds ordering of hardware profiles returned from the Provider. Ordering is
first by cpu and then by memory. Addresses JIRA DTACLOUD_208
Note: This patch was backported from non-modular

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/bcc98a21
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/bcc98a21
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/bcc98a21

Branch: refs/heads/master
Commit: bcc98a21c596a6a21ef0c51bea3199b9cc2d3852
Parents: 1a66cee
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Mon May 21 11:41:58 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue May 22 22:17:39 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/helpers/deltacloud_helper.rb |   11 +++++++++++
 server/views/hardware_profiles/index.html.haml     |    2 +-
 server/views/hardware_profiles/index.xml.haml      |    2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/bcc98a21/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 ed3e57d..5806d15 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -266,6 +266,17 @@ module Deltacloud::Helpers
       end
     end
 
+    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)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/bcc98a21/server/views/hardware_profiles/index.html.haml
----------------------------------------------------------------------
diff --git a/server/views/hardware_profiles/index.html.haml b/server/views/hardware_profiles/index.html.haml
index 59d43eb..011e80f 100644
--- a/server/views/hardware_profiles/index.html.haml
+++ b/server/views/hardware_profiles/index.html.haml
@@ -3,7 +3,7 @@
 
 %div{ :'data-role' => :content, :'data-theme' => 'c'}
   %ul{ :'data-role' => :listview, :'data-inset' => :true }
-    - for profile in @hardware_profiles
+    - for profile in order_hardware_profiles(@hardware_profiles)
       %li{ :'data-theme' => 'c'}
         %a{ :href => hardware_profile_url(profile.name)}
           %img{ :class => 'ui-link-thumb', :src => '/images/profile.png'}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/bcc98a21/server/views/hardware_profiles/index.xml.haml
----------------------------------------------------------------------
diff --git a/server/views/hardware_profiles/index.xml.haml b/server/views/hardware_profiles/index.xml.haml
index 25e0496..9292c5b 100644
--- a/server/views/hardware_profiles/index.xml.haml
+++ b/server/views/hardware_profiles/index.xml.haml
@@ -1,4 +1,4 @@
 !!! XML
 %hardware_profiles
-  - @hardware_profiles.each do |prof|
+  - order_hardware_profiles(@hardware_profiles).each do |prof|
     = haml :'hardware_profiles/show', :locals => { :@hardware_profile => prof, :partial
=> true }


Mime
View raw message