use of com.vmware.vim25.DistributedVirtualSwitchPortConnection in project cloudstack by apache.
the class VmwareHelper method prepareDvNicDevice.
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String dvPortGroupName, String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
VirtualEthernetCard nic;
switch(deviceType) {
case E1000:
nic = new VirtualE1000();
break;
case PCNet32:
nic = new VirtualPCNet32();
break;
case Vmxnet2:
nic = new VirtualVmxnet2();
break;
case Vmxnet3:
nic = new VirtualVmxnet3();
break;
default:
assert (false);
nic = new VirtualE1000();
}
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
final DistributedVirtualSwitchPortConnection dvPortConnection = new DistributedVirtualSwitchPortConnection();
final VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo();
dvPortConnection.setSwitchUuid(dvSwitchUuid);
dvPortConnection.setPortgroupKey(morNetwork.getValue());
dvPortBacking.setPort(dvPortConnection);
nic.setBacking(dvPortBacking);
nic.setKey(30);
connectInfo.setAllowGuestControl(true);
connectInfo.setConnected(conntected);
connectInfo.setStartConnected(connectOnStart);
nic.setAddressType("Manual");
nic.setConnectable(connectInfo);
nic.setMacAddress(macAddress);
nic.setUnitNumber(deviceNumber);
nic.setKey(-contextNumber);
return nic;
}
use of com.vmware.vim25.DistributedVirtualSwitchPortConnection in project cloudstack by apache.
the class VirtualMachineMO method getDvPortGroupName.
public String getDvPortGroupName(VirtualEthernetCard nic) throws Exception {
VirtualEthernetCardDistributedVirtualPortBackingInfo dvpBackingInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo) nic.getBacking();
DistributedVirtualSwitchPortConnection dvsPort = dvpBackingInfo.getPort();
String dvPortGroupKey = dvsPort.getPortgroupKey();
ManagedObjectReference dvPortGroupMor = new ManagedObjectReference();
dvPortGroupMor.setValue(dvPortGroupKey);
dvPortGroupMor.setType("DistributedVirtualPortgroup");
return (String) _context.getVimClient().getDynamicProperty(dvPortGroupMor, "name");
}
Aggregations