use of org.ovirt.engine.core.common.errors.EngineMessage 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));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method notMovingLabeledNetworkToDifferentNicCommonTest.
private void notMovingLabeledNetworkToDifferentNicCommonTest(boolean nicContainslabel, boolean labelShouldBeRemovedFromNic, boolean labelShouldBeAddedToNic, boolean valid) {
VdsNetworkInterface nic = createNic("nicWithLabel");
if (nicContainslabel) {
nic.setLabels(Collections.singleton("lbl1"));
}
Network movedNetwork = createNetworkWithNameAndLabel("net", "lbl1");
NetworkAttachment existingAttachment = createNetworkAttachment(movedNetwork, nic);
NetworkAttachment updatedAttachment = new NetworkAttachment(existingAttachment);
updatedAttachment.setNicId(Guid.newGuid());
updatedAttachment.setNicName(nic.getName() + "not");
HostSetupNetworksParameters params = new HostSetupNetworksParameters(host.getId());
if (labelShouldBeRemovedFromNic) {
params.getRemovedLabels().add("lbl1");
}
if (labelShouldBeAddedToNic) {
NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
params.getLabels().add(nicLabel);
}
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(params).addExistingInterfaces(nic).addExistingAttachments(existingAttachment).addNetworks(movedNetwork).build();
if (valid) {
assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), isValid());
} else {
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_CANNOT_MOVE_LABELED_NETWORK_TO_ANOTHER_NIC;
assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), failsWith(engineMessage, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, movedNetwork.getName()), ReplacementUtils.getVariableAssignmentString(engineMessage, movedNetwork.getLabel())));
}
}
use of org.ovirt.engine.core.common.errors.EngineMessage 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);
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidRemovedBondsWhenReferencedInterfaceBondViaInexistingId.
@Test
public void testValidRemovedBondsWhenReferencedInterfaceBondViaInexistingId() throws Exception {
Guid idOfInexistingInterface = Guid.newGuid();
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(idOfInexistingInterface)).build();
EngineMessage engineMessage = EngineMessage.NETWORK_BOND_RECORDS_DOES_NOT_EXISTS;
assertThat(validator.validRemovedBonds(Collections.emptyList()), failsWith(engineMessage, ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singletonList(idOfInexistingInterface))));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class MoveMacs method canMigrateMacsToAnotherMacPool.
public ValidationResult canMigrateMacsToAnotherMacPool(ReadMacPool targetPool, List<String> macsToMigrate) {
if (targetPool.isDuplicateMacAddressesAllowed()) {
return ValidationResult.VALID;
}
Map<String, Long> occurrenceCount = macsToMigrate.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
List<String> problematicMacs = macsToMigrate.stream().distinct().filter(mac -> targetPool.isMacInUse(mac) || occurrenceCount.get(mac) > 1).collect(Collectors.toList());
EngineMessage engineMessage = ACTION_TYPE_FAILED_CANNOT_MIGRATE_MACS_DUE_TO_DUPLICATES;
Collection<String> replacements = ReplacementUtils.getListVariableAssignmentString(engineMessage, problematicMacs);
return ValidationResult.failWith(engineMessage, replacements).when(!problematicMacs.isEmpty());
}
Aggregations