About NSX-T
NSX-T is VMware's multi-hypervisor, multi-cloud Networking & Security platform for workloads running on-premises and the public cloud.
The platform is vCenter agnostic but does have some loose vCenter integrations.
For more information, see:
About N-VDS
NSX-T manages the lifecycle of its own virtual switches agnostic of Compute Manager(vCenter). The switch is called the N-VDS.
How Partners should interact with NSX-T
Option A: Partners can integrate with NSX-T directly through NSX-T Rest APIs. For more information, see the NSX-T Manager API Guide.
These APIs are homogenous across multiple hypervisors types: ESX, KVM as well as multiple workload types VM, BM, Container, Cloud.
There are also several API plugins to choose from:
Option B: Partners can continue to use with VIM apis or vSphere SDKs to interact with "select" NSX-T networking features if the workload is running on ESX hypervisors. The following are the only APIs that interacts with Opaque networks.
Note: For partners who interact with VIM APIs or vSphere SDKs, all NSX-T managed VMs have NIC backing as "Opaque Network" hence some code changes may be required as below.
VM related APIs
vim.vm.device.VirtualEthernetCard.OpaqueNetworkBackingInfo
vim.vm.device.VirtualEthernetCard.OpaqueNetworkBackingInfo is introduced and it extends vim.vm.device.VirtualDevice.BackingInfo. Code changes are needed if you want the VM to connect to an Opaque network or you already have a VM connected to an Opaque network. Most of VM operations are affected such as reconfig, vMotion, clone, etc.
Affected API |
vim.vm.check.CompatibilityChecker.checkVmConfig |
vim.ResourcePool.createVm |
vim.Folder.createVm |
vim.VirtualMachine.reconfigure |
vim.vm.check.ProvisioningChecker.checkRelocate |
vim.VirtualMachine.relocate |
vim.vm.check.ProvisioningChecker.checkClone |
vim.VirtualMachine.clone |
vim.ClusterComputeResource.placeVm |
vim.vm.check.ProvisioningChecker.checkInstantClone |
vim.VirtualMachine.instantClone |
Code changes are also needed if you invoke the API which return an object containing vim.vm.device.VirtualDevice.BackingInfo and you want to get some information from it.
Vmknic related APIs
vim.host.VirtualNic.OpaqueNetworkSpec
vim.host.VirtualNic.OpaqueNetworkSpec is introduced as a property of vim.host.VirtualNic. code changes are needed if you want to connect a vmknic to an Opaque network.
Affected API |
vim.host.NetworkSystem.addServiceConsolVirtualNic |
vim.host.NetworkSystem.AddVirtualNic |
vim.host.NetworkSystem.UpdateServiceConsoleVirtualNic |
vim.host.NetworkSystem.UpdateVirtualNic |
Host network related APIs
vim.OpaqueNetwork
vim.OpaqueNetwork extends vim.Network. So all APIs related with vim.Network are affected. vim.Network is read only property, there is no API to change that. Here is a list of objects/properties which contain vim.Network. Since it does not change anything in the base class, your script still works but you may lose additional information for the Opaque network.
vim.HostSystem |
vim.fault.CannotAccessNetwork |
vim.fault.CannotUseNetwork |
vim.ComputeResource |
vim.Datacenter |
vim.host.Summary.ConfigSummary |
vim.host.EsxAgentHostManager.ConfigInfo |
vim.vApp.IpPool.Association |
vim.event.NetworkEventArgument |
vim.Network.Summary |
vim.fault.NoAvailableIp |
vim.vcha.FailoverClusterConfiguration.NodeDeploymentSpec |
vim.OvfManager.NetworkMapping |
vim.vApp.CloneSpec.NetworkMappingPair |
vim.VirtualApp |
vim.vm.device.VirtualEthernetCard.NetworkBackingInfo |
vim.VirtualMachine |
vim.host.OpaqueSwitch and vim.host.OpaqueNetworkInfo
vim.host.OpaqueSwitch and vim.host.OpaqueNetworkInfo are new properties in vim.host.NetworkInfo. So all APIs related with vim.host.Networkinfo are affected. They are read only properties for the user. If you want to get them correctly, code changes are needed for your script. Affected objects and APIs:
Affected Objects | Note |
vim.host.NetworkInfo | |
vim.host.ConfigInfo | vim.host.NetworkInfo is a property of it |
vim.host.NetworkSystem | vim.host.NetworkInfo is a property of it |
vim.host.ConfigManager | vim.host.HostNetworkSystem is a property of it |
vim.HostSystem | vim.host.ConfigInfo is a property of it vim.host.ConfigManager is a property of it |
For more information on how to interact with the VIM API, see Managed Object - Opaque Network.
If you interact with vSphere using SDKs, here are some of vSphere SDK code samples:
Sample code
private VirtualDeviceBackingInfo getBacking(ManagedObjectReference network)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
switch (network.getType()) {
case "Network":
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(value);
return nicBacking;
case "OpaqueNetwork":
OpaqueNetworkSummary opaqueNetworkSummary = (OpaqueNetworkSummary) getMOREFs.entityProps(network,
"summary");
VirtualEthernetCardOpaqueNetworkBackingInfo opaqueBack = new VirtualEthernetCardOpaqueNetworkBackingInfo();
opaqueBack.setOpaqueNetworkId(opaqueNetworkSummary.getOpaqueNetworkId());
opaqueBack.setOpaqueNetworkType(opaqueNetworkSummary.getOpaqueNetworkType());
return opaqueBack;
case "DistributedVirtualPortgroup":
DVPortgroupConfigInfo dvPortgroupConfigInfo = (DVPortgroupConfigInfo) getMOREFs.entityProps(network,
"config");
String uuid = getMOREFs.entityProps(dvPortgroupConfigInfo.getDistributedVirtualSwitch(), "uuid").toString();
VirtualEthernetCardDistributedVirtualPortBackingInfo dvpBack = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
DistributedVirtualSwitchPortConnection dvsPortConnection = new DistributedVirtualSwitchPortConnection();
dvsPortConnection.setPortgroupKey(dvPortgroupConfigInfo.getKey());
dvsPortConnection.setSwitchUuid(uuid);
dvpBack.setPort(dvsPortConnection);
return dvpBack;
default:
return null;
}
}
.....
//Add a new nic
VirtualEthernetCard nic = new VirtualE1000E();
//get the list of available host networks
HashMap<String, ManagedObjectReference> availableNetworks = getAvailableHostNetworks();
if (availableNetworks.containsKey(value)) {
nic.setBacking(getBacking(availableNetworks.get(value)));
} else {
nic.setBacking(null);
}
VirtualDeviceConnectInfo deviceConnectInfo = new VirtualDeviceConnectInfo();
deviceConnectInfo.setStartConnected((nic.getBacking() != null));
deviceConnectInfo.setConnected((nic.getBacking() != null));
nic.setConnectable(deviceConnectInfo);
nic.setAddressType("generated");
nic.setKey(-1);
VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec();
nicSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
nicSpec.setDevice(nic);
nicSpecArray.add(nicSpec);
vmConfigSpec.getDeviceChange().addAll(nicSpecArray);
ManagedObjectReference tmor = vimPort.reconfigVMTask(virtualMachine, vmConfigSpec);
if (getTaskResultAfterDone(tmor)) {
System.out.println("Virtual Machine reconfigured successfully");
} else {
System.out.println("Virtual Machine reconfigur failed");
}
Code Examples: