Hi all,
One of our ESX servers' VSwitch is configured with multiple VLANs and I have a requirement for programmatically (command line) changing the network that a Virtual Machine is connected too.
Does anyone know how to do this?
Thanks,
Darin
You can either manually edit the VM(s) .vmx configuration file and use vimsh wrapper vmware-vim-cmd to refresh the VM(s) configuration:
[root@himalaya root]# vmware-vim-cmd vmsvc/reload Insufficient arguments. Usage: reload vmid Reload the virtual machine state from afresh.
The VM unfortunately needs to be powered off I think for this to work.
If you need to do it while the VM is running, you'll want to take a look at the VI API and look into the ReconfigVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#re...
This is also implemented in the VI Perl Toolkit Utilities as a script: http://www.vmware.com/support/developer/viperltoolkit/viperl15/doc/perl_toolkit_utilities_idx.html and you can look at the script called vmreconfig.pl http://www.vmware.com/support/developer/viperltoolkit/viperl15/doc/vmreconfig.html
The VIPT is to be executed on either a Windows/Linux or on VMware VIMA/vMA and not on the Service Console of classic ESX
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".
You can either manually edit the VM(s) .vmx configuration file and use vimsh wrapper vmware-vim-cmd to refresh the VM(s) configuration:
[root@himalaya root]# vmware-vim-cmd vmsvc/reload Insufficient arguments. Usage: reload vmid Reload the virtual machine state from afresh.
The VM unfortunately needs to be powered off I think for this to work.
If you need to do it while the VM is running, you'll want to take a look at the VI API and look into the ReconfigVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#re...
This is also implemented in the VI Perl Toolkit Utilities as a script: http://www.vmware.com/support/developer/viperltoolkit/viperl15/doc/perl_toolkit_utilities_idx.html and you can look at the script called vmreconfig.pl http://www.vmware.com/support/developer/viperltoolkit/viperl15/doc/vmreconfig.html
The VIPT is to be executed on either a Windows/Linux or on VMware VIMA/vMA and not on the Service Console of classic ESX
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".
This can also easlily be done through the VI Toolkit (Powershell)
Check the VI Toolkit for more info:
http://communities.vmware.com/community/developer/windows_toolkit?view=discussions
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Ok, thanks for the replies.
I have the Perl VI toolkit installed and can run vmreconfig.pl but I'm really stumped as to what I need to give it?!
Do I always need to provide an XML file or are there a bunch of command like arguments I can throw at it?
There doesn't seem to be very many examples so I'm a bit stumped.
Thanks,
Darin
You do need to provide it the xml spec on the configurations you would like to change each time, but you can also modify the script to just perform a network interface update but in general the script provides you a way of modifying some of the basic params w/VM
Update: You can take a look at this thread on how to just create a script that updates the network: http://communities.vmware.com/message/1210967#1210967
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".