Search in sources :

Example 1 with VmJob

use of org.ovirt.engine.core.common.businessentities.VmJob in project ovirt-engine by oVirt.

the class MergeCommandCallback method doPolling.

@Override
public void doPolling(Guid cmdId, List<Guid> childCmdIds) {
    MergeCommand<MergeParameters> command = getCommand(cmdId);
    Guid jobId = command.getParameters().getVmJobId();
    VmJob vmJob = vmJobsMonitoring.getJobById(jobId);
    // If the VM Job exists, the command is still active
    if (vmJob != null) {
        log.info("Waiting on merge command to complete (jobId = {})", jobId);
        return;
    }
    // It finished; a command will be called later to determine the status.
    command.setSucceeded(true);
    command.setCommandStatus(CommandStatus.SUCCEEDED);
    command.persistCommand(command.getParameters().getParentCommand(), true);
    log.info("Merge command (jobId = {}) has completed for images '{}'..'{}'", jobId, command.getParameters().getBaseImage().getImageId(), command.getParameters().getTopImage().getImageId());
}
Also used : MergeParameters(org.ovirt.engine.core.common.action.MergeParameters) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with VmJob

use of org.ovirt.engine.core.common.businessentities.VmJob in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method buildVmJobData.

private static VmJob buildVmJobData(Guid vmId, Map<String, Object> struct) {
    VmJob ret;
    VmJobType jobType = VmJobType.getByName(assignStringValue(struct, VdsProperties.vmJobType));
    if (jobType == null) {
        jobType = VmJobType.UNKNOWN;
    }
    switch(jobType) {
        case BLOCK:
            VmBlockJob blockJob = new VmBlockJob();
            blockJob.setBlockJobType(VmBlockJobType.getByName(assignStringValue(struct, VdsProperties.vmBlockJobType)));
            blockJob.setCursorCur(assignLongValue(struct, VdsProperties.vmJobCursorCur));
            blockJob.setCursorEnd(assignLongValue(struct, VdsProperties.vmJobCursorEnd));
            blockJob.setBandwidth(assignLongValue(struct, VdsProperties.vmJobBandwidth));
            blockJob.setImageGroupId(new Guid(assignStringValue(struct, VdsProperties.vmJobImageUUID)));
            ret = blockJob;
            break;
        default:
            ret = new VmJob();
            break;
    }
    ret.setVmId(vmId);
    ret.setId(new Guid(assignStringValue(struct, VdsProperties.vmJobId)));
    ret.setJobState(VmJobState.NORMAL);
    ret.setJobType(jobType);
    return ret;
}
Also used : VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with VmJob

use of org.ovirt.engine.core.common.businessentities.VmJob in project ovirt-engine by oVirt.

the class VmJobDaoTest method testInsertVmJob.

@Test
public void testInsertVmJob() {
    // Create a job in memory
    VmJob job = new VmJob();
    job.setId(Guid.newGuid());
    job.setVmId(FixturesTool.VM_RHEL5_POOL_60);
    job.setJobState(VmJobState.NORMAL);
    job.setJobType(VmJobType.UNKNOWN);
    assertInsert(job);
}
Also used : VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Test(org.junit.Test)

Example 4 with VmJob

use of org.ovirt.engine.core.common.businessentities.VmJob in project ovirt-engine by oVirt.

the class VmJobsMonitoring method processVmJobs.

private void processVmJobs(Guid vmId, List<VmJob> jobs, List<VmJob> jobsToUpdate, List<VmJob> jobsToRemove) {
    if (jobs == null) {
        // If no vmJobs key was returned, we can't presume anything about the jobs; save them all
        log.debug("No vmJob data returned from VDSM, preserving existing jobs");
        return;
    }
    Map<Guid, VmJob> jobIdToReportedJob = jobs.stream().collect(toMap(VmJob::getId, identity()));
    getExistingJobsForVm(vmId).forEach(job -> {
        VmJob reportedJob = jobIdToReportedJob.get(job.getId());
        if (reportedJob != null) {
            if (reportedJob.equals(job)) {
                // Same data, no update needed.  It would be nice if a caching
                // layer would take care of this for us.
                log.info("{}: In progress (no change)", job);
            } else {
                jobsToUpdate.add(reportedJob);
                log.info("{}: In progress, updating", job);
            }
        } else {
            jobsToRemove.add(job);
            log.info("{}: Deleting", job);
        }
    });
}
Also used : VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

VmJob (org.ovirt.engine.core.common.businessentities.VmJob)4 Guid (org.ovirt.engine.core.compat.Guid)3 Test (org.junit.Test)1 MergeParameters (org.ovirt.engine.core.common.action.MergeParameters)1 VmBlockJob (org.ovirt.engine.core.common.businessentities.VmBlockJob)1 VmJobType (org.ovirt.engine.core.common.businessentities.VmJobType)1