class Chef::Knife::VsphereVmToolsconfig
Vspherevmtoolsconfig extends the BaseVspherecommand
Public Instance Methods
run()
click to toggle source
The main run method for vm_toolsconfig
# File lib/chef/knife/vsphere_vm_toolsconfig.rb, line 28 def run $stdout.sync = true vmname = @name_args[0] if vmname.nil? show_usage fatal_exit("You must specify a virtual machine name") end property = @name_args[1] if property.nil? show_usage fatal_exit("You must specify a property to modify") end value = @name_args[2] if value.nil? && !get_config(:empty) show_usage fatal_exit("You must specify a value") end value = "" if get_config(:empty) vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}") vm_config_spec = RbVmomi::VIM.VirtualMachineConfigSpec(tools: RbVmomi::VIM.ToolsConfigInfo(property => value)) vm.ReconfigVM_Task(spec: vm_config_spec) puts "property #{property} updated successfully" end