Search in sources :

Example 6 with VmNetworkStatistics

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

the class VmNetworkInterfaceDaoTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getVmNetworkInterfaceDao();
    existingVmInterface = dao.get(FixturesTool.VM_NETWORK_INTERFACE);
    existingTemplateInterface = dao.get(FixturesTool.TEMPLATE_NETWORK_INTERFACE);
    newVmInterface = new VmNetworkInterface();
    newVmInterface.setStatistics(new VmNetworkStatistics());
    newVmInterface.setId(Guid.newGuid());
    newVmInterface.setVnicProfileId(FixturesTool.VM_NETWORK_INTERFACE_PROFILE);
    newVmInterface.setName("eth77");
    newVmInterface.setNetworkName("enginet");
    newVmInterface.setLinked(true);
    newVmInterface.setSpeed(1000);
    newVmInterface.setType(3);
    newVmInterface.setMacAddress("01:C0:81:21:71:17");
    newVmDevice.setType(VmDeviceGeneralType.INTERFACE);
    newVmDevice.setDevice("bridge");
    newVmDevice.setAddress("sample");
    newVmDevice.setManaged(true);
    newVmDevice.setPlugged(true);
    newVmDevice.setReadOnly(false);
    Map<String, String> customProp = new LinkedHashMap<>();
    customProp.put("prop1", "val1");
    newVmDevice.setCustomProperties(customProp);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with VmNetworkStatistics

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

the class VmNetworkStatisticsDaoTest method testGet.

/**
 * Ensures that the network interface statistics entity is returned.
 */
@Test
public void testGet() {
    VmNetworkStatistics result = dao.get(FixturesTool.VM_NETWORK_INTERFACE);
    assertNotNull(result);
    assertEquals(FixturesTool.VM_NETWORK_INTERFACE, result.getId());
}
Also used : VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Test(org.junit.Test)

Example 8 with VmNetworkStatistics

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

the class VmNetworkStatisticsDaoTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getVmNetworkStatisticsDao();
    newVmStatistics = new VmNetworkStatistics();
    newVmStatistics.setId(NEW_INTERFACE_ID);
    newVmStatistics.setVmId(VM_ID);
    newVmStatistics.setStatus(InterfaceStatus.DOWN);
    newVmStatistics.setSampleTime(0.0);
    newVmStatistics.setReceiveDropRate(0.0);
    newVmStatistics.setReceiveRate(0.0);
    newVmStatistics.setReceivedBytes(0L);
    newVmStatistics.setReceivedBytesOffset(0L);
    newVmStatistics.setTransmitDropRate(0.0);
    newVmStatistics.setTransmitRate(0.0);
    newVmStatistics.setTransmittedBytes(0L);
    newVmStatistics.setTransmittedBytesOffset(0L);
}
Also used : VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)

Example 9 with VmNetworkStatistics

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

the class VmNetworkStatisticsDaoTest method testGetWithNonExistingId.

/**
 * Ensures null is returned.
 */
@Test
public void testGetWithNonExistingId() {
    VmNetworkStatistics result = dao.get(Guid.newGuid());
    assertNull(result);
}
Also used : VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Test(org.junit.Test)

Example 10 with VmNetworkStatistics

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

the class ImportVmTemplateCommand method addVmInterfaces.

protected void addVmInterfaces() {
    VnicProfileHelper vnicProfileHelper = new VnicProfileHelper(getVmTemplate().getClusterId(), getStoragePoolId(), AuditLogType.IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES);
    for (VmNetworkInterface iface : getVmTemplate().getInterfaces()) {
        if (iface.getId() == null) {
            iface.setId(Guid.newGuid());
        }
        iface.setVmId(getVmTemplateId());
        VmNic nic = new VmNic();
        nic.setId(iface.getId());
        nic.setVmTemplateId(getVmTemplateId());
        nic.setName(iface.getName());
        nic.setLinked(iface.isLinked());
        nic.setSpeed(iface.getSpeed());
        nic.setType(iface.getType());
        vnicProfileHelper.updateNicWithVnicProfileForUser(iface, getCurrentUser());
        nic.setVnicProfileId(iface.getVnicProfileId());
        vmNicDao.save(nic);
        getCompensationContext().snapshotNewEntity(nic);
        VmNetworkStatistics iStat = new VmNetworkStatistics();
        nic.setStatistics(iStat);
        iStat.setId(iface.getId());
        iStat.setVmId(getVmTemplateId());
        vmNetworkStatisticsDao.save(iStat);
        getCompensationContext().snapshotNewEntity(iStat);
    }
    vnicProfileHelper.auditInvalidInterfaces(getVmTemplateName());
}
Also used : VnicProfileHelper(org.ovirt.engine.core.bll.network.vm.VnicProfileHelper) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Aggregations

VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)10 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)1 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)1 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)1 Guid (org.ovirt.engine.core.compat.Guid)1 RandomUtils (org.ovirt.engine.core.utils.RandomUtils)1