Search in sources :

Example 71 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method removeUnchangedBonds.

private void removeUnchangedBonds(List<VdsNetworkInterface> existingNics) {
    Map<Guid, VdsNetworkInterface> nicsById = Entities.businessEntitiesById(existingNics);
    List<CreateOrUpdateBond> createOrUpdateBonds = getParameters().getCreateOrUpdateBonds();
    for (Iterator<CreateOrUpdateBond> iterator = createOrUpdateBonds.iterator(); iterator.hasNext(); ) {
        CreateOrUpdateBond bondFromRequest = iterator.next();
        Guid idOfBondFromRequest = bondFromRequest.getId();
        boolean bondFromRequestIsNewBond = idOfBondFromRequest == null;
        if (!bondFromRequestIsNewBond) {
            if (bondFromRequest.equalToBond((Bond) nicsById.get(idOfBondFromRequest))) {
                iterator.remove();
            }
        }
    }
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid)

Example 72 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method validate.

@Override
protected boolean validate() {
    VDS host = getVds();
    final ValidationResult hostValidatorResult = new HostValidator(host, isInternalExecution()).validate();
    if (!hostValidatorResult.isValid()) {
        return validate(hostValidatorResult);
    }
    completeMissingDataInParameters();
    boolean requestValid = validateEntitiesFromRequest(getParameters().getNetworkAttachments()) && validateEntitiesFromRequest(getParameters().getCreateOrUpdateBonds());
    if (!requestValid) {
        return requestValid;
    }
    fillInUnsetBondingOptions();
    IdQueryParameters idParameters = new IdQueryParameters(getVdsId());
    QueryReturnValue existingBondsResponse = runInternalQuery(QueryType.GetHostBondsByHostId, idParameters);
    if (!existingBondsResponse.getSucceeded()) {
        return false;
    }
    List<VdsNetworkInterface> existingBonds = existingBondsResponse.getReturnValue();
    removeUnchangedAttachments();
    removeUnchangedBonds(existingBonds);
    ValidationResult hostSetupNetworkValidatorResult = validateWithHostSetupNetworksValidator(host);
    if (!hostSetupNetworkValidatorResult.isValid()) {
        return validate(hostSetupNetworkValidatorResult);
    }
    return validate(checkForOutOfSyncNetworks());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 73 with VdsNetworkInterface

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

the class NicLabelValidatorTest method assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed.

private void assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(HostSetupNetworksParameters params, VdsNetworkInterface attachLabelToNic) {
    List<VdsNetworkInterface> nics = new ArrayList<>();
    nics.add(attachLabelToNic);
    if (attachLabelToNic.getBondName() != null) {
        Bond bond = new Bond(attachLabelToNic.getBondName());
        bond.setId(Guid.newGuid());
        nics.add(bond);
    }
    NicLabel nicLabel = new NicLabel(attachLabelToNic.getId(), attachLabelToNic.getName(), "lbl1");
    assertThat(createNicLabelValidator(params, nics).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), failsWith(EngineMessage.LABEL_ATTACH_TO_IMPROPER_INTERFACE, ReplacementUtils.createSetVariableString("LABEL_ATTACH_TO_IMPROPER_INTERFACE_ENTITY", attachLabelToNic.getName())));
}
Also used : ArrayList(java.util.ArrayList) 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)

Example 74 with VdsNetworkInterface

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

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceValid.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceValid() {
    VdsNetworkInterface nic = createNic();
    List<VdsNetworkInterface> nics = Collections.singletonList(nic);
    NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
    assertThat(createNicLabelValidator(nics).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) Test(org.junit.Test)

Example 75 with VdsNetworkInterface

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

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToExistingSlave.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToExistingSlave() {
    VdsNetworkInterface nic = createNic();
    nic.setBondName("bond");
    assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(createHostSetupNetworksParams(), nic);
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

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