Search in sources :

Example 61 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testValidRemovedBondsWhenBondIsRequired.

@Test
public void testValidRemovedBondsWhenBondIsRequired() throws Exception {
    String nicName = "nicName";
    bond.setName(nicName);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(bond.getId())).addExistingInterfaces(Collections.singletonList(bond)).build();
    NetworkAttachment requiredNetworkAttachment = new NetworkAttachment();
    requiredNetworkAttachment.setNicName(nicName);
    List<String> replacements = new ArrayList<>();
    EngineMessage engineMessage = EngineMessage.BOND_USED_BY_NETWORK_ATTACHMENTS;
    replacements.add(ReplacementUtils.getVariableAssignmentString(engineMessage, nicName));
    // null -- new network attachment with null id.
    replacements.addAll(replaceWith(HostSetupNetworksValidator.VAR_ATTACHMENT_IDS, Collections.<Guid>singletonList(null)));
    assertThat(validator.validRemovedBonds(Collections.singletonList(requiredNetworkAttachment)), failsWith(engineMessage, replacements));
}
Also used : ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Guid(org.ovirt.engine.core.compat.Guid) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 62 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method modifiedAttachmentNotRemovedAttachmentModifiedAndRemoved.

@Test
public void modifiedAttachmentNotRemovedAttachmentModifiedAndRemoved() {
    NetworkAttachment modifiedAttachment = createNetworkAttachment(new Network());
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedNetworkAttachments(modifiedAttachment)).build();
    assertThat(validator.modifiedAttachmentNotRemoved(modifiedAttachment), failsWith(EngineMessage.NETWORK_ATTACHMENT_IN_BOTH_LISTS, ReplacementUtils.createSetVariableString("NETWORK_ATTACHMENT_IN_BOTH_LISTS_ENTITY", modifiedAttachment.getId().toString())));
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 63 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method createValidatorForTestingValidateQosOverridden.

private HostSetupNetworksValidator createValidatorForTestingValidateQosOverridden(Network network) {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    networkAttachment.setNetworkId(network.getId());
    networkAttachment.setHostNetworkQos(new AnonymousHostNetworkQos());
    return new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(network).build();
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 64 with NetworkAttachment

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

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

the class HostSetupNetworksValidatorTest method testInvalidNetworkAttachmentIpConfiguration.

@Test
public void testInvalidNetworkAttachmentIpConfiguration() {
    HostSetupNetworksValidator validator = initValidator();
    NetworkAttachment networkAttachment = validator.getAttachmentsToConfigure().iterator().next();
    Collection<String> replacements = createReplacement(networkAttachment);
    EngineMessage engineMessage = EngineMessage.NETWORK_ATTACHMENT_MISSING_IP_CONFIGURATION;
    initMockNetworkAttachmentIpConfigurationValidator(engineMessage, replacements);
    assertThat(validator.validNewOrModifiedNetworkAttachments(), failsWith(engineMessage, replacements));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Aggregations

NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)167 Test (org.junit.Test)79 Network (org.ovirt.engine.core.common.businessentities.network.Network)62 Guid (org.ovirt.engine.core.compat.Guid)37 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)36 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)35 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)20 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)18 HashMap (java.util.HashMap)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)14 ArrayList (java.util.ArrayList)10 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)10 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)9 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)8 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)7 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)7 AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)6 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)5 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)5