Search in sources :

Example 6 with NicLabel

use of org.ovirt.engine.core.common.businessentities.network.NicLabel 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 7 with NicLabel

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

the class NicLabelValidatorTest method nicActuallyExistsOrReferencesNoNicName.

@Test
public void nicActuallyExistsOrReferencesNoNicName() {
    NicLabelValidator validator = spy(createNicLabelValidator());
    mockIsNicActuallyExistsOrReferencesNewBond(validator, true);
    assertThatNicActuallyExistsOrReferencesNewBondFailed(validator, new NicLabel());
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) Test(org.junit.Test)

Example 8 with NicLabel

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

the class NicLabelValidatorTest method nicActuallyExistsOrReferencesNewBondTrueButBondIsRemoved.

@Test
public void nicActuallyExistsOrReferencesNewBondTrueButBondIsRemoved() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    Guid removedBondId = Guid.newGuid();
    params.getRemovedBonds().add(removedBondId);
    NicLabelValidator validator = spy(createNicLabelValidator(params));
    mockIsNicActuallyExistsOrReferencesNewBond(validator, true);
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicId(removedBondId);
    nicLabel.setNicName("anyName");
    assertThatNicActuallyExistsOrReferencesNewBondFailed(validator, nicLabel);
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 9 with NicLabel

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

the class NicLabelValidatorTest method validateCoherentNicIdentificationTest.

@Test
public void validateCoherentNicIdentificationTest() {
    NicLabelValidator validator = spy(createNicLabelValidator());
    ValidationResult validationReuslt = new ValidationResult(EngineMessage.Unassigned);
    doReturn(validationReuslt).when(validator).validateCoherentIdentification(any(), any(), any(), any(), any());
    assertEquals(validationReuslt, validator.validateCoherentNicIdentification(new NicLabel()));
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 10 with NicLabel

use of org.ovirt.engine.core.common.businessentities.network.NicLabel 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)

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