use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class MoveMacsTest method canMigrateMacsToAnotherMacPoolWhenMacToBeMigratedAlreadyExistInTargetPool.
@Test
public void canMigrateMacsToAnotherMacPoolWhenMacToBeMigratedAlreadyExistInTargetPool() {
// first mac will be already used.
String macUsedInTargetMacPool = macsToMigrate.get(0);
when(targetMacPool.isMacInUse(macUsedInTargetMacPool)).thenReturn(true);
when(vmNicDao.getAllMacsByClusterId(cluster.getId())).thenReturn(macsToMigrate);
EngineMessage engineMessage = ACTION_TYPE_FAILED_CANNOT_MIGRATE_MACS_DUE_TO_DUPLICATES;
Collection<String> replacements = ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singleton(macUsedInTargetMacPool));
assertThat(underTest.canMigrateMacsToAnotherMacPool(cluster, targetMacPoolId), ValidationResultMatchers.failsWith(engineMessage, replacements));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class MoveMacsTest method canMigrateMacsToAnotherMacPoolWhenTheresDuplicityAmongMacToBeMigrated.
@Test
public void canMigrateMacsToAnotherMacPoolWhenTheresDuplicityAmongMacToBeMigrated() {
// first mac will be duplicated
macsToMigrate.add(macsToMigrate.get(0));
when(vmNicDao.getAllMacsByClusterId(cluster.getId())).thenReturn(macsToMigrate);
EngineMessage engineMessage = ACTION_TYPE_FAILED_CANNOT_MIGRATE_MACS_DUE_TO_DUPLICATES;
Collection<String> replacements = ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singleton(macsToMigrate.get(0)));
assertThat(underTest.canMigrateMacsToAnotherMacPool(cluster, targetMacPoolId), ValidationResultMatchers.failsWith(engineMessage, replacements));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class RunVmOnceCommand method validateImpl.
@Override
protected boolean validateImpl() {
if (!super.validateImpl()) {
return false;
}
// set (null), the action will fail if only one of those parameters is null.
if (getParameters().getSysPrepUserName() == null ^ getParameters().getSysPrepPassword() == null) {
return failValidation(EngineMessage.VM_CANNOT_RUN_ONCE_WITH_ILLEGAL_SYSPREP_PARAM);
}
if (getParameters().getVmInit() != null && getParameters().getVmInit().isPasswordAlreadyStored()) {
VmBase temp = new VmBase();
temp.setId(getParameters().getVmId());
vmHandler.updateVmInitFromDB(temp, false);
getParameters().getVmInit().setRootPassword(temp.getVmInit().getRootPassword());
}
List<EngineMessage> msgs = openStackMetadataAdapter.validate(getParameters().getVmInit());
if (!CollectionUtils.isEmpty(msgs)) {
return failValidation(msgs);
}
return true;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class NetworkAttachmentsValidator method validateNetworkExclusiveOnNics.
public ValidationResult validateNetworkExclusiveOnNics() {
Map<String, List<NetworkType>> nicNameToNetworkTypesMap = createNicNameToNetworkTypesMap();
List<String> violatedNics = findViolatedNics(nicNameToNetworkTypesMap);
if (violatedNics.isEmpty()) {
return ValidationResult.VALID;
} else {
final EngineMessage violationMessage = networkExclusivenessValidator.getViolationMessage();
return new ValidationResult(violationMessage, ReplacementUtils.replaceWith(violationMessage + LIST_SUFFIX, violatedNics));
}
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostInterfaceValidator method interfaceExists.
/**
* @param nicName name of interface to be reported as a inexisting one.
* @return validation result
*/
public ValidationResult interfaceExists(String nicName) {
EngineMessage engineMessage = EngineMessage.HOST_NETWORK_INTERFACE_HAVING_NAME_DOES_NOT_EXIST;
String nicNameReplacement = ReplacementUtils.getVariableAssignmentString(engineMessage, nicName);
return ValidationResult.failWith(engineMessage, nicNameReplacement).when(iface == null);
}
Aggregations