Search in sources :

Example 11 with NicLabel

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

the class NicLabelValidatorTest method labelBeingAttachedToValidBondNewBondValid.

@Test
public void labelBeingAttachedToValidBondNewBondValid() {
    CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
    createOrUpdateBond.setName("bond");
    createOrUpdateBond.setSlaves(new HashSet<>(Arrays.asList("slave1", "slave2")));
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    params.getCreateOrUpdateBonds().add(createOrUpdateBond);
    NicLabel nicLabel = new NicLabel(createOrUpdateBond.getId(), createOrUpdateBond.getName(), "lbl1");
    assertThat(createNicLabelValidator(params, new ArrayList<>()).labelBeingAttachedToValidBond(nicLabel), isValid());
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Test(org.junit.Test)

Example 12 with NicLabel

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

the class NicLabelValidatorTest method labelBeingAttachedToValidBondExistingBondValid.

@Test
public void labelBeingAttachedToValidBondExistingBondValid() {
    Bond bond = new Bond("bond");
    bond.setSlaves(Arrays.asList("slave1", "slave2"));
    List<VdsNetworkInterface> nics = new ArrayList<>(Collections.singletonList(bond));
    NicLabel nicLabel = new NicLabel(bond.getId(), bond.getName(), "lbl1");
    assertThat(createNicLabelValidator(nics).labelBeingAttachedToValidBond(nicLabel), isValid());
}
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) Test(org.junit.Test)

Example 13 with NicLabel

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

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToSlaveOnRemovedBond.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToSlaveOnRemovedBond() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    VdsNetworkInterface slave = createNic();
    Bond bondWithSlave = new Bond("bond");
    bondWithSlave.setId(Guid.newGuid());
    bondWithSlave.setSlaves(Collections.singletonList(slave.getName()));
    params.getRemovedBonds().add(bondWithSlave.getId());
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicName(slave.getName());
    assertThat(createNicLabelValidator(params, Arrays.asList(bondWithSlave, slave)).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 14 with NicLabel

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

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToRemovedSlave.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToRemovedSlave() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    VdsNetworkInterface slave = createNic();
    Bond bondWithSlave = new Bond("bond");
    bondWithSlave.setSlaves(Collections.singletonList(slave.getName()));
    CreateOrUpdateBond updatedBond = new CreateOrUpdateBond();
    updatedBond.setName(bondWithSlave.getName());
    updatedBond.setSlaves(new HashSet<>());
    params.setCreateOrUpdateBonds(Collections.singletonList(updatedBond));
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicName(slave.getName());
    NicLabelValidator nicLabelValidator = createNicLabelValidator(params, Arrays.asList(bondWithSlave, slave));
    assertThat(nicLabelValidator.labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 15 with NicLabel

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

the class HostSetupNetworksValidatorTest method validateSlaveHasNoLabelsHasNewLabel.

@Test
public void validateSlaveHasNoLabelsHasNewLabel() {
    VdsNetworkInterface slave = createNic("slave");
    NicLabel nicLabel = new NicLabel(slave.getId(), slave.getName(), "lbl1");
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addLabels(nicLabel)).addExistingInterfaces(slave).build();
    assertValidateSlaveHasNoLabelsFailed(validator, slave.getName());
}
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