Search in sources :

Example 16 with VmNic

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

the class VmNicDaoTest method testGetWithNonExistingId.

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

Example 17 with VmNic

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

the class VmNicDaoTest method generateNewEntity.

@Override
protected VmNic generateNewEntity() {
    VmNic vmNic = new VmNic();
    vmNic.setId(Guid.newGuid());
    vmNic.setVnicProfileId(FixturesTool.VM_NETWORK_INTERFACE_PROFILE);
    vmNic.setName("eth77");
    vmNic.setLinked(true);
    vmNic.setSpeed(1000);
    vmNic.setType(3);
    vmNic.setMacAddress("01:C0:81:21:71:17");
    return vmNic;
}
Also used : VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 18 with VmNic

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

the class VmInterfaceManager method removeAll.

public void removeAll(List<? extends VmNic> interfaces) {
    if (interfaces == null) {
        return;
    }
    removeFromExternalNetworks(interfaces);
    for (VmNic iface : interfaces) {
        getVmNicDao().remove(iface.getId());
        getVmNetworkStatisticsDao().remove(iface.getId());
    }
}
Also used : VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 19 with VmNic

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

the class SnapshotsManager method synchronizeNics.

/**
 * Synchronize the VM's {@link VmNetworkInterface}s with the ones from the snapshot.<br>
 * All existing NICs will be deleted, and the ones from the snapshot re-added.<br>
 * In case a MAC address is already in use, the user will be issued a warning in the audit log.
 *
 * @param user
 *            The user that performs the action
 * @param vmInterfaceManager vmInterfaceManager instance
 */
private void synchronizeNics(VM snapshotedVm, CompensationContext compensationContext, DbUser user, VmInterfaceManager vmInterfaceManager, boolean macsInSnapshotAreExpectedToBeAlreadyAllocated) {
    VnicProfileHelper vnicProfileHelper = new VnicProfileHelper(snapshotedVm.getClusterId(), snapshotedVm.getStoragePoolId(), AuditLogType.IMPORTEXPORT_SNAPSHOT_VM_INVALID_INTERFACES);
    MacPool macPool = vmInterfaceManager.getMacPool();
    /*what is at moment of calling this in DB are data related to (stateless) VM being updated/overwritten by
         * snapshot data.
         */
    List<VmNic> dbNics = vmNicDao.getAllForVm(snapshotedVm.getId());
    /*
         * while snapshotedVm.getInterfaces() are interfaces taken from VM passed into here via parameter. This instance originates from same DB
         * record, but it was updated with ovf snapshot, so at the moment of calling this, VM is filled with data to
         * which we need to revert for example stateless VM being stopped.
         */
    new SyncMacsOfDbNicsWithSnapshot(macPool, auditLogDirector, macsInSnapshotAreExpectedToBeAlreadyAllocated).sync(dbNics, snapshotedVm.getInterfaces());
    vmInterfaceManager.removeAll(dbNics);
    for (VmNetworkInterface vmInterface : snapshotedVm.getInterfaces()) {
        vmInterface.setVmId(snapshotedVm.getId());
        // These fields might not be saved in the OVF, so fill them with reasonable values.
        if (vmInterface.getId() == null) {
            vmInterface.setId(Guid.newGuid());
        }
        vnicProfileHelper.updateNicWithVnicProfileForUser(vmInterface, user);
        vmInterfaceManager.persistIface(vmInterface, compensationContext);
    }
    vnicProfileHelper.auditInvalidInterfaces(snapshotedVm.getName());
}
Also used : MacPool(org.ovirt.engine.core.bll.network.macpool.MacPool) VnicProfileHelper(org.ovirt.engine.core.bll.network.vm.VnicProfileHelper) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 20 with VmNic

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

the class MacAddressPatternTest method createVmNic.

private VmNic createVmNic() {
    VmNic nic = new VmNic();
    nic.setName("nic1");
    nic.setMacAddress(address);
    return nic;
}
Also used : 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