Search in sources :

Example 11 with AsyncTaskCreationInfo

use of org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo in project ovirt-engine by oVirt.

the class CreateImageVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    storageDomainHelper.checkNumberOfLVsForBlockDomain(getParameters().getStorageDomainId());
    setReturnValue(Guid.Empty);
    log.info("-- executeIrsBrokerCommand: calling 'createVolume' with two new parameters: description and UUID");
    // NOTE: The 'uuidReturn' variable will contain the taskID and not the
    // created image id!
    String imageInitSize = null;
    if (getParameters().getImageInitialSizeInBytes() != 0) {
        imageInitSize = Long.valueOf(getParameters().getImageInitialSizeInBytes()).toString();
    }
    String diskType = FeatureSupported.isContentTypeSupported(getParameters().getPoolCompatibilityVersion()) ? getParameters().getDiskContentType().getStorageValue() : DiskContentType.LEGACY_DISK_TYPE;
    uuidReturn = getIrsProxy().createVolume(getParameters().getStorageDomainId().toString(), getParameters().getStoragePoolId().toString(), getParameters().getImageGroupId().toString(), Long.valueOf(getParameters().getImageSizeInBytes()).toString(), getParameters().getVolumeFormat().getValue(), getParameters().getImageType().getValue(), diskType, getParameters().getNewImageID().toString(), getParameters().getNewImageDescription(), Guid.Empty.toString(), Guid.Empty.toString(), imageInitSize);
    proceedProxyReturnValue();
    Guid taskID = new Guid(uuidReturn.uuid);
    createdImageId = getParameters().getNewImageID().toString();
    setReturnValue(new Guid(createdImageId));
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(taskID, AsyncTaskType.createVolume, getParameters().getStoragePoolId()));
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with AsyncTaskCreationInfo

use of org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo in project ovirt-engine by oVirt.

the class DestroyImageVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    DestroyImageVDSCommandParameters params = getParameters();
    int imageListSize = params.getImageList().size();
    String[] volUUID = new String[imageListSize];
    int i = 0;
    for (Guid tempGuid : params.getImageList()) {
        volUUID[i++] = tempGuid.toString();
    }
    uuidReturn = deleteVolume(params.getStorageDomainId().toString(), params.getStoragePoolId().toString(), params.getImageGroupId().toString(), volUUID, String.valueOf(params.getPostZero()), params.isDiscard(), String.valueOf(params.getForce()));
    proceedProxyReturnValue();
    Guid taskID = new Guid(uuidReturn.uuid);
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(taskID, AsyncTaskType.deleteVolume, getParameters().getStoragePoolId()));
}
Also used : DestroyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DestroyImageVDSCommandParameters) AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 13 with AsyncTaskCreationInfo

use of org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo in project ovirt-engine by oVirt.

the class RemoveVmLeaseVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    returnValue = getIrsProxy().removeVmLease(getParameters().getLeaseId().toString(), getParameters().getStorageDomainId().toString());
    proceedProxyReturnValue();
    Guid taskID = new Guid(returnValue.getTaskId());
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(taskID, AsyncTaskType.removeVmLease, getParameters().getStoragePoolId()));
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 14 with AsyncTaskCreationInfo

use of org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo in project ovirt-engine by oVirt.

the class HSMGetAllTasksInfoVDSCommand method parseTaskInfoList.

protected ArrayList<AsyncTaskCreationInfo> parseTaskInfoList(Map<String, Map<String, String>> taskInfoList) {
    try {
        ArrayList<AsyncTaskCreationInfo> result = new ArrayList<>(taskInfoList.size());
        for (Map.Entry<String, Map<String, String>> entry : taskInfoList.entrySet()) {
            Guid taskID = new Guid(entry.getKey());
            Map<String, String> taskInfo = entry.getValue();
            AsyncTaskCreationInfo task = parseTaskInfo(taskInfo, taskID);
            if (task != null) {
                result.add(task);
            }
        }
        return result;
    } catch (RuntimeException exp) {
        log.error("Could not parse task info list: '{}'", taskInfoList);
        throw exp;
    }
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Map(java.util.Map)

Example 15 with AsyncTaskCreationInfo

use of org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo in project ovirt-engine by oVirt.

the class HSMGetAllTasksInfoVDSCommand method parseTaskInfo.

protected AsyncTaskCreationInfo parseTaskInfo(Map<String, String> taskInfo, Guid taskID) {
    try {
        String deTaskType = taskInfo.get(VERB_KEY);
        AsyncTaskType taskType;
        try {
            taskType = AsyncTaskType.valueOf(deTaskType);
        } catch (Exception e) {
            taskType = AsyncTaskType.unknown;
            log.warn("The task type in the vdsm response is '{}' and does not " + " appear in the AsyncTaskType enum", deTaskType);
        }
        AsyncTaskCreationInfo tempVar = new AsyncTaskCreationInfo();
        tempVar.setVdsmTaskId(taskID);
        tempVar.setTaskType(taskType);
        AsyncTaskCreationInfo task = tempVar;
        return task;
    } catch (RuntimeException e) {
        log.error("Could not parse single task info: '{}' (possibly specific task should not be monitored): {}", taskInfo, e.getMessage());
        log.debug("Exception", e);
        return null;
    }
}
Also used : AsyncTaskType(org.ovirt.engine.core.common.asynctasks.AsyncTaskType) AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)

Aggregations

AsyncTaskCreationInfo (org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)24 Guid (org.ovirt.engine.core.compat.Guid)20 ArrayList (java.util.ArrayList)2 SPMTask (org.ovirt.engine.core.bll.tasks.interfaces.SPMTask)2 AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 FutureTask (java.util.concurrent.FutureTask)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 CopyImageGroupWithDataCommandParameters (org.ovirt.engine.core.common.action.CopyImageGroupWithDataCommandParameters)1 AsyncTaskType (org.ovirt.engine.core.common.asynctasks.AsyncTaskType)1 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 CopyImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters)1 DestroyImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DestroyImageVDSCommandParameters)1 MoveImageGroupVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.MoveImageGroupVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 TransactionScopeOption (org.ovirt.engine.core.compat.TransactionScopeOption)1 VdsManager (org.ovirt.engine.core.vdsbroker.VdsManager)1