Search in sources :

Example 21 with VnicProfile

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

the class InternalImportExternalNetworkCommandTest method setUp.

@Before
public void setUp() {
    prepareNetwork(commandNoCluster.getParameters().getExternalNetwork());
    prepareNetwork(commandCluster.getParameters().getExternalNetwork());
    when(backend.runInternalAction(eq(ActionType.AddNetwork), any(), any())).thenReturn(getAddNetworkReturnValue());
    when(networkHelper.createVnicProfile(any())).thenReturn(new VnicProfile());
    ActionReturnValue returnValue = new ActionReturnValue();
    returnValue.setSucceeded(true);
    when(networkHelper.attachNetworkToClusters(eq(NETWORK_ID), any())).thenReturn(returnValue);
    QueryReturnValue queryReturnValue = new QueryReturnValue();
    queryReturnValue.setReturnValue(getClusters());
    queryReturnValue.setSucceeded(true);
    when(backend.runInternalQuery(eq(QueryType.GetClustersByStoragePoolId), any(), any())).thenReturn(queryReturnValue);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Before(org.junit.Before)

Example 22 with VnicProfile

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

the class VnicProfileValidatorTest method mockVnicProfilePortMirroringChange.

private void mockVnicProfilePortMirroringChange(boolean portMirroring) {
    VnicProfile vnicProfile = mock(VnicProfile.class);
    when(this.vnicProfile.isPortMirroring()).thenReturn(portMirroring);
    when(vnicProfile.isPortMirroring()).thenReturn(!portMirroring);
    when(vnicProfileDao.get(any())).thenReturn(vnicProfile);
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 23 with VnicProfile

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

the class VnicProfileModel method updateNetworks.

protected void updateNetworks(Collection<Network> networks) {
    VnicProfile profile = getProfile();
    if (profile != null && profile.getNetworkId() != null) {
        Network selected = networks.stream().filter(net -> Objects.equals(profile.getNetworkId(), net.getId())).findFirst().get();
        getNetwork().setSelectedItem(selected);
        getNetwork().setIsChangeable(false);
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 24 with VnicProfile

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

the class VnicProfileModel method flush.

public void flush() {
    if (vnicProfile == null) {
        vnicProfile = new VnicProfile();
    }
    vnicProfile.setName(getName().getEntity());
    Network network = getNetwork().getSelectedItem();
    vnicProfile.setNetworkId(network != null ? network.getId() : null);
    NetworkQoS networkQoS = getNetworkQoS().getSelectedItem();
    vnicProfile.setNetworkQosId(networkQoS != null && networkQoS.getId() != null && !networkQoS.getId().equals(Guid.Empty) ? networkQoS.getId() : null);
    NetworkFilter networkFilter = getNetworkFilter().getSelectedItem();
    vnicProfile.setNetworkFilterId(networkFilter != null ? networkFilter.getId() : null);
    vnicProfile.setPortMirroring(getPortMirroring().getEntity());
    vnicProfile.setPassthrough(getPassthrough().getEntity());
    if (vnicProfile.isPassthrough()) {
        vnicProfile.setMigratable(getMigratable().getEntity());
    }
    if (customPropertiesVisible) {
        vnicProfile.setCustomProperties(KeyValueModel.convertProperties(getCustomPropertySheet().serialize()));
    } else {
        vnicProfile.setCustomProperties(null);
    }
    vnicProfile.setDescription(getDescription().getEntity());
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 25 with VnicProfile

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

the class SyncNetworkProviderCommand method disconnectVms.

private void disconnectVms(Guid networkId) {
    Map<Guid, VnicProfile> profiles = vnicProfileDao.getAllForNetwork(networkId).stream().collect(Collectors.toConcurrentMap(VnicProfile::getId, Function.identity()));
    for (VM vm : vmDao.getAllForNetwork(networkId)) {
        vmHandler.updateNetworkInterfacesFromDb(vm);
        for (VmNetworkInterface iface : vm.getInterfaces()) {
            if (profiles.get(iface.getVnicProfileId()) != null) {
                log.warn("External network '{}' disappeared from provider '{}', disconnecting interface '{}' of VM '{}'.", networkId, getProvider().getName(), iface.getName(), vm.getName());
                iface.setVnicProfileId(null);
                iface.setPlugged(false);
                propagateReturnValue(runInternalAction(ActionType.UpdateVmInterface, new AddVmInterfaceParameters(vm.getId(), iface), getInternalCommandContext()));
            }
        }
    }
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Guid(org.ovirt.engine.core.compat.Guid) AddVmInterfaceParameters(org.ovirt.engine.core.common.action.AddVmInterfaceParameters)

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