Search in sources :

Example 31 with VmNic

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

the class VmInterfaceManager method removeFromExternalNetworks.

protected void removeFromExternalNetworks(List<? extends VmNic> interfaces) {
    Transaction transaction = TransactionSupport.suspend();
    for (VmNic iface : interfaces) {
        getExternalNetworkManagerFactory().create(iface).deallocateIfExternal();
    }
    TransactionSupport.resume(transaction);
}
Also used : Transaction(javax.transaction.Transaction) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 32 with VmNic

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

the class VmNicDaoTest method testGetAllForTemplate.

/**
 * Ensures that interfaces are returned.
 */
@Test
public void testGetAllForTemplate() {
    List<VmNic> result = dao.getAllForTemplate(TEMPLATE_ID);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (VmNic iface : result) {
        assertEquals(TEMPLATE_ID, iface.getVmTemplateId());
    }
}
Also used : VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) Test(org.junit.Test)

Example 33 with VmNic

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

the class VmNicDaoTest method testGetAllInterfacesForVm.

/**
 * Ensures that a collection of interfaces related the specified VM are returned.
 */
@Test
public void testGetAllInterfacesForVm() {
    List<VmNic> result = dao.getAllForVm(VM_ID);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (VmNic iface : result) {
        assertEquals(VM_ID, iface.getVmId());
    }
}
Also used : VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) Test(org.junit.Test)

Example 34 with VmNic

use of org.ovirt.engine.core.common.businessentities.network.VmNic 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)

Example 35 with VmNic

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

the class VmTemplateManagementCommand method removeNetwork.

protected void removeNetwork() {
    List<VmNic> list = vmNicDao.getAllForTemplate(getVmTemplateId());
    for (VmNic iface : list) {
        vmDeviceDao.remove(new VmDeviceId(iface.getId(), getVmTemplateId()));
        vmNicDao.remove(iface.getId());
    }
}
Also used : VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Aggregations

VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)47 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 VM (org.ovirt.engine.core.common.businessentities.VM)6 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)6 Network (org.ovirt.engine.core.common.businessentities.network.Network)5 Guid (org.ovirt.engine.core.compat.Guid)5 HashMap (java.util.HashMap)4 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)4 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)4 List (java.util.List)3 Map (java.util.Map)3 VmNicValidator (org.ovirt.engine.core.bll.validator.VmNicValidator)3 Version (org.ovirt.engine.core.compat.Version)3 Collectors (java.util.stream.Collectors)2 VmInterfaceManager (org.ovirt.engine.core.bll.network.VmInterfaceManager)2 MacPool (org.ovirt.engine.core.bll.network.macpool.MacPool)2 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)2 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2