Sha256: 253200ac58c532a54a9fda4ac8a4a452806b5b39d23c92e7adc07e588680cd03

Contents?: true

Size: 824 Bytes

Versions: 27

Compression:

Stored size: 824 Bytes

Contents

module HardwareProfilesHelper

  def format_hardware_property(prop)
    return "∅" unless prop
    u = hardware_property_unit(prop)
    case prop.kind
      when :range
      "#{prop.first} #{u} - #{prop.last} #{u} (default: #{prop.default} #{u})"
      when :enum
      prop.values.collect{ |v| "#{v} #{u}"}.join(', ') + " (default: #{prop.default} #{u})"
      else
      "#{prop.value} #{u}"
    end
  end

  def format_instance_profile(ip)
    o = ip.overrides.collect do |p, v|
      u = hardware_property_unit(p)
      "#{p} = #{v} #{u}"
    end
    if o.empty?
      ""
    else
      "with #{o.join(", ")}"
    end
  end

  private
  def hardware_property_unit(prop)
    u = ::Deltacloud::HardwareProfile::unit(prop)
    u = "" if ["label", "count"].include?(u)
    u = "vcpus" if prop == :cpu
    u
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
steamcannon-deltacloud-core-0.1.1.3 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.1.1.2 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.1.1.1 lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.1.1 lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.1.0 lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.0.9 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.8.1-java lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.8.1 lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.0.8 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.7.2 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.7.2-java lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.7.1 lib/deltacloud/helpers/hardware_profiles_helper.rb
steamcannon-deltacloud-core-0.0.7.1-java lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.0.7 lib/deltacloud/helpers/hardware_profiles_helper.rb
bbrowning-deltacloud-core-0.0.6.1-java lib/deltacloud/helpers/hardware_profiles_helper.rb
bbrowning-deltacloud-core-0.0.6-java lib/deltacloud/helpers/hardware_profiles_helper.rb
bbrowning-deltacloud-core-0.0.6 lib/deltacloud/helpers/hardware_profiles_helper.rb
deltacloud-core-0.0.6 lib/deltacloud/helpers/hardware_profiles_helper.rb
bbrowning-deltacloud-core-0.0.4 lib/deltacloud/helpers/hardware_profiles_helper.rb
bbrowning-deltacloud-core-0.0.4-java lib/deltacloud/helpers/hardware_profiles_helper.rb