class Chef::Knife::VsphereVmVncset
Main class VsphereVMvncset extends the BaseVspherecommand
Public Instance Methods
run()
click to toggle source
The main run method for vm_vnc_set
# File lib/chef/knife/vsphere_vm_vnc_set.rb, line 32 def run $stdout.sync = true vmname = @name_args[0] if vmname.nil? show_usage fatal_exit("You must specify a virtual machine name") end vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}") extra_config, = vm.collect("config.extraConfig") vm.ReconfigVM_Task( spec: { extraConfig: [ { key: "RemoteDisplay.vnc.enabled", value: "true" }, { key: "RemoteDisplay.vnc.port", value: config[:vnc_port].to_s }, { key: "RemoteDisplay.vnc.password", value: config[:vnc_password].to_s }, ], } ).wait_for_completion puts extra_config.detect { |x| "RemoteDisplay.vnc.enabled".casecmp(x.key) && "true".casecmp(x.value.downcase) } end