Class: Chef::Knife::AzureImageList

Inherits:
Chef::Knife show all
Includes:
AzureBase
Defined in:
lib/chef/knife/azure_image_list.rb

Instance Method Summary collapse

Methods included from AzureBase

#fetch_chef_client_logs, #fetch_deployment, #fetch_extension, #fetch_role, #fetch_substatus, #find_file, #get_azure_profile_file_path, #get_default_subscription, included, #is_image_windows?, #msg_pair, #msg_server_summary, #parse_azure_profile, #parse_publish_settings_file, #pretty_key, #service, #validate!, #validate_asm_keys!, #validate_params!

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chef/knife/azure_image_list.rb', line 37

def run
  $stdout.sync = true

  validate_asm_keys!
  items = service.list_images

  image_labels = !config[:show_all_fields] ? %w{Name OS Location} : %w{Name Category Label OS Location}
  image_list =  image_labels.map { |label| ui.color(label, :bold) }

  image_items = image_labels.map(&:downcase)
  items.each do |image|
    image_items.each { |item| image_list << image.send(item).to_s }
  end

  puts "\n"
  puts ui.list(image_list, :uneven_columns_across, !config[:show_all_fields] ? 3 : 5)
end