vCO – Create Distributed Virtual Switch (DVS)

Here is the code for creating a distributed virtual switch. Input is sdkConnection. The code assumes you have only the root network folder.

//sdkConnection is an input parameter of type VC:SdkConnection
var allNetFolder = sdkConnection.getAllNetworkFolders();

//Assuming you have no network folder but the root folder
var netFolder = allNetFolder[0];

var dvsCreateSpec = new VcDVSCreateSpec();
var uplinkNames = new Array();
dvsCreateSpec.productInfo = new VcDistributedVirtualSwitchProductSpec();
//The Version of the DVS
dvsCreateSpec.productInfo.version = "4.1.0";  
dvsCreateSpec.configSpec = new VcVMwareDVSConfigSpec();
//The name of the DVS = "DVSwitch_Backup";
dvsCreateSpec.configSpec.uplinkPortPolicy = new VcDVSNameArrayUplinkPortPolicy;
dvsCreateSpec.configSpec.uplinkPortPolicy.uplinkPortName = uplinkNames;

dvsCreateSpec.configSpec.maxMtu = 9000;
dvsCreateSpec.configSpec.maxPorts = 20000;

task = netFolder.createDVS_Task(dvsCreateSpec);

Published by txusa

VMware Certified Design Expert - VCDX 92. VMware Architect, automation enthusiast.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: