Search in sources :

Example 91 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class VmDeviceCommonUtilsTest method createNetworkInterface.

private VmDevice createNetworkInterface(boolean plugged, String name, List<VmNetworkInterface> interfaces) {
    Guid id = Guid.newGuid();
    VmNetworkInterface vmNic = new VmNetworkInterface();
    vmNic.setId(id);
    vmNic.setName(name);
    interfaces.add(vmNic);
    VmDevice device = createNetworkInterfaceDevice(plugged, id);
    device.setManaged(true);
    return device;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid)

Example 92 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class BackendVmNicResourceTest method setUpStatisticalExpectations.

protected VmNetworkInterface setUpStatisticalExpectations() throws Exception {
    VmNetworkStatistics stats = mock(VmNetworkStatistics.class);
    VmNetworkInterface entity = mock(VmNetworkInterface.class);
    when(entity.getStatistics()).thenReturn(stats);
    when(entity.getSpeed()).thenReturn(50);
    when(entity.getId()).thenReturn(NIC_ID);
    when(stats.getReceiveRate()).thenReturn(10D);
    when(stats.getTransmitRate()).thenReturn(20D);
    when(stats.getReceiveDropRate()).thenReturn(30D);
    when(stats.getTransmitDropRate()).thenReturn(40D);
    when(stats.getReceivedBytes()).thenReturn(50L);
    when(stats.getTransmittedBytes()).thenReturn(60L);
    List<VmNetworkInterface> ifaces = new ArrayList<>();
    ifaces.add(entity);
    setUpEntityQueryExpectations(QueryType.GetVmInterfacesByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { VM_ID }, ifaces);
    return entity;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) ArrayList(java.util.ArrayList)

Example 93 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilderTest method validateVmNetworkInterfaceId.

private void validateVmNetworkInterfaceId(String nicId, Map<String, Object> vmStruct) {
    List<VmNetworkInterface> vmNetworkInterfaceList = VdsBrokerObjectsBuilder.buildVmNetworkInterfacesFromDevices(vmStruct);
    assertNotNull(vmNetworkInterfaceList);
    assertEquals(1, vmNetworkInterfaceList.size());
    VmNetworkInterface vmNetworkInterface = vmNetworkInterfaceList.get(0);
    assertEquals(Guid.createGuidFromString(nicId), vmNetworkInterface.getId());
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)

Example 94 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class TemplateInterfaceListModel method edit.

private void edit() {
    if (getWindow() != null) {
        return;
    }
    VmInterfaceModel model = EditTemplateInterfaceModel.createInstance(getEntity(), getEntity().getStoragePoolId(), getEntity().getCompatibilityVersion(), (ArrayList<VmNetworkInterface>) getItems(), getSelectedItem(), this);
    setWindow(model);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceModel)

Example 95 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class FindActiveVmsUsingNetwork method findActiveVmsUsingNetworks.

private List<VM> findActiveVmsUsingNetworks(Guid vdsId, Collection<String> networks) {
    if (networks.isEmpty()) {
        return Collections.emptyList();
    }
    List<VM> runningVms = vmDao.getAllRunningForVds(vdsId);
    List<VM> vms = new ArrayList<>();
    for (VM vm : runningVms) {
        List<VmNetworkInterface> vmInterfaces = vmNetworkInterfaceDao.getAllForVm(vm.getId());
        for (VmNetworkInterface vmNic : vmInterfaces) {
            boolean vmHasNetworkAttachedToPluggedNic = vmNic.isPlugged() && vmNic.getNetworkName() != null && networks.contains(vmNic.getNetworkName());
            if (vmHasNetworkAttachedToPluggedNic) {
                vms.add(vm);
                break;
            }
        }
    }
    return vms;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList)

Aggregations

VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)115 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 Guid (org.ovirt.engine.core.compat.Guid)19 VM (org.ovirt.engine.core.common.businessentities.VM)16 HashMap (java.util.HashMap)11 List (java.util.List)9 Map (java.util.Map)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)6 MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)5 VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)5 Nic (org.ovirt.engine.api.model.Nic)4 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Collection (java.util.Collection)3