Search in sources :

Example 11 with Bond

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

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

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

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

the class HostSetupNetworksValidatorTest method testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved.

@Test
public void testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved() throws Exception {
    Bond bond = createBond("bondName");
    Bond differentBond = createBond("differentBond");
    VdsNetworkInterface slaveA = createBondSlave(bond, "slaveA");
    VdsNetworkInterface slaveB = createBondSlave(differentBond, "slaveB");
    setBondSlaves(bond, slaveA, slaveB);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(differentBond.getId())).addExistingInterfaces(bond, differentBond, slaveA, slaveB).build();
    doTestValidateModifiedBondSlaves(spy(validator), ValidationResult.VALID, ValidationResult.VALID, isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 15 with Bond

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

the class HostSetupNetworksValidatorTest method setUp.

@Before
public void setUp() throws Exception {
    host = new VDS();
    host.setId(Guid.newGuid());
    final VdsDynamic vdsDynamic = new VdsDynamic();
    host.setDynamicData(vdsDynamic);
    bond = new Bond();
    bond.setId(Guid.newGuid());
    when(mockNetworkExclusivenessValidatorResolver.resolveNetworkExclusivenessValidator()).thenReturn(mockNetworkExclusivenessValidator);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Before(org.junit.Before)

Aggregations

Bond (org.ovirt.engine.core.common.businessentities.network.Bond)34 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)19 Test (org.junit.Test)11 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)8 ArrayList (java.util.ArrayList)7 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)5 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)5 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)5 List (java.util.List)4 HostNic (org.ovirt.engine.api.model.HostNic)4 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 HashMap (java.util.HashMap)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)3 Guid (org.ovirt.engine.core.compat.Guid)3 Bonding (org.ovirt.engine.api.model.Bonding)2 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2