Search in sources :

Example 1 with VmWorkMigrateVolume

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

the class VolumeApiServiceImpl method migrateVolumeThroughJobQueue.

public Outcome<Volume> migrateVolumeThroughJobQueue(final Long vmId, final long volumeId, final long destPoolId, final boolean liveMigrate) {
    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(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());
    // save work context info (there are some duplications)
    VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(), callingAccount.getId(), vm.getId(), VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, destPoolId, liveMigrate);
    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
    AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(workJob.getId());
    return new VmJobVolumeOutcome(workJob, volumeId);
}
Also used : Account(com.cloud.user.Account) User(com.cloud.user.User) VMInstanceVO(com.cloud.vm.VMInstanceVO) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) CallContext(org.apache.cloudstack.context.CallContext) VmWorkJobVO(org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)

Example 2 with VmWorkMigrateVolume

use of com.cloud.vm.VmWorkMigrateVolume in project cosmic by MissionCriticalCloud.

the class VolumeApiServiceImpl method migrateVolumeThroughJobQueue.

public Outcome<Volume> migrateVolumeThroughJobQueue(final Long vmId, final long volumeId, final long destPoolId, final boolean liveMigrate) {
    final CallContext context = CallContext.current();
    final User callingUser = context.getCallingUser();
    final Account callingAccount = context.getCallingAccount();
    final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
    final 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());
    // save work context info (there are some duplications)
    final VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(), callingAccount.getId(), vm.getId(), VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, destPoolId, liveMigrate);
    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
    AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(workJob.getId());
    return new VmJobVolumeOutcome(workJob, volumeId);
}
Also used : Account(com.cloud.user.Account) User(com.cloud.user.User) VMInstanceVO(com.cloud.vm.VMInstanceVO) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) CallContext(com.cloud.context.CallContext) VmWorkJobVO(com.cloud.framework.jobs.impl.VmWorkJobVO)

Example 3 with VmWorkMigrateVolume

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

the class VolumeOrchestrator method cleanupStorageJobs.

@Override
public void cleanupStorageJobs() {
    // clean up failure jobs related to volume
    List<AsyncJobVO> jobs = _jobMgr.findFailureAsyncJobs(VmWorkAttachVolume.class.getName(), VmWorkMigrateVolume.class.getName(), VmWorkTakeVolumeSnapshot.class.getName());
    for (AsyncJobVO job : jobs) {
        try {
            if (job.getCmd().equalsIgnoreCase(VmWorkAttachVolume.class.getName())) {
                VmWorkAttachVolume work = VmWorkSerializer.deserialize(VmWorkAttachVolume.class, job.getCmdInfo());
                cleanupVolumeDuringAttachFailure(work.getVolumeId(), work.getVmId());
            } else if (job.getCmd().equalsIgnoreCase(VmWorkMigrateVolume.class.getName())) {
                VmWorkMigrateVolume work = VmWorkSerializer.deserialize(VmWorkMigrateVolume.class, job.getCmdInfo());
                cleanupVolumeDuringMigrationFailure(work.getVolumeId(), work.getDestPoolId());
            } else if (job.getCmd().equalsIgnoreCase(VmWorkTakeVolumeSnapshot.class.getName())) {
                VmWorkTakeVolumeSnapshot work = VmWorkSerializer.deserialize(VmWorkTakeVolumeSnapshot.class, job.getCmdInfo());
                cleanupVolumeDuringSnapshotFailure(work.getVolumeId(), work.getSnapshotId());
            }
        } catch (Exception e) {
            s_logger.debug("clean up job failure, will continue", e);
        }
    }
}
Also used : VmWorkTakeVolumeSnapshot(com.cloud.vm.VmWorkTakeVolumeSnapshot) VmWorkAttachVolume(com.cloud.vm.VmWorkAttachVolume) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) InsufficientStorageCapacityException(com.cloud.exception.InsufficientStorageCapacityException) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StorageAccessException(com.cloud.exception.StorageAccessException) ExecutionException(java.util.concurrent.ExecutionException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Example 4 with VmWorkMigrateVolume

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

the class VolumeApiServiceImpl method orchestrateMigrateVolume.

@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateMigrateVolume(VmWorkMigrateVolume work) throws Exception {
    VolumeVO volume = _volsDao.findById(work.getVolumeId());
    StoragePoolVO targetStoragePool = _storagePoolDao.findById(work.getDestPoolId());
    DiskOfferingVO newDiskOffering = _diskOfferingDao.findById(work.getNewDiskOfferingId());
    Volume newVol = orchestrateMigrateVolume(volume, targetStoragePool, work.isLiveMigrate(), newDiskOffering);
    return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(newVol.getId()));
}
Also used : VmWorkDetachVolume(com.cloud.vm.VmWorkDetachVolume) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) VmWorkResizeVolume(com.cloud.vm.VmWorkResizeVolume) VmWorkAttachVolume(com.cloud.vm.VmWorkAttachVolume) VmWorkExtractVolume(com.cloud.vm.VmWorkExtractVolume) JobInfo(org.apache.cloudstack.jobs.JobInfo) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) Pair(com.cloud.utils.Pair) ReflectionUse(com.cloud.utils.ReflectionUse)

Example 5 with VmWorkMigrateVolume

use of com.cloud.vm.VmWorkMigrateVolume in project cosmic by MissionCriticalCloud.

the class VolumeOrchestrator method cleanupStorageJobs.

@Override
public void cleanupStorageJobs() {
    // clean up failure jobs related to volume
    final List<AsyncJobVO> jobs = _jobMgr.findFailureAsyncJobs(VmWorkAttachVolume.class.getName(), VmWorkMigrateVolume.class.getName(), VmWorkTakeVolumeSnapshot.class.getName());
    for (final AsyncJobVO job : jobs) {
        try {
            if (job.getCmd().equalsIgnoreCase(VmWorkAttachVolume.class.getName())) {
                final VmWorkAttachVolume work = VmWorkSerializer.deserialize(VmWorkAttachVolume.class, job.getCmdInfo());
                cleanupVolumeDuringAttachFailure(work.getVolumeId());
            } else if (job.getCmd().equalsIgnoreCase(VmWorkMigrateVolume.class.getName())) {
                final VmWorkMigrateVolume work = VmWorkSerializer.deserialize(VmWorkMigrateVolume.class, job.getCmdInfo());
                cleanupVolumeDuringMigrationFailure(work.getVolumeId(), work.getDestPoolId());
            } else if (job.getCmd().equalsIgnoreCase(VmWorkTakeVolumeSnapshot.class.getName())) {
                final VmWorkTakeVolumeSnapshot work = VmWorkSerializer.deserialize(VmWorkTakeVolumeSnapshot.class, job.getCmdInfo());
                cleanupVolumeDuringSnapshotFailure(work.getVolumeId(), work.getSnapshotId());
            }
        } catch (final Exception e) {
            s_logger.debug("clean up job failure, will continue", e);
        }
    }
}
Also used : VmWorkTakeVolumeSnapshot(com.cloud.vm.VmWorkTakeVolumeSnapshot) VmWorkAttachVolume(com.cloud.vm.VmWorkAttachVolume) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) InsufficientStorageCapacityException(com.cloud.exception.InsufficientStorageCapacityException) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) ConfigurationException(javax.naming.ConfigurationException) AsyncJobVO(com.cloud.framework.jobs.impl.AsyncJobVO)

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