VMware {code} Community
Chewie71
Contributor
Contributor

How to Get and Set VM Network "Connect at power on" Setting?

I'm working on some automation scripting and need to be able to get/set the "connect at power on" setting of the network adapter of a newly cloned vm.  I am new to the SDK.  Can someone point me in the right direction?

Thanks,

Matt

Reply
0 Kudos
2 Replies
BenN
Enthusiast
Enthusiast

See the 'startConnected' property of VirtualDeviceConnectInfo:

  http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.vm.device....

The VM devices can be read from VirtualMachine.config -> VirtualMachineConfigInfo.hardware -> VirtualHardware.devices.

One or more of those VirtualDevice objects will be of a subtype of type VirtualEthernetCard. The 'connectable' property points to the VirtualDeviceConnectInfo.

Chewie71
Contributor
Contributor

I worked on my solution last night and finally found some code examples that got me going in the right direction.  I solved the problem in this question but it didn't fix my issue.  After cloning a template, the VM's NIC is not connected, and attempting to select "Connect at power on" from the GUI or from my first program threw an error.

What I ended up doing was removing then re-adding the NIC.  I'm using the RbVmomi Ruby library for this and here's the link to a snippet of the code I used to do this.

https://gist.github.com/4235695

Thanks,

Matt

Reply
0 Kudos