class Chef::Knife::VcVdcShow

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/vdc/vc_vdc_show.rb, line 27
def run
  $stdout.sync = true

  vdc_arg = @name_args.shift

  connection.login

  vdc = get_vdc(vdc_arg)

  header = [
      ui.color('Name', :bold),
      ui.color('ID', :bold),
      ui.color('Status', :bold),
      ui.color('IP', :bold),
  ]

  ui.msg "#{ui.color('Description:', :cyan)} #{vdc[:description]}"
  list = ["#{ui.color('vAPPS', :cyan)}", '', '', '']
  list << header
  list.flatten!
  sort_by_key(vdc[:vapps]).each do |k, v|
    vapp = connection.get_vapp v
    list << ("#{k} (#{vapp[:vms_hash].count} VMs)" || '')
    list << (v || '')
    list << (vapp[:status] || '')
    list << (vapp[:ip] || '')
  end

  ui.msg ui.list(list, :columns_across, 4)
  connection.logout
end