VMware Cloud Community
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Need help with API Explorer

Hi all,

I am creating a workflow to automate some P2V tasks and i want to disconnect the NIC before doing anyting on the VMs. When everything will be done, i want to reconnect this NIC. I am playing with vCO for some months now and I need to get help with the scripting part. I always managed to find some code but this time I did not find anything!

So i need to script this part! I think i find a way to change the connection settings of the VMXNET3 NIC with this part of code :

System.getModule("com.vmware.library.vc.vm.spec.config.device").getVirtualVmxnet3(backing,connectable,controllerKey,deviceInfo,key,unitNumber,addressType,macAddress,wakeOnLanEnabled)

var connectset = new VcVirtualDeviceConnectInfo();

connectset.connected = false;

connectset.startConnected = false;

Now i need to find how to affect those settings to the VMXNET3 adapter of a VM?

How to drill down from the VM to those settings?

Thanks for your help!

Reply
0 Kudos
1 Solution

Accepted Solutions
qc4vmware
Virtuoso
Virtuoso
Jump to solution

If you are connecting to a distributed switch they have a canned action for that com.vmware.library.vc.networking.connectVmNicNumberToVirtualDistributedPortgroup .  If it isn't a vds you are connecting to then you'd need to modify then it will need to be modified slightly to use normal network card backing instead of vds.  You will also need to add these lines to the device config section:

devicespec.device.connectable = new VcVirtualDeviceConnectInfo();

devicespec.device.connectable.connected = true;

devicespec.device.connectable.startConnected = true;

I copied that action and added these 3 lines to achieve what it sounds like you are attempting to do.  We don't really use standard switches in our environment.

Paul

View solution in original post

Reply
0 Kudos
4 Replies
qc4vmware
Virtuoso
Virtuoso
Jump to solution

If you are connecting to a distributed switch they have a canned action for that com.vmware.library.vc.networking.connectVmNicNumberToVirtualDistributedPortgroup .  If it isn't a vds you are connecting to then you'd need to modify then it will need to be modified slightly to use normal network card backing instead of vds.  You will also need to add these lines to the device config section:

devicespec.device.connectable = new VcVirtualDeviceConnectInfo();

devicespec.device.connectable.connected = true;

devicespec.device.connectable.startConnected = true;

I copied that action and added these 3 lines to achieve what it sounds like you are attempting to do.  We don't really use standard switches in our environment.

Paul

Reply
0 Kudos
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Hi qc4vmware,

Thanks for the reply!

I try this but unable to have it work! Here is what i did :

System.getModule("com.vmware.library.vc.networking").connectVmNicNumberToVirtualDistributedPortgroup(vm,dvProtgroup,number);

devicespec.device.connectable = new VcVirtualDeviceConnectInfo();

devicespec.device.connectable.connected = false;

devicespec.device.connectable.startConnected = false;

I get this error :

[2015-02-10 14:19:19.429] [I] devices.deviceInfo.summary: 'DVSwitch: c6 af 18 50 f2 a9 78 07-14 d9 59 10 32 95 f3 5e'

[2015-02-10 14:19:19.456] [I] ReferenceError: "devicespec" is not defined. (Workflow:API_test / Test Dev (item2)#1)

Thanks for your help!

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

The error is expected as there is no global devicespec variable.

You need to add the code provided by Paul inside the scripting code of connectVmNicNumberToVirtualDistributedPortgroup action, not after you call it.

Open vCO Java client, find this action (either by using 'Search' edit box or browsing in 'Actions' tree view), and open it for editing (Ctrl+E or right click,Edit). Then, find in the source code where the other devicespec properties are populated, and add the additional lines.

pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Thanks all, it works well! Smiley Happy

Reply
0 Kudos