Search in sources :

Example 16 with CreateOrUpdateBond

use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.

the class NicNameNicIdCompleterTest method testProperBondBindingToNicNameAndNicIdAccessors.

@Test
public void testProperBondBindingToNicNameAndNicIdAccessors() {
    CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
    createOrUpdateBond.setName("nic name");
    createOrUpdateBond.setId(Guid.newGuid());
    NicNameAndNicIdAccessors accessors = new NicNameAndNicIdAccessors.FromCreateOrUpdateBondData(createOrUpdateBond);
    assertThat(accessors.getId(), is(createOrUpdateBond.getId()));
    assertThat(accessors.getName(), is(createOrUpdateBond.getName()));
    accessors.setId(Guid.newGuid());
    accessors.setName("another name");
    assertThat(createOrUpdateBond.getId(), is(accessors.getId()));
    assertThat(createOrUpdateBond.getName(), is(accessors.getName()));
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) NicNameAndNicIdAccessors(org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors) Test(org.junit.Test)

Example 17 with CreateOrUpdateBond

use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.

the class HostSetupNetworksValidatorTest method testAddNetworkToNicAlongWithAddingItIntoBond.

// TODO MM: same test for vlan.
@Test
public void testAddNetworkToNicAlongWithAddingItIntoBond() {
    Network networkA = createNetworkWithName("networkA");
    VdsNetworkInterface nicA = createNic("nicA");
    VdsNetworkInterface nicB = createNic("nicB");
    NetworkAttachment networkAttachment = createNetworkAttachment(networkA, (Guid) null);
    networkAttachment.setNicId(nicA.getId());
    networkAttachment.setNicName(nicA.getName());
    networkAttachment.setNetworkId(networkA.getId());
    networkAttachment.setNetworkName(networkA.getName());
    CreateOrUpdateBond createOrUpdateBond = createNewCreateOrUpdateBond(Guid.newGuid(), "bond1", nicA.getName(), nicB.getName());
    addNetworkIdToNetworkDaoMock(networkA);
    addNetworkToClusterDaoMock(networkA.getId());
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment).addBonds(createOrUpdateBond).build()).addExistingInterfaces(nicA, nicB).addNetworks(networkA).build();
    ValidationResult validate = validator.validate();
    assertThat(validate, not(isValid()));
    EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME;
    assertThat(validate, failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, nicA.getName()), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkA.getName())));
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 18 with CreateOrUpdateBond

use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.

the class HostSetupNetworksValidatorTest method testValidModifiedBondsFailsWhenReferencingExistingNonBondInterface.

@Test
public void testValidModifiedBondsFailsWhenReferencingExistingNonBondInterface() throws Exception {
    CreateOrUpdateBond createOrUpdateBond = createNewCreateOrUpdateBondWithNameAndId();
    final EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_IS_NOT_BOND;
    ValidationResult notABondValidationResult = new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, createOrUpdateBond.getName()));
    doTestValidModifiedBonds(createOrUpdateBond, notABondValidationResult, notABondValidationResult, ValidationResult.VALID);
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 19 with CreateOrUpdateBond

use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    VdsNetworkInterface slave = createNic();
    CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
    createOrUpdateBond.setName("bond");
    createOrUpdateBond.setSlaves(Collections.singleton(slave.getName()));
    params.setCreateOrUpdateBonds(Collections.singletonList(createOrUpdateBond));
    assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(params, slave);
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Test(org.junit.Test)

Example 20 with CreateOrUpdateBond

use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method labelBeingAttachedToValidBondAttachedBondBecomingNotValid.

@Test
public void labelBeingAttachedToValidBondAttachedBondBecomingNotValid() {
    Bond existingBond = new Bond("bond");
    existingBond.setSlaves(Arrays.asList("slave1", "slave2"));
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    CreateOrUpdateBond updatedBond = new CreateOrUpdateBond();
    updatedBond.setName(existingBond.getName());
    updatedBond.setSlaves(new HashSet<>());
    params.getCreateOrUpdateBonds().add(updatedBond);
    assertLabelBeingAttachedToValidBondFailed(params, existingBond);
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) 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)

Aggregations

CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)38 Test (org.junit.Test)18 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)14 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)10 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)8 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)8 Guid (org.ovirt.engine.core.compat.Guid)6 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)5 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)4 BondNetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Network (org.ovirt.engine.core.common.businessentities.network.Network)3 LogicalNetworkModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)3 NetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel)3 List (java.util.List)2 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)2 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)2 BaseCommandTarget (org.ovirt.engine.ui.uicommonweb.BaseCommandTarget)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2