Class: Chef::Knife::SceStorageOfferings
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::SceStorageOfferings
- Includes:
- SceBase
- Defined in:
- lib/chef/knife/sce_storage_offerings.rb
Instance Method Summary collapse
Methods included from SceBase
#connection, #connection_storage, #datacenter_id, included, #locate_config_value, #msg_pair, #validate!
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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 |