Search in sources :

Example 1 with NetworkImplementationDetails

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

the class HostSetupNetworksCommand method checkForOutOfSyncNetworks.

private ValidationResult checkForOutOfSyncNetworks() {
    for (NetworkAttachment networkAttachment : getParameters().getNetworkAttachments()) {
        boolean newNetworkAttachment = networkAttachment.getId() == null;
        if (newNetworkAttachment) {
            // attachment to be yet created cannot be out of sync.
            continue;
        }
        boolean doNotCheckForOutOfSync = networkAttachment.isOverrideConfiguration();
        if (doNotCheckForOutOfSync) {
            continue;
        }
        Map<Guid, NetworkAttachment> existingNetworkAttachmentMap = Entities.businessEntitiesById(getExistingAttachments());
        NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentMap.get(networkAttachment.getId());
        VdsNetworkInterface nic = NetworkUtils.hostInterfacesByNetworkName(getExistingNics()).get(existingNetworkAttachment.getNetworkName());
        NetworkImplementationDetails networkImplementationDetails = nic.getNetworkImplementationDetails();
        boolean networkIsNotInSync = networkImplementationDetails != null && !networkImplementationDetails.isInSync();
        if (networkIsNotInSync) {
            return new ValidationResult(EngineMessage.NETWORKS_NOT_IN_SYNC, ReplacementUtils.createSetVariableString("NETWORK_NOT_IN_SYNC", existingNetworkAttachment.getNetworkName()));
        }
    }
    return ValidationResult.VALID;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 2 with NetworkImplementationDetails

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

the class HostNicsUtil method findHostNics.

private List<VdsNetworkInterface> findHostNics(Guid hostId, Function<Guid, Guid> hostClusterIdFinder, Guid userID, boolean isFiltered) {
    final List<VdsNetworkInterface> vdsInterfaces = interfaceDao.getAllInterfacesForVds(hostId, userID, isFiltered);
    // 1. here we return all interfaces (eth0, eth1, eth2) - the first
    // condition
    // 2. we also return bonds that connected to network and has interfaces
    // - the second condition
    // i.e.
    // we have:
    // Network | Interface
    // -------------------
    // red-> |->eth0
    // |->eth1
    // | |->eth2
    // blue-> |->bond0->|->eth3
    // |->bond1
    // 
    // we return: eth0, eth1, eth2, eth3, bond0
    // we don't return bond1 because he is not connected to network and has
    // no child interfaces
    List<VdsNetworkInterface> interfaces = new ArrayList<>(vdsInterfaces.size());
    if (!vdsInterfaces.isEmpty()) {
        final Guid clusterId = hostClusterIdFinder.apply(hostId);
        Map<String, Network> networks = Entities.entitiesByName(networkDao.getAllForCluster(clusterId));
        for (final VdsNetworkInterface nic : vdsInterfaces) {
            if (!nic.isBond() || nicDoesHaveSlaves(vdsInterfaces, nic)) {
                interfaces.add(nic);
                Network network = networks.get(nic.getNetworkName());
                NetworkImplementationDetails networkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(nic, network);
                nic.setNetworkImplementationDetails(networkImplementationDetails);
            }
        }
    }
    return interfaces;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

Example 3 with NetworkImplementationDetails

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

the class HostSetupNetworksValidatorTest method validateValidBondsForBondMode.

private void validateValidBondsForBondMode(boolean isValidForAllModes, boolean isVmNetwork, boolean isInSync, boolean isOverriddenConfiguration, BondMode bondMode) {
    String networkName = "network";
    String bondName = "bondName";
    Network network = createNetworkWithName(networkName);
    network.setVmNetwork(isVmNetwork);
    NetworkImplementationDetails networkImplementationDetails = new NetworkImplementationDetails(isInSync, true);
    Bond bond = createBond(bondName, networkName, null);
    bond.setBondOptions(bondMode.getConfigurationValue());
    bond.setNetworkImplementationDetails(networkImplementationDetails);
    NetworkAttachment networkAttachment = createNetworkAttachment(network, bond);
    networkAttachment.setOverrideConfiguration(isOverriddenConfiguration);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addNetworks(network).addExistingInterfaces(bond).build();
    boolean expectValidValidationResult = isValidForAllModes || bondMode.isBondModeValidForVmNetwork();
    List<NetworkAttachment> attachmentsToConfigure = Collections.singletonList(networkAttachment);
    ValidationResult result = validator.validateBondModeVsNetworksAttachedToIt(attachmentsToConfigure);
    if (expectValidValidationResult) {
        collector.checkThat(result, isValid());
    } else {
        collector.checkThat(result, failsWith(EngineMessage.INVALID_BOND_MODE_FOR_BOND_WITH_VM_NETWORK, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_BOND_NAME, bondName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkName)));
    }
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails) 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 4 with NetworkImplementationDetails

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

the class UnmanagedNetworkValidatorTest method createVlanNic.

public VdsNetworkInterface createVlanNic(VdsNetworkInterface baseNic, String nicName, Integer vlanId, boolean isManaged) {
    VdsNetworkInterface vlanNic = new VdsNetworkInterface();
    vlanNic.setId(Guid.newGuid());
    vlanNic.setName(nicName);
    vlanNic.setVlanId(vlanId);
    vlanNic.setBaseInterface(baseNic.getName());
    vlanNic.setNetworkName("unmanagedNetworkName");
    vlanNic.setNetworkImplementationDetails(new NetworkImplementationDetails(true, isManaged));
    return vlanNic;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

Example 5 with NetworkImplementationDetails

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

the class UnmanagedNetworkValidatorTest method createNicWithNetworkImplementationDetails.

private Nic createNicWithNetworkImplementationDetails(String name, boolean isManaged) {
    Nic nic = createNic(name);
    NetworkImplementationDetails networkImplementationDetails1 = new NetworkImplementationDetails(true, isManaged);
    nic.setNetworkImplementationDetails(networkImplementationDetails1);
    return nic;
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

Aggregations

NetworkImplementationDetails (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)9 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)7 Network (org.ovirt.engine.core.common.businessentities.network.Network)6 ArrayList (java.util.ArrayList)3 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)3 Guid (org.ovirt.engine.core.compat.Guid)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)1 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)1 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)1 HostNetwork (org.ovirt.engine.core.common.vdscommands.HostNetwork)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1