Search in sources :

Example 1 with VnicProfile

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

the class NetworkProfileListModel method newProfile.

public void newProfile() {
    if (getWindow() != null) {
        return;
    }
    NewVnicProfileModel model = new NewVnicProfileModel(this, getEntity().getDataCenterId());
    setWindow(model);
    VnicProfile profile = new VnicProfile();
    profile.setNetworkId(getEntity().getId());
    model.setProfile(profile);
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)

Example 2 with VnicProfile

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

the class AddEmptyStoragePoolCommand method addDefaultNetworks.

private void addDefaultNetworks() {
    Network net = new Network();
    net.setId(Guid.newGuid());
    net.setName(managementNetworkUtil.getDefaultManagementNetworkName());
    NetworkUtils.setNetworkVdsmName(net);
    net.setDescription(AddClusterCommand.DefaultNetworkDescription);
    net.setDataCenterId(getStoragePool().getId());
    net.setVmNetwork(true);
    networkDao.save(net);
    networkHelper.addPermissionsOnNetwork(getCurrentUser().getId(), net.getId());
    VnicProfile profile = networkHelper.createVnicProfile(net);
    vnicProfileDao.save(profile);
    networkHelper.addPermissionsOnVnicProfile(getCurrentUser().getId(), profile.getId(), true);
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 3 with VnicProfile

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

the class RemoveStoragePoolCommand method removeNetworks.

private void removeNetworks() {
    final List<Network> networks = networkDao.getAllForDataCenter(getStoragePoolId());
    for (Network network : networks) {
        if (network.isExternal()) {
            for (VmNic nic : vmNicDao.getAllForNetwork(network.getId())) {
                externalNetworkManagerFactory.create(nic, network).deallocateIfExternal();
            }
        }
    }
    TransactionSupport.executeInNewTransaction(() -> {
        for (final Network net : networks) {
            List<VnicProfile> profiles = vnicProfileDao.getAllForNetwork(net.getId());
            for (VnicProfile vnicProfile : profiles) {
                getCompensationContext().snapshotEntity(vnicProfile);
                vnicProfileDao.remove(vnicProfile.getId());
            }
            getCompensationContext().snapshotEntity(net);
            networkDao.remove(net.getId());
        }
        getCompensationContext().stateChanged();
        return null;
    });
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 4 with VnicProfile

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

the class VmValidatorTest method mockVnic.

private VmNetworkInterface mockVnic(boolean passthrough, boolean migratable, boolean plugged) {
    VmNetworkInterface vnic = mock(VmNetworkInterface.class);
    when(vnic.isPassthrough()).thenReturn(passthrough);
    when(vnic.isPlugged()).thenReturn(plugged);
    Guid vnicProfileId = Guid.newGuid();
    when(vnic.getVnicProfileId()).thenReturn(vnicProfileId);
    VnicProfile profile = mock(VnicProfile.class);
    when(vnicProfileDao.get(vnicProfileId)).thenReturn(profile);
    when(profile.isMigratable()).thenReturn(migratable);
    return vnic;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with VnicProfile

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

the class VnicProfileValidatorTest method passthroughNotChangedIfUsedByVmsTest.

private void passthroughNotChangedIfUsedByVmsTest(boolean passthoughOld, boolean pasthroughNew, boolean profileUsedByVms) {
    VnicProfile updatedVnicProfile = mock(VnicProfile.class);
    when(vnicProfile.isPassthrough()).thenReturn(passthoughOld);
    when(updatedVnicProfile.isPassthrough()).thenReturn(pasthroughNew);
    when(vnicProfileDao.get(any())).thenReturn(updatedVnicProfile);
    mockVmsUsingVnicProfile(profileUsedByVms ? Collections.singletonList(mock(VM.class)) : Collections.emptyList());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Aggregations

VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)31 Network (org.ovirt.engine.core.common.businessentities.network.Network)12 NetworkFilter (org.ovirt.engine.core.common.businessentities.network.NetworkFilter)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Test (org.junit.Test)3 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)3 Guid (org.ovirt.engine.core.compat.Guid)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 AddVnicProfileParameters (org.ovirt.engine.core.common.action.AddVnicProfileParameters)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)2 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1