Class: Chef::Knife::Ec2SubnetList

Inherits:
Chef::Knife show all
Includes:
Ec2Base
Defined in:
lib/chef/knife/ec2_subnet_list.rb

Instance Method Summary collapse

Methods included from Ec2Base

#ami, #connection_string, #ec2_connection, #fetch_ami, #fetch_ec2_instance, #fetch_network_interfaces, #fetch_password_data, #fetch_region, #fetch_subnet, #find_name_tag, included, #is_image_windows?, #msg_pair, #normalize_server_data, #server_hashes, #validate_aws_config!, #vpc_mode?

Methods inherited from Chef::Knife

#aws_cred_file_location, #custom_warnings!, #find_server_platform, #iam_name_from_profile, #ini_parse

Instance Method Details

#run ⇒ Object



29
30
31
32
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
# File 'lib/chef/knife/ec2_subnet_list.rb', line 29

def run
  validate_aws_config!
  custom_warnings!

  subnet_list = [
    ui.color("ID", :bold),
    ui.color("State", :bold),
    ui.color("CIDR Block", :bold),
    ui.color("AZ", :bold),
    ui.color("Available IPs", :bold),
    ui.color("AZ Default?", :bold),
    ui.color("Maps Public IP?", :bold),
    ui.color("VPC ID", :bold),
  ].flatten.compact

  output_column_count = subnet_list.length

  if config[:format] == "summary"
    subnet_hash.each_pair do |_k, v|
      subnet_list << v["subnet_id"]
      subnet_list << v["state"]
      subnet_list << v["cidr_block"]
      subnet_list << v["availability_zone"]
      subnet_list << v["available_ip_address_count"].to_s
      subnet_list << (v["default_for_az"] ? "Yes" : "No")
      subnet_list << (v["map_public_ip_on_launch"] ? "Yes" : "No")
      subnet_list << v["vpc_id"]
    end
    puts ui.list(subnet_list, :uneven_columns_across, output_column_count)
  else
    output(format_for_display(subnet_hash))
  end
end