class Chef::Knife::SceStorageOfferings
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/sce_storage_offerings.rb, line 33 def run $stdout.sync = true validate! offer_list = [ ui.color('Offering ID', :bold), ui.color("Name", :bold), ui.color("Label", :bold), ui.color("Location", :bold), ui.color('Supported sizes', :bold), ui.color('Supported formats', :bold), ui.color('Price', :bold) ].flatten.compact output_column_count = offer_list.length connection_storage.offerings.all.each do |offer| formats = [] offer.supported_formats.each do |format| formats << format["id"] end sizes = offer.supported_sizes.split(",") did = datacenter_id if did.nil? or did.eql?( offer.location ) offer_list << offer.id.to_s offer_list << offer.name.to_s offer_list << offer.label.to_s offer_list << connection.locations.get(offer.location).name offer_list << "#{sizes[0].to_s}GB" offer_list << formats.join(", ") offer_list << "#{offer.price['rate']}#{offer.price['currencyCode']}/#{offer.price['pricePerQuantity']}#{offer.price['unitOfMeasure']}" (1...sizes.length).each do |index| offer_list << " " offer_list << " " offer_list << " " offer_list << " " offer_list << "#{sizes[index].to_s}GB" offer_list << " " offer_list << " " end end end puts "\n" puts ui.list(offer_list, :uneven_columns_across, output_column_count) end