Search in sources :

Example 21 with NicLabel

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

the class NicLabelValidatorTest method nicActuallyExistsOrReferencesNewBondTrue.

@Test
public void nicActuallyExistsOrReferencesNewBondTrue() {
    NicLabelValidator validator = spy(createNicLabelValidator());
    mockIsNicActuallyExistsOrReferencesNewBond(validator, true);
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicName("anyName");
    assertThat(validator.nicActuallyExistsOrReferencesNewBond(nicLabel), isValid());
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) Test(org.junit.Test)

Example 22 with NicLabel

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

the class NicLabelValidatorTest method nicActuallyExistsOrReferencesNewBondFalse.

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

Example 23 with NicLabel

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

the class NicLabelValidatorTest method labelBeingAttachedToValidBondNotBond.

@Test
public void labelBeingAttachedToValidBondNotBond() {
    VdsNetworkInterface nic = createNic();
    List<VdsNetworkInterface> nics = Collections.singletonList(nic);
    NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
    assertThat(createNicLabelValidator(nics).labelBeingAttachedToValidBond(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 24 with NicLabel

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

the class UnmanagedNetworkValidatorTest method testValidateLabelsForVlan.

@Test
public void testValidateLabelsForVlan() {
    Nic nic = createNic("eth0");
    NicLabel label = new NicLabel(null, "eth1", "label1");
    NicLabel labelWithUnmanagedNetwork = new NicLabel(null, "eth0", "labelOnUnmanaged");
    Collection<NicLabel> labels = Arrays.asList(label, labelWithUnmanagedNetwork);
    VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
    List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
    Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
    assertEquals(1, nicsWithUnmanagedNetworks.size());
    String vlanNicName = nicsWithUnmanagedNetworks.iterator().next();
    ValidationResult result = validator.validateLabels(vlanNicName, labels);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_LABEL_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(LABEL, "labelOnUnmanaged"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
    NicLabel labelWithoutUnmanaged = new NicLabel(null, "eth_other", "label1");
    Collection<NicLabel> labelsNotOnUnmanagedNetwork = Collections.singletonList(labelWithoutUnmanaged);
    result = validator.validateLabels(vlanNicName, labelsNotOnUnmanagedNetwork);
    assertTrue(result.isValid());
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 25 with NicLabel

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

the class UnmanagedNetworkValidatorTest method testValidateLabels.

@Test
public void testValidateLabels() {
    String nicWithUnmanagedNetwork = "eth_unmanaged";
    NicLabel label = new NicLabel(null, "eth1", "label1");
    NicLabel labelWithUnmanagedNetwork = new NicLabel(null, nicWithUnmanagedNetwork, "labelOnUnmanaged");
    Collection<NicLabel> labels = Arrays.asList(label, labelWithUnmanagedNetwork);
    ValidationResult result = validator.validateLabels(nicWithUnmanagedNetwork, labels);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_LABEL_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(LABEL, "labelOnUnmanaged"), ReplacementUtils.createSetVariableString(NIC, "eth_unmanaged")));
    NicLabel labelWithoutUnmanaged = new NicLabel(null, "eth_other", "label1");
    Collection<NicLabel> labelsNotOnUnmanagedNetwork = Collections.singletonList(labelWithoutUnmanaged);
    result = validator.validateLabels(nicWithUnmanagedNetwork, labelsNotOnUnmanagedNetwork);
    assertTrue(result.isValid());
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) 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