Class: Chef::Knife::Cloud::GoogleServerList

Inherits:
ServerListCommand
  • Object
show all
Includes:
GoogleServiceOptions
Defined in:
lib/chef/knife/google_server_list.rb

Instance Method Summary collapse

Methods included from GoogleServiceOptions

included

Instance Method Details

#before_exec_commandObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chef/knife/google_server_list.rb', line 42

def before_exec_command
  @columns_with_info = [
    { label: "Instance Name", key: "name" },
    { label: "Status",        key: "status", value_callback: method(:format_status_value) },
    { label: "Machine Type",  key: "machine_type" },
    { label: "Internal IP",   key: "private_ip" },
    { label: "External IP",   key: "public_ip" },
    { label: "Network",       key: "network" },
  ]

  @sort_by_field = "name"
end

#format_status_value(status) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/chef/knife/google_server_list.rb', line 55

def format_status_value(status)
  status = status.downcase
  status_color = case status
                 when "stopping", "stopped", "terminated"
                   :red
                 when "requested", "provisioning", "staging"
                   :yellow
                 else
                   :green
                 end

  ui.color(status, status_color)
end

#validate_params!Object



37
38
39
40
# File 'lib/chef/knife/google_server_list.rb', line 37

def validate_params!
  check_for_missing_config_values!(:gce_zone)
  super
end