Class: Chef::Knife::VcCatalogItemShow

Inherits:
Chef::Knife show all
Includes:
VcCatalogCommon, VcCommon
Defined in:
lib/chef/knife/catalog/vc_catalog_item_show.rb

Instance Method Summary collapse

Methods included from VcCatalogCommon

#get_catalog, #get_catalog_item, included

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
# File 'lib/chef/knife/catalog/vc_catalog_item_show.rb', line 27

def run
  $stdout.sync = true

  item_arg = @name_args.first

  connection.
  catalog_item = get_catalog_item(item_arg)
  connection.logout

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

  ui.msg "#{ui.color('Description:', :cyan)} #{catalog_item[:description]}"
  list = header
  list.flatten!

  catalog_item[:items].each do |item|
    list << (item[:name] || '')
    list << (item[:id] || '')
    # TODO: show VMs using this item? item[:vms_hash]
  end

  ui.msg ui.list(list, :columns_across, 2)
end