Search in sources :

Example 26 with VnicProfile

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

the class MapVnicFlowTestUtils method profileOf.

static VnicProfile profileOf(String profileName, Guid networkId) {
    VnicProfile vp = new VnicProfile();
    vp.setName(profileName);
    vp.setNetworkId(networkId);
    return vp;
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 27 with VnicProfile

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

the class MapVnicFlowTestUtils method profileOf.

static VnicProfile profileOf(Guid profileId, String profileName, Guid networkId) {
    VnicProfile vp = profileOf(profileName, networkId);
    vp.setId(profileId);
    return vp;
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 28 with VnicProfile

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

the class NetworkModel method performProfilesActions.

private void performProfilesActions(Guid networkGuid) {
    List<VnicProfileModel> profileModels = (List<VnicProfileModel>) getProfiles().getItems();
    if (profileModels.isEmpty() || !getProfiles().getIsAvailable()) {
        return;
    }
    networkGuid = networkGuid == null ? getNetwork().getId() : networkGuid;
    ArrayList<ActionParametersBase> paramlist = new ArrayList<>();
    for (VnicProfileModel profileModel : profileModels) {
        if (!StringHelper.isNullOrEmpty(profileModel.getProfile().getName())) {
            VnicProfile vnicProfile = profileModel.getProfile();
            vnicProfile.setNetworkId(networkGuid);
            AddVnicProfileParameters parameters = new AddVnicProfileParameters(vnicProfile, true);
            parameters.setPublicUse(profileModel.getPublicUse().getEntity());
            paramlist.add(parameters);
        }
    }
    Frontend.getInstance().runMultipleActions(ActionType.AddVnicProfile, paramlist, // cast is required to avoid overload ambiguity
    (IFrontendActionAsyncCallback) null);
}
Also used : ArrayList(java.util.ArrayList) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) AddVnicProfileParameters(org.ovirt.engine.core.common.action.AddVnicProfileParameters) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 29 with VnicProfile

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

the class BackwardCompatibilityVnicHelper method updateNicForBackwardCompatibility.

/**
 * Since the network name and port mirroring attributed were replaced on the {@link VmNic} with the vnic profile id,
 * a certain logic should be applied to translate a given usage of the former api to the expected one.
 *
 * @param nic
 *            the candidate nic to apply the logic for
 * @param oldNic
 *            the existing nic
 * @param networkName
 *            the network name to be configured for the nic
 * @param portMirroring
 *            indicator if port mirroring should be configured for the network
 * @param vm
 *            the vm which contains the nic
 * @param user
 *            the user which execute the action
 */
public ValidationResult updateNicForBackwardCompatibility(VmNic nic, VmNic oldNic, String networkName, boolean portMirroring, VmBase vm, DbUser user) {
    // if network wasn't provided, no need for backward compatibility logic
    if (networkName == null) {
        return ValidationResult.VALID;
    }
    // if the network was provided but unchanged, use the provided vnic profile id
    if (oldNic != null && oldNic.getVnicProfileId() != null) {
        VnicProfile oldProfile = vnicProfileDao.get(oldNic.getVnicProfileId());
        Network oldNetwork = networkDao.get(oldProfile.getNetworkId());
        if (StringUtils.equals(networkName, oldNetwork.getName())) {
            return ValidationResult.VALID;
        }
    }
    // empty network name is considered as an empty (unlinked) network
    if ("".equals(networkName)) {
        if (portMirroring) {
            return new ValidationResult(EngineMessage.PORT_MIRRORING_REQUIRES_NETWORK);
        } else {
            nic.setVnicProfileId(null);
            return ValidationResult.VALID;
        }
    }
    if (vm.getClusterId() == null) {
        return networkOfGivenNameNotExistsInCluster(networkName);
    }
    // if the network was provided with changed name, resolve a suitable profile for it
    Network network = networkDao.getByNameAndCluster(networkName, vm.getClusterId());
    if (network == null) {
        return networkOfGivenNameNotExistsInCluster(networkName);
    }
    List<VnicProfile> vnicProfiles = vnicProfileDao.getAllForNetwork(network.getId());
    for (VnicProfile profile : vnicProfiles) {
        if (isVnicProfilePermitted(user, profile, portMirroring)) {
            nic.setVnicProfileId(profile.getId());
            return ValidationResult.VALID;
        }
    }
    return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_CANNOT_FIND_VNIC_PROFILE_FOR_NETWORK);
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 30 with VnicProfile

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

the class NetworkHelper method createVnicProfile.

public VnicProfile createVnicProfile(Network net) {
    VnicProfile profile = new VnicProfile();
    profile.setId(Guid.newGuid());
    profile.setName(net.getName());
    profile.setNetworkId(net.getId());
    profile.setPortMirroring(false);
    if (!net.isExternal()) {
        NetworkFilter defaultNetworkFilter = resolveVnicProfileDefaultNetworkFilter();
        profile.setNetworkFilterId(defaultNetworkFilter == null ? null : defaultNetworkFilter.getId());
    }
    return profile;
}
Also used : NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) 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