incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962286 - /incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
Date Thu, 08 Jul 2010 23:43:27 GMT
Author: lutter
Date: Thu Jul  8 23:43:26 2010
New Revision: 962286

URL: http://svn.apache.org/viewvc?rev=962286&view=rev
Log:
* hardware_profile_helper (format_hardware_property): add in unit

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb?rev=962286&r1=962285&r2=962286&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb Thu
Jul  8 23:43:26 2010
@@ -2,14 +2,21 @@ module HardwareProfilesHelper
 
   def format_hardware_property(prop)
     return "∅" unless prop
+    u = hardware_property_unit(prop)
     case prop.kind
       when :range
-      "#{prop.first} - #{prop.last} (default: #{prop.default})"
+      "#{prop.first} #{u} - #{prop.last} #{u} (default: #{prop.default} #{u})"
       when :enum
-      prop.values.join(', ') + " (default: #{prop.default})"
+      prop.values.collect{ |v| "#{v} #{u}"}.join(', ') + " (default: #{prop.default} #{u})"
       else
-        prop.value.to_s
+      "#{prop.value} #{u}"
     end
   end
 
+  def hardware_property_unit(prop)
+    u = prop.unit
+    u = "" if ["label", "count"].include?(u)
+    u = "vcpus" if prop.name == :cpu
+    u
+  end
 end



Mime
View raw message