Class: Chef::Knife::OvhPccVmList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::OvhPccVmList
- Includes:
- OvhBase
- Defined in:
- lib/chef/knife/ovh_pcc_vm_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
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/knife/ovh_pcc_vm_list.rb', line 22 def run $stdout.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" baseFolder = dc.vmFolder; if config[:folder] baseFolder = get_folders(dc.vmFolder).find { |f| f.name == config[:folder]} or abort "no such folder #{config[:folder]}" end vms = find_all_in_folders(baseFolder, RbVmomi::VIM::VirtualMachine) vms.each do |vm| puts "#{ui.color("VM Name", :cyan)}: #{vm.name}" end end |