Search in sources :

Example 31 with Bond

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

the class HostSetupNetworksValidator method validateBondModeVsNetworksAttachedToIt.

protected ValidationResult validateBondModeVsNetworksAttachedToIt(Collection<NetworkAttachment> attachmentsToConfigure) {
    Map<String, VdsNetworkInterface> hostInterfacesByNetworkName = NetworkUtils.hostInterfacesByNetworkName(existingInterfaces);
    for (NetworkAttachment attachment : attachmentsToConfigure) {
        if (!mustAttachementBeCheckedForBondMode(attachment, hostInterfacesByNetworkName)) {
            continue;
        }
        CreateOrUpdateBond bondToCheck = createOrUpdateBondBusinessEntityMap.get(attachment.getNicName());
        if (bondToCheck == null) {
            VdsNetworkInterface existingNetworkInterfaceForAttachement = existingInterfacesMap.get(attachment.getNicName());
            if (existingNetworkInterfaceForAttachement == null || !existingNetworkInterfaceForAttachement.isBond()) {
                continue;
            }
            bondToCheck = CreateOrUpdateBond.fromBond((Bond) existingNetworkInterfaceForAttachement);
        }
        String networkLabel = networkBusinessEntityMap.get(attachment.getNetworkName()).getLabel();
        ValidationResult validationResult = checkBondMode(bondToCheck, networkLabel, attachment.getNetworkName());
        if (!validationResult.isValid()) {
            return validationResult;
        }
    }
    return ValidationResult.VALID;
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 32 with Bond

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

the class NetworkCommonUtils method getBondsWithSlavesInformation.

public static Collection<VdsNetworkInterface> getBondsWithSlavesInformation(Collection<? extends VdsNetworkInterface> nics) {
    List<VdsNetworkInterface> bonds = new ArrayList<>();
    fillBondSlaves(nics);
    for (VdsNetworkInterface nic : nics) {
        if (nic instanceof Bond) {
            bonds.add(nic);
        }
    }
    return bonds;
}
Also used : ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 33 with Bond

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

the class HostNetworkInterfaceBondedListViewItem method createBondTooltipMessage.

private SafeHtml createBondTooltipMessage(HostInterfaceLineModel lineModel, InterfaceStatus interfaceStatus) {
    Bond bond = (Bond) lineModel.getInterface();
    StringBuilder bondProperties = new StringBuilder(messages.bondStatus(interfaceStatus.toString()));
    boolean isBond4 = BondMode.BOND4.equals(BondMode.parseBondMode(bond.getBondOptions()));
    if (InterfaceStatus.UP.equals(interfaceStatus) && isBond4) {
        // $NON-NLS-1$
        bondProperties.append("\n").append(createActiveBondTooltipMessage(bond, lineModel));
    }
    if ((bond.getActiveSlave() != null) && (bond.getActiveSlave().length() > 0)) {
        // $NON-NLS-1$
        bondProperties.append("\n").append(messages.bondActiveSlave(bond.getActiveSlave()));
    }
    return new SafeHtmlBuilder().appendEscapedLines(bondProperties.toString()).toSafeHtml();
}
Also used : Bond(org.ovirt.engine.core.common.businessentities.network.Bond) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 34 with Bond

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

the class BackendHostResource method toParameters.

private HostSetupNetworksParameters toParameters(Action action) {
    HostSetupNetworksParameters parameters = new HostSetupNetworksParameters(guid);
    Map<Guid, NetworkAttachment> attachmentsById = getBackendNetworkAttachments();
    if (action.isSetModifiedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getModifiedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getNetworkAttachments().add(attachment);
        }
    }
    if (action.isSetSynchronizedNetworkAttachments()) {
        Map<Guid, NetworkAttachment> networkAttachmentFromParams = Entities.businessEntitiesById(parameters.getNetworkAttachments());
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getSynchronizedNetworkAttachments().getNetworkAttachments()) {
            if (model.isSetId()) {
                Guid networkAttachmentId = asGuid(model.getId());
                if (networkAttachmentFromParams.containsKey(networkAttachmentId)) {
                    networkAttachmentFromParams.get(networkAttachmentId).setOverrideConfiguration(true);
                } else if (attachmentsById.containsKey(networkAttachmentId)) {
                    NetworkAttachment networkAttachment = attachmentsById.get(networkAttachmentId);
                    networkAttachment.setOverrideConfiguration(true);
                    parameters.getNetworkAttachments().add(networkAttachment);
                } else {
                    return handleError(new EntityNotFoundException("NetworkAttachment.id: " + model.getId()), true);
                }
            }
        }
    }
    if (action.isSetModifiedLabels()) {
        for (NetworkLabel label : action.getModifiedLabels().getNetworkLabels()) {
            NicLabel nicLabel = new NicLabel();
            nicLabel.setLabel(label.getId());
            if (label.isSetHostNic()) {
                nicLabel.setNicId(label.getHostNic().isSetId() ? asGuid(label.getHostNic().getId()) : null);
                nicLabel.setNicName(label.getHostNic().getName());
            }
            parameters.getLabels().add(nicLabel);
        }
    }
    if (action.isSetRemovedLabels()) {
        for (NetworkLabel label : action.getRemovedLabels().getNetworkLabels()) {
            parameters.getRemovedLabels().add(label.getId());
        }
    }
    if (action.isSetRemovedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getRemovedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getRemovedNetworkAttachments().add(attachment.getId());
        }
    }
    BusinessEntityMap<Bond> bonds = getBackendHostBonds();
    if (action.isSetModifiedBonds()) {
        BusinessEntityMap<VdsNetworkInterface> nicsFromBackend = getBackendNics();
        for (HostNic bond : action.getModifiedBonds().getHostNics()) {
            completeSlaveNames(nicsFromBackend, bond);
            parameters.getCreateOrUpdateBonds().add(mapBonds(bonds, bond));
        }
    }
    if (action.isSetRemovedBonds()) {
        for (HostNic bond : action.getRemovedBonds().getHostNics()) {
            parameters.getRemovedBonds().add(mapBonds(bonds, bond).getId());
        }
    }
    if (action.isSetCheckConnectivity()) {
        parameters.setRollbackOnFailure(action.isCheckConnectivity());
    }
    if (action.isSetConnectivityTimeout()) {
        parameters.setConectivityTimeout(action.getConnectivityTimeout());
    }
    return parameters;
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) NetworkLabel(org.ovirt.engine.api.model.NetworkLabel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Aggregations

Bond (org.ovirt.engine.core.common.businessentities.network.Bond)34 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)19 Test (org.junit.Test)11 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)8 ArrayList (java.util.ArrayList)7 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)5 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)5 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)5 List (java.util.List)4 HostNic (org.ovirt.engine.api.model.HostNic)4 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 HashMap (java.util.HashMap)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)3 Guid (org.ovirt.engine.core.compat.Guid)3 Bonding (org.ovirt.engine.api.model.Bonding)2 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2