Search in sources :

Example 11 with VirtualEthernetCard

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);
}
Also used : VirtualDevice(com.vmware.vim25.VirtualDevice) VirtualEthernetCard(com.vmware.vim25.VirtualEthernetCard) Pair(com.cloud.utils.Pair)

Example 12 with VirtualEthernetCard

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");
}
Also used : VirtualEthernetCardDistributedVirtualPortBackingInfo(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo) DistributedVirtualSwitchPortConnection(com.vmware.vim25.DistributedVirtualSwitchPortConnection) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

VirtualEthernetCard (com.vmware.vim25.VirtualEthernetCard)10 VirtualDevice (com.vmware.vim25.VirtualDevice)5 VirtualDeviceConnectInfo (com.vmware.vim25.VirtualDeviceConnectInfo)5 VirtualE1000 (com.vmware.vim25.VirtualE1000)5 VirtualPCNet32 (com.vmware.vim25.VirtualPCNet32)5 VirtualVmxnet2 (com.vmware.vim25.VirtualVmxnet2)5 VirtualVmxnet3 (com.vmware.vim25.VirtualVmxnet3)5 DistributedVirtualSwitchPortConnection (com.vmware.vim25.DistributedVirtualSwitchPortConnection)4 VirtualEthernetCardDistributedVirtualPortBackingInfo (com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo)4 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)3 VirtualEthernetCardNetworkBackingInfo (com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo)3 ArrayList (java.util.ArrayList)3 Pair (com.cloud.utils.Pair)2 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)2 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 DatacenterMO (com.cloud.hypervisor.vmware.mo.DatacenterMO)1 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)1 VirtualSwitchType (com.cloud.hypervisor.vmware.mo.VirtualSwitchType)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1