Search in sources :

Example 56 with VdsNetworkInterface

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

the class NetworkCommonUtils method fillBondSlaves.

public static void fillBondSlaves(Collection<? extends VdsNetworkInterface> nics) {
    Map<String, List<String>> bondToSlaves = getBondNameToBondSlaveNamesMap(nics);
    for (VdsNetworkInterface nic : nics) {
        if (nic instanceof Bond) {
            Bond bond = (Bond) nic;
            bond.setSlaves(bondToSlaves.containsKey(bond.getName()) ? bondToSlaves.get(bond.getName()) : new ArrayList<String>());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) List(java.util.List) ArrayList(java.util.ArrayList) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 57 with VdsNetworkInterface

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

the class NetworkDeviceHelperImpl method updateHostNicVfsConfigWithNumVfsData.

@Override
public void updateHostNicVfsConfigWithNumVfsData(HostNicVfsConfig hostNicVfsConfig) {
    VdsNetworkInterface nic = getNicById(hostNicVfsConfig.getNicId());
    updateVfsConfigWithNumOfVfsData(hostNicVfsConfig, nic, getDevicesByHostId(nic.getVdsId()));
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 58 with VdsNetworkInterface

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

the class NicLabelValidator method labelBeingAttachedToValidBond.

ValidationResult labelBeingAttachedToValidBond(NicLabel nicLabel) {
    String interfaceName = nicLabel.getNicName();
    VdsNetworkInterface nic = existingInterfacesMap.get(interfaceName);
    if (nic instanceof Bond) {
        CreateOrUpdateBond createOrUpdateBond = createOrUpdateBondBusinessEntityMap.containsKey(interfaceName) ? createOrUpdateBondBusinessEntityMap.get(interfaceName) : CreateOrUpdateBond.fromBond((Bond) nic);
        if (createOrUpdateBond.getSlaves().size() < 2) {
            return new ValidationResult(EngineMessage.IMPROPER_BOND_IS_LABELED, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_BOND_NAME, createOrUpdateBond.getName()));
        }
    }
    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)

Example 59 with VdsNetworkInterface

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

the class NicLabelValidator method shouldBeConfigureAsBondSlave.

private boolean shouldBeConfigureAsBondSlave(String interfaceName) {
    // Check if the interface was updated to be a bond's slave
    for (CreateOrUpdateBond createOrUpdateBond : params.getCreateOrUpdateBonds()) {
        if (createOrUpdateBond.getSlaves().contains(interfaceName)) {
            return true;
        }
    }
    // The interface wasn't updated to be a slave, check if currently it is a slave.
    VdsNetworkInterface existingNic = existingInterfacesMap.get(interfaceName);
    if (existingNic == null) {
        return false;
    }
    if (existingNic.isPartOfBond()) {
        String bondName = existingNic.getBondName();
        VdsNetworkInterface bond = existingInterfacesMap.get(bondName);
        boolean bondWasRemoved = params.getRemovedBonds().contains(bond.getId());
        boolean slaveWasRemovedFromBond = createOrUpdateBondBusinessEntityMap.containsKey(bondName) && !createOrUpdateBondBusinessEntityMap.get(bondName).getSlaves().contains(interfaceName);
        return !bondWasRemoved && !slaveWasRemovedFromBond;
    }
    return false;
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 60 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method isBonding.

private boolean isBonding(NetworkAttachment attachment, BusinessEntityMap<VdsNetworkInterface> nics) {
    for (CreateOrUpdateBond bond : getParameters().getCreateOrUpdateBonds()) {
        if (bond.getName() != null && bond.getName().equals(attachment.getNicName())) {
            return true;
        }
    }
    VdsNetworkInterface attachedNic = nics.get(attachment.getNicId(), attachment.getNicName());
    Validate.notNull(attachedNic, "NicId/NicName must refer to a resolvable interface");
    return Boolean.TRUE.equals(attachedNic.getBonded());
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Aggregations

VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)233 Test (org.junit.Test)68 Network (org.ovirt.engine.core.common.businessentities.network.Network)47 ArrayList (java.util.ArrayList)46 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)35 Guid (org.ovirt.engine.core.compat.Guid)30 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)23 List (java.util.List)19 HashMap (java.util.HashMap)18 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)18 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)17 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)16 VDS (org.ovirt.engine.core.common.businessentities.VDS)15 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)14 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 Map (java.util.Map)12 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)9 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)8 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)8