use of org.ovirt.engine.core.common.job.StepEnum in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method createJobToMonitor.
private void createJobToMonitor(Cluster cluster, GlusterAsyncTask task) {
if (!isTaskToBeMonitored(task)) {
// there's no need to monitor jobs that are failed or completed
return;
}
StepEnum step = task.getType().getStep();
ActionType actionType;
switch(step) {
case REBALANCING_VOLUME:
actionType = ActionType.StartRebalanceGlusterVolume;
break;
case REMOVING_BRICKS:
actionType = ActionType.StartRemoveGlusterVolumeBricks;
break;
default:
actionType = ActionType.Unknown;
}
String volumeName = task.getTaskParameters().getVolumeName();
GlusterVolumeEntity vol = volumeDao.getByName(cluster.getId(), volumeName);
if (vol == null) {
log.info("Volume '{}' does not exist yet for task detected from CLI '{}', not adding to engine", volumeName, task);
return;
}
Guid jobId = addJob(cluster, task, actionType, vol);
Guid execStepId = addExecutingStep(jobId);
Guid asyncStepId = addAsyncTaskStep(cluster, task, step, execStepId);
Step asyncStep = stepDao.get(asyncStepId);
executionHandler.updateStepExternalId(asyncStep, task.getTaskId(), ExternalSystemType.GLUSTER);
updateVolumeBricksAndLock(cluster, task, vol);
}
use of org.ovirt.engine.core.common.job.StepEnum in project ovirt-engine by oVirt.
the class ExportOvaCommand method createOvaCreationStepContext.
protected CommandContext createOvaCreationStepContext() {
CommandContext commandCtx = null;
StepEnum step = StepEnum.CREATING_OVA;
try {
Step ovaCreationStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), step, ExecutionMessageDirector.resolveStepMessage(step, Collections.emptyMap()));
ExecutionContext ctx = new ExecutionContext();
ctx.setStep(ovaCreationStep);
ctx.setMonitored(true);
commandCtx = cloneContext().withoutCompensationContext().withExecutionContext(ctx).withoutLock();
} catch (RuntimeException e) {
log.error("Failed to create command context of creating OVA '{}': {}", getVmName(), e.getMessage());
log.debug("Exception", e);
}
return commandCtx;
}
use of org.ovirt.engine.core.common.job.StepEnum in project ovirt-engine by oVirt.
the class VdsCommandsHelper method updateStepMessage.
private void updateStepMessage(CommandBase<?> cmd, Guid vdsForExecution) {
// As an HSM job can run on any host, we want to display the host running the job when it is
// chosen. To do so, we look for a corresponding command step with an "_ON_HOST" suffix that
// is supposed to contain a "vds" placeholder.
StepEnum stepEnum = null;
try {
stepEnum = StepEnum.valueOf(getStepWithHostname(cmd));
} catch (IllegalArgumentException e) {
// Ignore this exception and do nothing as no corresponding step_ON_HOST found.
log.debug("No StepEnum found for " + getStepWithHostname(cmd));
return;
}
Step step = cmd.getExecutionContext().getStep();
Map<String, String> jobProperties = cmd.getJobMessageProperties();
jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), vdsDao.get(vdsForExecution).getName());
step.setDescription(ExecutionMessageDirector.resolveStepMessage(stepEnum, jobProperties));
stepDao.update(step);
// Add an audit log entry if a corresponding AuditLogType exists. Note that we expect an AuditLogType
// with name equals to Step_Enum to exist. If an AuditLogType exists, the arguments in the audit
// message must match these in the StepEnum message.
AuditLogType logType = null;
try {
logType = AuditLogType.valueOf(getAuditLogType(cmd));
} catch (IllegalArgumentException e) {
// Ignore this exception and do nothing as no corresponding AuditLogType found.
log.debug("No AuditLogType found for " + getAuditLogType(cmd));
return;
}
jobProperties.entrySet().stream().forEach(entry -> cmd.addCustomValue(entry.getKey(), entry.getValue()));
Injector.get(AuditLogDirector.class).log(cmd, logType);
}
Aggregations