VMware {code} Community
jshamberger
Contributor
Contributor

Unable to create a vmknic on a vDS (vNetwork Distributed Switch)

I am attempting to created a vmknic on a vDS. The API AddVirtualNic appears to support this, since the HostVirtualNicSpec parameter includes fields to describe a DistributedVirtualPort. However, the AddVirtualNic API also has a required 'portgroup' parameter, and I have not been able to find a value to pass in that is not rejected as an invalid parameter. I have tried the DVPortGroup name, key, and the DVPort key. Does anyone have any suggestions on how to use this API?

Attached is the code snippet I am using and the resulting output.

Thanks in advance,

Jason

Reply
0 Kudos
3 Replies
lamw
Community Manager
Community Manager

This functionality already exists today with the vCLI's esxcfg-vmknic which has been re-written to support dvs

e.g.

esxcfg-vmknic -a -i <IP addr> -n <Mask> -s <dvSwitch Name> -v <dvPort ID>

The vCLI scripts are based on the vSphere SDK for Perl bindings, you'll want to take a look at the script to figure out what you're missing. I would only duplicate the functionality if there is something lacking, else just use what is available.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
jshamberger
Contributor
Contributor

This is not what I am seeing, but you pointed me in the right direction. I am using the 4.0 GA vMA. When I attempt to use esxcfg-vmknic to add a vmknic to a vDS I see:

$ esxcfg-vmknic -a -i 10.127.129.166 -n 255.255.0.0 -s dvSwitchISCSI3 -v 14 --vihost 10.127.129.160

Can not specify dvsName, dvportId parameters for --add operation.

However, when I looked through the perl script, I found the functionality was partially implemented, and used that as a guide. The trick is to specify portgroup => "" when calling AddVirtualNic to create the vmknic on a vDS.

Reply
0 Kudos
lamw
Community Manager
Community Manager

Not surprised you found a bug. Good to hear you were able to leverage the script.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos