use of com.vmware.vim25.VirtualEthernetCard in project cloudstack by apache.
the class VirtualMachineMO method getNicDeviceIndex.
public Pair<Integer, VirtualDevice> getNicDeviceIndex(String networkNamePrefix) throws Exception {
List<VirtualDevice> nics = getNicDevices(true);
int index = 0;
String attachedNetworkSummary;
String dvPortGroupName;
for (VirtualDevice nic : nics) {
attachedNetworkSummary = ((VirtualEthernetCard) nic).getDeviceInfo().getSummary();
if (attachedNetworkSummary.startsWith(networkNamePrefix)) {
return new Pair<Integer, VirtualDevice>(new Integer(index), nic);
} else if (attachedNetworkSummary.endsWith("DistributedVirtualPortBackingInfo.summary") || attachedNetworkSummary.startsWith("DVSwitch")) {
dvPortGroupName = getDvPortGroupName((VirtualEthernetCard) nic);
if (dvPortGroupName != null && dvPortGroupName.startsWith(networkNamePrefix)) {
s_logger.debug("Found a dvPortGroup already associated with public NIC.");
return new Pair<Integer, VirtualDevice>(new Integer(index), nic);
}
}
index++;
}
return new Pair<Integer, VirtualDevice>(new Integer(-1), null);
}
use of com.vmware.vim25.VirtualEthernetCard 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