use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class ValidateVmMacsQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
final VM vm1 = createVm(VM_ID1);
final VM vm2 = createVm(VM_ID2);
vms.add(vm1);
vms.add(vm2);
when(vmMacsValidation.validate(vm2)).thenReturn(new ValidationResult(EngineMessage.Unassigned, REPLACEMENT1, REPLACEMENT2));
getQuery().executeQueryCommand();
final QueryReturnValue queryReturnValue = getQuery().getQueryReturnValue();
final Map<Guid, List<List<String>>> actual = queryReturnValue.getReturnValue();
assertValidVmInOutput(actual, VM_ID1);
assertInvalidVmInOutput(actual, VM_ID2, VALIDATION_MESSAGES);
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class ExportOvaCommand method validateTargetFolder.
private ValidationResult validateTargetFolder() {
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("target_directory", getParameters().getDirectory()), new Pair<>("validate_only", "True")).logFileDirectory(CreateOvaCommand.CREATE_OVA_LOG_DIRECTORY).logFilePrefix("ovirt-export-ova-validate-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.EXPORT_OVA_PLAYBOOK);
boolean succeeded = false;
try {
succeeded = ansibleExecutor.runCommand(command).getAnsibleReturnCode() == AnsibleReturnCode.OK;
} catch (IOException | InterruptedException e) {
log.error("Invalid target for OVA (directory={}, host={}): {}", getParameters().getDirectory(), getVdsName(), e.getMessage());
log.debug("Exception", e);
}
return succeeded ? ValidationResult.VALID : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_INVALID_OVA_DESTINATION_FOLDER, String.format("$vdsName %s", getVdsName()), String.format("$directory %s", getParameters().getDirectory()));
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class HostValidator method hostStatusLegalForSetupNetworks.
private ValidationResult hostStatusLegalForSetupNetworks() {
VDSStatus hostStatus = host.getStatus();
boolean hostStatusLegalForSetupNetworks = LEGAL_STATUSES.contains(hostStatus) || hostStatus == VDSStatus.Installing && internalExecution;
if (!hostStatusLegalForSetupNetworks) {
logger.error("Unable to setup network: operation can only be done when Host status is one of: {};" + " current status is {}", LEGAL_STATUSES_STR, hostStatus);
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL, ReplacementUtils.replaceWith(VAR_HOST_STATUS, LEGAL_STATUSES, ",", LEGAL_STATUSES.size()));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class HostValidator method validate.
public ValidationResult validate() {
ValidationResult vr = ValidationResult.VALID;
vr = skipValidation(vr) ? vr : hostExist();
vr = skipValidation(vr) ? vr : hostStatusLegalForSetupNetworks();
return vr;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NicLabelValidator method validNewOrModifiedLabels.
public ValidationResult validNewOrModifiedLabels() {
ValidationResult vr = ValidationResult.VALID;
Iterator<NicLabel> iterator = params.getLabels().iterator();
while (iterator.hasNext() && vr.isValid()) {
NicLabel nicLabel = iterator.next();
vr = skipValidation(vr) ? vr : validateCoherentNicIdentification(nicLabel);
vr = skipValidation(vr) ? vr : nicActuallyExistsOrReferencesNewBond(nicLabel);
vr = skipValidation(vr) ? vr : labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel);
vr = skipValidation(vr) ? vr : labelBeingAttachedToValidBond(nicLabel);
}
return vr;
}
Aggregations