Search in sources :

Example 6 with VmWorkMigrateVolume

use of com.cloud.vm.VmWorkMigrateVolume in project cloudstack by apache.

the class VolumeApiServiceImpl method migrateVolumeThroughJobQueue.

private Outcome<Volume> migrateVolumeThroughJobQueue(VMInstanceVO vm, VolumeVO vol, StoragePool destPool, boolean liveMigrateVolume, DiskOfferingVO newDiskOffering) {
    CallContext context = CallContext.current();
    User callingUser = context.getCallingUser();
    Account callingAccount = context.getCallingAccount();
    VmWorkJobVO workJob = new VmWorkJobVO(context.getContextId());
    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
    workJob.setCmd(VmWorkMigrateVolume.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());
    Long newDiskOfferingId = newDiskOffering != null ? newDiskOffering.getId() : null;
    // save work context info (there are some duplications)
    VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(), callingAccount.getId(), vm.getId(), VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, vol.getId(), destPool.getId(), liveMigrateVolume, newDiskOfferingId);
    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
    AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(workJob.getId());
    return new VmJobVolumeOutcome(workJob, vol.getId());
}
Also used : Account(com.cloud.user.Account) User(com.cloud.user.User) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) CallContext(org.apache.cloudstack.context.CallContext) VmWorkJobVO(org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)

Aggregations

VmWorkMigrateVolume (com.cloud.vm.VmWorkMigrateVolume)6 Account (com.cloud.user.Account)3 User (com.cloud.user.User)3 VmWorkAttachVolume (com.cloud.vm.VmWorkAttachVolume)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientStorageCapacityException (com.cloud.exception.InsufficientStorageCapacityException)2 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)2 VMInstanceVO (com.cloud.vm.VMInstanceVO)2 VmWorkTakeVolumeSnapshot (com.cloud.vm.VmWorkTakeVolumeSnapshot)2 ExecutionException (java.util.concurrent.ExecutionException)2 ConfigurationException (javax.naming.ConfigurationException)2 CallContext (org.apache.cloudstack.context.CallContext)2 VmWorkJobVO (org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)2 CallContext (com.cloud.context.CallContext)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 StorageAccessException (com.cloud.exception.StorageAccessException)1 AsyncJobVO (com.cloud.framework.jobs.impl.AsyncJobVO)1 VmWorkJobVO (com.cloud.framework.jobs.impl.VmWorkJobVO)1