class Chef::Knife::VsphereVmConfig
VsphereVMconfig extends the BaseVspherecommand
Public Instance Methods
run()
click to toggle source
The main run method in vm_config
# File lib/chef/knife/vsphere_vm_config.rb, line 23 def run $stdout.sync = true vmname = @name_args.shift if vmname.nil? show_usage fatal_exit("You must specify a virtual machine name") end unless @name_args.length > 0 && @name_args.length.even? fatal_exit("You must specify a series of PROPERTY name (e.g. annotation) followed by a value") end vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}") properties = @name_args.each_slice(2).map { |prop, val| [prop.to_sym, val] }.to_h vm.ReconfigVM_Task(spec: RbVmomi::VIM.VirtualMachineConfigSpec(properties)).wait_for_completion end