VMware {code} Community
3axap
Contributor
Contributor
Jump to solution

vmrun to change a host VM's network adapter connection settings

Hello!

I have a vSphere vCenter VM running Windows 2008 R2 that is hosting many VMs of varying OSs on several different network VLANs (100, 200, 300, etc). I would like to be able to run a command from a guest VM running Red Hat Enterprise Linux 6.5 to tell vCenter to switch the network adapter settings from one VLAN to another and back again. I have done a lot of investigating, but I have been unable to figure out a way to do it. The closest thing I have found to what I am looking for are the commands below, but they are not working.

vmrun -T vc -h 192.168.0.3 -P443 -gu <guestusername> -gp <guestpassword> readVariable "[Datastore Name] RHEL 6.5/RHEL 6.5.vmx" runtimeConfig ethernet0.vnet /dev/vmnet0

vmrun -T vc -h 192.168.0.3 -P443 -gu <guestusername> -gp <guestpassword> writeVariable "[Datastore Name] RHEL 6.5/RHEL 6.5.vmx" runtimeConfig ethernet0.vnet /dev/vmnet1

The readVariable command appears to execute successfully, but produces 0 bytes of data, and the writeVariable command gives an error stating that the operation is not supported. Is vmrun able to perform a switch between a VM's network connections or am I going to need to use a different approach? The reason I need to have a command to run instead of simply going into the guest VM's setting in vCenter and selecting the custom network from the drop down is so that the development and testing team can execute a script at will instead of being given administrative privileges.

Reply
0 Kudos
1 Solution

Accepted Solutions
lemke
VMware Employee
VMware Employee
Jump to solution

vmrun (and VIX) won't let you do what you're trying to do.  Nothing is paying attention to those variables being changed.  You'll need to use an API that reconfigures the VM's networking, which probably means writing some code using a vSphere API.

View solution in original post

Reply
0 Kudos
2 Replies
lemke
VMware Employee
VMware Employee
Jump to solution

vmrun (and VIX) won't let you do what you're trying to do.  Nothing is paying attention to those variables being changed.  You'll need to use an API that reconfigures the VM's networking, which probably means writing some code using a vSphere API.

Reply
0 Kudos
3axap
Contributor
Contributor
Jump to solution

Well, at least that answers my question. Thank you so much for your help!

Reply
0 Kudos