Sha256: 37a135ff7232ff89dba0bf79d7dd3e7c385748dfde4b3be3e30892623431424a

Contents?: true

Size: 963 Bytes

Versions: 5

Compression:

Stored size: 963 Bytes

Contents

require 'chef/knife/joyent_base'

class Chef
  class Knife
    class JoyentFlavorList < Knife

      include Knife::JoyentBase

      banner "knife joyent flavor list <options>"

      def run
        flavor_list = [
          ui.color('Name', :bold),
          ui.color('      RAM', :bold),
          ui.color('     Disk', :bold),
          ui.color('    Swap', :bold),
          ui.color('$ Per Month', :bold),
        ]

        self.connection.flavors.sort_by(&:memory).each do |flavor|
          flavor_list << flavor.name.to_s
          flavor_list << "#{sprintf "%6.2f", flavor.memory/1024.0} GB"
          flavor_list << "#{sprintf "%6.0f", flavor.disk/1024.0} GB"
          flavor_list << "#{sprintf "%5.0f", flavor.swap/1024.0} GB"
          flavor_list << pricing.format_monthly_price(flavor.name.to_s, 10)
        end

        puts ui.list(flavor_list, :uneven_columns_across, 5)
      rescue => e
        output_error(e)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
knife-joyent-0.4.14 lib/chef/knife/joyent_flavor_list.rb
knife-joyent-0.4.12 lib/chef/knife/joyent_flavor_list.rb
knife-joyent-0.4.11 lib/chef/knife/joyent_flavor_list.rb
knife-joyent-0.4.10 lib/chef/knife/joyent_flavor_list.rb
knife-joyent-0.4.9 lib/chef/knife/joyent_flavor_list.rb