Search code examples
perlvirtual-machinevsphere

Enabling VNC port on a VM using perl script


How do I enable vnc port and assign RemoteDisplay.vnc.password, RemoteDisplay.vnc.port parameters on a VM using a perl script?

VMWare provided some sample perl scripts with vSphere Perl SDK, which gives the option to customize the VM or the guest while creating or cloning the virtual machine, using configuration specification file. I tried specifying the values in configuration specification file, but that doesn't support these VNC configuration parameters.

Where do I start? Is there any function VMware provides that I could use?


Solution

  • I found the answer to my question here . I could get the configuration parameters as key value pair from the user and update those settings.

    my $option = OptionValue->new(key => $key, value => $value);
    $vmSpec = VirtualMachineConfigSpec->new(extraConfig => [$option]);
    $task = $vm->ReconfigVM_Task(spec => $vmSpec);