class Chef::Knife::VsphereTemplateList

Lists all known VM templates in the configured datacenter VsphereTemplatelist extends the BaseVspherecommand

Public Instance Methods

run() click to toggle source

The main run method for template_list

# File lib/chef/knife/vsphere_template_list.rb, line 24
def run
  $stdout.sync = true
  $stderr.sync = true

  vim_connection

  vms = get_all_vm_objects(
    folder: get_config(:folder),
    properties: ["name", "config.template"]
  ).select { |vm| vm["config.template"] == true }

  vm_list = vms.map do |vm|
    { "Template Name" => vm["name"] }
  end

  ui.output(vm_list)
end