Search in sources :

Example 56 with NetworkAttachment

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

the class UnmanagedNetworkValidatorTest method testValidateAttachementsForVlans.

@Test
public void testValidateAttachementsForVlans() {
    String unmanagedBaseNicName = "eth0";
    NetworkAttachment attachement1 = new NetworkAttachment();
    attachement1.setNetworkName("network1");
    attachement1.setNicName(unmanagedBaseNicName);
    NetworkAttachment attachement2 = new NetworkAttachment();
    attachement2.setNetworkName("any2");
    attachement2.setNicName("eth1");
    List<NetworkAttachment> attachementList = Arrays.asList(attachement1, attachement2);
    Nic nic = createNic(unmanagedBaseNicName);
    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 filteredNicName = nicsWithUnmanagedNetworks.iterator().next();
    assertEquals(unmanagedBaseNicName, filteredNicName);
    ValidationResult result = validator.validateAttachements(filteredNicName, attachementList);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_ATTACHEMENT_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, "network1"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
    result = validator.validateAttachements("eth7", attachementList);
    assertTrue(result.isValid());
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 57 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testValidateQosOverriddenInterfacesWhenAttachmentDoesNotHaveQosOverridden.

@Test
public void testValidateQosOverriddenInterfacesWhenAttachmentDoesNotHaveQosOverridden() {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).build();
    assertThat(validator.validateQosOverriddenInterfaces(), ValidationResultMatchers.isValid());
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 58 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testValidateCustomPropertiesWhenCustomPropertyValidationFailed.

@Test
public void testValidateCustomPropertiesWhenCustomPropertyValidationFailed() throws Exception {
    Network networkA = createNetworkWithName("networkA");
    NetworkAttachment networkAttachment = createNetworkAttachment(networkA);
    Map<String, String> customProperties = new HashMap<>();
    customProperties.put("a", "b");
    networkAttachment.setProperties(customProperties);
    HostSetupNetworksValidator validator = spy(new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(networkA).build());
    // this was added just because of DI issues with 'Backend.getInstance().getErrorsTranslator()' is 'spyed' method
    // noinspection unchecked
    doReturn(Collections.emptyList()).when(validator).translateErrorMessages(any());
    EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
    assertThat(validator.validateCustomProperties(SimpleCustomPropertiesUtil.getInstance(), Collections.emptyMap(), Collections.emptyMap()), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, networkA.getName())));
}
Also used : HashMap(java.util.HashMap) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) 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)

Example 59 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method validateBondOptionsForNewAttachementWithOutOfSyncVmNetworOverridden.

@Test
public void validateBondOptionsForNewAttachementWithOutOfSyncVmNetworOverridden() {
    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 60 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksLabelRemovedFromNicValid.

@Test
public void testNotRemovingLabeledNetworksLabelRemovedFromNicValid() {
    VdsNetworkInterface nicWithLabel = createNic("nicWithLabel");
    final String labelName = "lbl1";
    nicWithLabel.setLabels(Collections.singleton(labelName));
    Network network = createNetworkWithNameAndLabel("net", labelName);
    NetworkAttachment removedAttachment = createNetworkAttachment(network, nicWithLabel);
    assertTestNotRemovingLabeledNetworksValid(nicWithLabel, removedAttachment, new ParametersBuilder().addRemovedLabels(labelName).build(), network);
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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