Sha256: bf08560031a38f5210311954c87521aaa121fff5a04144b5748fe16894c0cbfb

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'chef/knife/joyent_base'

class Chef
  class Knife
    class JoyentServerPricing < Knife

      include Knife::JoyentBase

      option :reserve_pricing,
             :short => '-r <file>',
             :long => '--reserve-pricing <file>',
             :description => 'Apply reserve discounts from a YAML config (see joyent-cloud-pricing gem)',
             :proc => Proc.new { |key| Chef::Config[:knife][:reserve_pricing] = key }

      option :show_zones,
             :short => '-z',
             :long => '--show-zones',
             :description => 'Print list of on-demand zones sorted by price',
             :proc => Proc.new { |key| Chef::Config[:knife][:show_zones] = key }

      banner 'knife joyent server pricing [-r <reserve-pricing.yml> ] [ -z ] '

      def run
        flavors = []
        self.connection.servers.each do |s|
          flavor = s.package || 'unknown'
          flavors << flavor
        end
        reporter = Joyent::Cloud::Pricing::Reporter.new(Chef::Config[:knife][:reserve_pricing], flavors)
        reporter.print_zone_list = Chef::Config[:knife][:show_zones]
        puts reporter.render
      rescue => e
        output_error(e)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-joyent-0.4.9 lib/chef/knife/joyent_server_pricing.rb