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);
}
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);
}
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;
}
Aggregations