Class: Chef::Knife::OvhPccTemplateList

Inherits:
Chef::Knife show all
Includes:
OvhBase
Defined in:
lib/chef/knife/ovh_pcc_template_list.rb

Instance Method Summary collapse

Methods included from OvhBase

#fatal_exit, #find_all_in_folders, #find_in_folders, #get_folders, #get_vim_connection, included

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chef/knife/ovh_pcc_template_list.rb', line 17

def run
  
  $stdout.sync = true
  $stderr.sync = true
  
  vim = get_vim_connection
  
  dcname = config[:vsphere_dc] || Chef::Config[:knife][:vsphere_dc]
  dc = vim.serviceInstance.find_datacenter(dcname) or abort "datacenter not found"
  
  vmFolders = get_folders(dc.vmFolder)
  
  vms = find_all_in_folders(dc.vmFolder, RbVmomi::VIM::VirtualMachine).
  select {|v| !v.config.nil? && v.config.template == true }
  
  vms.each do |vm|
      puts "#{ui.color("Template Name", :cyan)}: #{vm.name}"
  end

end