Search in sources :

Example 51 with VmWorkJobVO

use of org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO in project cloudstack by apache.

the class VMSnapshotManagerImpl method createPlaceHolderWork.

private VmWorkJobVO createPlaceHolderWork(long instanceId) {
    VmWorkJobVO workJob = new VmWorkJobVO("");
    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_PLACEHOLDER);
    workJob.setCmd("");
    workJob.setCmdInfo("");
    workJob.setAccountId(0);
    workJob.setUserId(0);
    workJob.setStep(VmWorkJobVO.Step.Starting);
    workJob.setVmType(VirtualMachine.Type.Instance);
    workJob.setVmInstanceId(instanceId);
    workJob.setInitMsid(ManagementServerNode.getManagementServerId());
    _workJobDao.persist(workJob);
    return workJob;
}
Also used : VmWorkJobVO(org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)

Example 52 with VmWorkJobVO

use of org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO in project cloudstack by apache.

the class VMSnapshotManagerImpl method revertToVMSnapshotThroughJobQueue.

public Outcome<VMSnapshot> revertToVMSnapshotThroughJobQueue(final Long vmId, final Long vmSnapshotId) {
    final CallContext context = CallContext.current();
    final User callingUser = context.getCallingUser();
    final Account callingAccount = context.getCallingAccount();
    final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
    VmWorkJobVO workJob = new VmWorkJobVO(context.getContextId());
    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
    workJob.setCmd(VmWorkRevertToVMSnapshot.class.getName());
    workJob.setAccountId(callingAccount.getId());
    workJob.setUserId(callingUser.getId());
    workJob.setStep(VmWorkJobVO.Step.Starting);
    workJob.setVmType(VirtualMachine.Type.Instance);
    workJob.setVmInstanceId(vm.getId());
    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
    // save work context info (there are some duplications)
    VmWorkRevertToVMSnapshot workInfo = new VmWorkRevertToVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(), VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId);
    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
    AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(workJob.getId());
    return new VmJobVMSnapshotOutcome(workJob, vmSnapshotId);
}
Also used : Account(com.cloud.user.Account) User(com.cloud.user.User) VMInstanceVO(com.cloud.vm.VMInstanceVO) CallContext(org.apache.cloudstack.context.CallContext) VmWorkJobVO(org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)

Aggregations

VmWorkJobVO (org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)52 Account (com.cloud.user.Account)27 User (com.cloud.user.User)22 CallContext (org.apache.cloudstack.context.CallContext)22 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)21 AsyncJobExecutionContext (org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext)21 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)20 VMInstanceVO (com.cloud.vm.VMInstanceVO)13 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)10 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 ActionEvent (com.cloud.event.ActionEvent)8 ExecutionException (java.util.concurrent.ExecutionException)6 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)6 UserVmVO (com.cloud.vm.UserVmVO)5 VmWorkAttachVolume (com.cloud.vm.VmWorkAttachVolume)5 VmWorkDetachVolume (com.cloud.vm.VmWorkDetachVolume)5 VmWorkExtractVolume (com.cloud.vm.VmWorkExtractVolume)5 VmWorkMigrateVolume (com.cloud.vm.VmWorkMigrateVolume)5 VmWorkResizeVolume (com.cloud.vm.VmWorkResizeVolume)5 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4