Adding a VMkernel Network
Interface
VMkernel network interfaces provide the
network access for the VMkernel TCP/IP stack. You must create new VMkernel
ports for your ESXi system if you plan on using VMotion, VMware FT, or iSCSI
and NAS storage. A VMkernel port consists of a port on the virtual switch and a
VMkernel interface.
To add a VMkernel Network Interface to your ESXi
system, use the following steps.
- Create aHostVirtualNicSpecdata object. Inside the object, you can specify the IP configuration in aHostIpConfigdata object. For vSS, specify theportgroupproperty. For vDS, specify thedistributedVirtualPortproperty.
- CallHostNetworkSystem.AddVirtualNic, passing in theHostVirtualNicSpec.
- You can then use the VMkernel network interface for software iSCSI or NAS, or call theHostVmotionSystem.SelectVnicmethod to use this VMkernel NIC for VMotion.Adding a VMkernel Network Interface, a code fragment from theAddVirtualNicexample, illustrates this. The sample retrieves the IP address from the command line using thecb.get_optioncall.
Adding a VMkernel Network Interface
private HostVirtualNicSpec createVNicSpecification() { HostVirtualNicSpec vNicSpec = new HostVirtualNicSpec(); HostIpConfig ipConfig = new HostIpConfig(); ipConfig.setDhcp(false); ipAddr = cb.get_option("ipaddress"); ipConfig.setIpAddress(ipAddr); ipConfig.setSubnetMask("255.255.255.0"); vNicSpec.setIp(ipConfig); return vNicSpec; } .... HostVirtualNicSpec vNicSpec = createVNicSpecification(); service.addVirtualNic(nwSystem, portGroup, vNicSpec);