Search in sources :

Example 1 with NetworkMO

use of com.cloud.hypervisor.vmware.mo.NetworkMO in project cloudstack by apache.

the class VMwareGuru method getNetworkMO.

/**
 * Get network MO from VM NIC
 */
private NetworkMO getNetworkMO(VirtualE1000 nic, VmwareContext context) {
    VirtualDeviceConnectInfo connectable = nic.getConnectable();
    VirtualEthernetCardNetworkBackingInfo info = (VirtualEthernetCardNetworkBackingInfo) nic.getBacking();
    ManagedObjectReference networkMor = info.getNetwork();
    if (networkMor == null) {
        throw new CloudRuntimeException("Could not find network for NIC on: " + nic.getMacAddress());
    }
    return new NetworkMO(context, networkMor);
}
Also used : VirtualEthernetCardNetworkBackingInfo(com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) NetworkMO(com.cloud.hypervisor.vmware.mo.NetworkMO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VirtualDeviceConnectInfo(com.vmware.vim25.VirtualDeviceConnectInfo) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 2 with NetworkMO

use of com.cloud.hypervisor.vmware.mo.NetworkMO in project cloudstack by apache.

the class VMwareGuru method getNicMacAddressAndNetworkName.

private Pair<String, String> getNicMacAddressAndNetworkName(VirtualDevice nicDevice, VmwareContext context) throws Exception {
    VirtualE1000 nic = (VirtualE1000) nicDevice;
    String macAddress = nic.getMacAddress();
    NetworkMO networkMO = getNetworkMO(nic, context);
    String networkName = networkMO.getName();
    return new Pair<>(macAddress, networkName);
}
Also used : NetworkMO(com.cloud.hypervisor.vmware.mo.NetworkMO) VirtualE1000(com.vmware.vim25.VirtualE1000) Pair(com.cloud.utils.Pair)

Example 3 with NetworkMO

use of com.cloud.hypervisor.vmware.mo.NetworkMO in project cloudstack by apache.

the class VmwareResource method areVMsOnNetwork.

private boolean areVMsOnNetwork(DatacenterMO dcMO, NetworkDetails netDetails) throws Exception {
    if (netDetails == null || netDetails.getName() == null) {
        throw new CloudRuntimeException("Unspecified network details / port group, couldn't check VMs on network port group");
    }
    List<HostMO> hosts = dcMO.getAllHostsOnDatacenter();
    if (!CollectionUtils.isEmpty(hosts)) {
        for (HostMO host : hosts) {
            NetworkMO networkMo = new NetworkMO(host.getContext(), netDetails.getNetworkMor());
            List<ManagedObjectReference> vms = networkMo.getVMsOnNetwork();
            if (!CollectionUtils.isEmpty(vms)) {
                s_logger.debug("Network port group: " + netDetails.getName() + " is in use");
                return true;
            }
        }
    }
    return false;
}
Also used : HostMO(com.cloud.hypervisor.vmware.mo.HostMO) NetworkMO(com.cloud.hypervisor.vmware.mo.NetworkMO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

NetworkMO (com.cloud.hypervisor.vmware.mo.NetworkMO)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)1 Pair (com.cloud.utils.Pair)1 VirtualDeviceConnectInfo (com.vmware.vim25.VirtualDeviceConnectInfo)1 VirtualE1000 (com.vmware.vim25.VirtualE1000)1 VirtualEthernetCardNetworkBackingInfo (com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo)1