Search in sources :

Example 1 with NicLabel

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

the class LabelNicCommand method createHostSetupNetworksParameters.

private HostSetupNetworksParameters createHostSetupNetworksParameters() {
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(getVdsId());
    params.getLabels().add(new NicLabel(getNic().getId(), getNic().getName(), getLabel()));
    return params;
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 2 with NicLabel

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

the class NicLabelValidator method validNewOrModifiedLabels.

public ValidationResult validNewOrModifiedLabels() {
    ValidationResult vr = ValidationResult.VALID;
    Iterator<NicLabel> iterator = params.getLabels().iterator();
    while (iterator.hasNext() && vr.isValid()) {
        NicLabel nicLabel = iterator.next();
        vr = skipValidation(vr) ? vr : validateCoherentNicIdentification(nicLabel);
        vr = skipValidation(vr) ? vr : nicActuallyExistsOrReferencesNewBond(nicLabel);
        vr = skipValidation(vr) ? vr : labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel);
        vr = skipValidation(vr) ? vr : labelBeingAttachedToValidBond(nicLabel);
    }
    return vr;
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 3 with NicLabel

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

the class NicLabelValidator method labelAppearsOnlyOnceInParams.

public ValidationResult labelAppearsOnlyOnceInParams() {
    Set<String> existingLabels = new HashSet<>();
    Set<String> duplicateLabels = new HashSet<>();
    for (NicLabel nicLabel : params.getLabels()) {
        String label = nicLabel.getLabel();
        addLabelToList(existingLabels, duplicateLabels, label);
    }
    for (String label : params.getRemovedLabels()) {
        addLabelToList(existingLabels, duplicateLabels, label);
    }
    return ValidationResult.failWith(EngineMessage.PARAMS_CONTAIN_DUPLICATE_LABELS, ReplacementUtils.replaceWith("PARAMS_CONTAIN_DUPLICATE_LABELS_LIST", new ArrayList<>(duplicateLabels))).unless(duplicateLabels.isEmpty());
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HashSet(java.util.HashSet)

Example 4 with NicLabel

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

the class NicLabelsCompleter method completeNetworkAttachmentsByLabels.

private void completeNetworkAttachmentsByLabels() {
    for (NicLabel nicLabel : params.getLabels()) {
        List<Network> labelNetworks = labelToNetworks.get(nicLabel.getLabel());
        if (labelNetworks == null) {
            continue;
        }
        for (Network network : labelNetworks) {
            NetworkAttachment newOrModifiedNetworkAttachment = attachmentsByNetworkId.get(network.getId());
            NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentsByNetworkId.get(network.getId());
            boolean existingAttachmentRemoved = existingNetworkAttachment == null ? false : params.getRemovedNetworkAttachments().contains(existingNetworkAttachment.getId());
            boolean noNewOrModifiedNetworkAttachment = newOrModifiedNetworkAttachment == null;
            NetworkAttachment attachmentToConfigure = noNewOrModifiedNetworkAttachment && !existingAttachmentRemoved ? existingNetworkAttachment : newOrModifiedNetworkAttachment;
            if (attachmentToConfigure == null) {
                params.getNetworkAttachments().add(createNetworkAttachment(nicLabel.getNicId(), nicLabel.getNicName(), network.getId(), network.getName()));
            } else if (!Objects.equals(attachmentToConfigure.getNicName(), nicLabel.getNicName()) && noNewOrModifiedNetworkAttachment) {
                NetworkAttachment updatedNetworkAttachment = new NetworkAttachment(existingNetworkAttachment);
                updatedNetworkAttachment.setNicId(nicLabel.getNicId());
                updatedNetworkAttachment.setNicName(nicLabel.getNicName());
                params.getNetworkAttachments().add(updatedNetworkAttachment);
            }
        }
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 5 with NicLabel

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

the class HostSetupNetworksCommand method updateAddedModifiedLabelsOnNics.

private void updateAddedModifiedLabelsOnNics(Map<String, VdsNetworkInterface> nicsToConfigureByName) {
    Map<String, VdsNetworkInterface> labelToExistingNic = getLabelToNic(nicsToConfigureByName.values());
    for (NicLabel nicLabel : getParameters().getLabels()) {
        VdsNetworkInterface currentLabelNic = labelToExistingNic.get(nicLabel.getLabel());
        VdsNetworkInterface newLabelNic = nicsToConfigureByName.get(nicLabel.getNicName());
        moveLabel(nicLabel.getLabel(), currentLabelNic, newLabelNic);
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel)

Aggregations

NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)28 Test (org.junit.Test)16 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)16 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)7 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)6 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)5 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)5 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 ArrayList (java.util.ArrayList)3 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)3 HashSet (java.util.HashSet)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 List (java.util.List)1 HostNic (org.ovirt.engine.api.model.HostNic)1 NetworkLabel (org.ovirt.engine.api.model.NetworkLabel)1 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)1