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());
}
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());
}
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())));
}
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())));
}
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);
}
Aggregations