Class: Chef::Knife::VcVmShow

Inherits:
Chef::Knife show all
Includes:
VcCommon, VcVmCommon
Defined in:
lib/chef/knife/vm/vc_vm_show.rb

Instance Method Summary collapse

Methods included from VcVmCommon

#get_vm, included, #sanitize_guest_name, #stop_if_running

Methods included from VcCommon

#connection, #deprecation_msg, #generate_key, #get_password, included, #locate_config_value, #locate_org_option, #notice_msg, #out_msg, #pretty_symbol, #sort_by_key, #store_config, #store_password, #wait_task

Instance Method Details

#runObject



27
28
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/chef/knife/vm/vc_vm_show.rb', line 27

def run
  $stdout.sync = true

  vm_arg = @name_args.first

  connection.

  vm = get_vm(vm_arg)

  vm_info = connection.get_vm_info vm[:id]
  vm_disks = connection.get_vm_disk_info vm[:id]
  connection.logout

  out_msg("VM Name", vm[:vm_name])
  out_msg("OS Name", vm[:os_desc])
  out_msg("Status", vm[:status])

  list = []
  list << ['', '']
  vm_info.each do |section, values|
    list << ui.color(section.capitalize, :bold)
    list << ''

    list << (values[:description] || '')
    list << (values[:name] || '')

    list << ['', '']
  end

  list << [ui.color('Disks', :bold), '']
  vm_disks.each do |values|
    list << (values[:name] || '')
    list << (values[:capacity] || '')
  end

  list << ['', '', ui.color('Networks', :bold), '']
  vm[:networks].each do |network, values|
    list << [(network || ''), '']
    values.each do |k, v|
      list << "  #{(pretty_symbol(k) || '')}"
      list << (v || '')
    end
  end

  list << ['', '', ui.color('Guest Customizations', :bold), '']
  list.flatten!
  vm[:guest_customizations].each do |k, v|
    list << (pretty_symbol(k) || '')
    list << (v || '')
  end
  ui.msg ui.list(list, :columns_across, 2)
end