Search in sources :

Example 1 with AsyncTaskCreationInfo

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

the class UploadImageVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    setReturnValue(Guid.Empty);
    log.info("-- executeIrsBrokerCommand: calling 'uploadImage', parameters:");
    log.info("++ srcSpUUID={}", getParameters().getStoragePoolId());
    log.info("++ srcSdUUID={}", getParameters().getStorageDomainId());
    log.info("++ srcImageGUID={}", getParameters().getImageGroupId());
    log.info("++ srcVolUUID={}", getParameters().getImageId());
    log.info("++ uploadLocation={}", getParameters().getUploadInfo());
    uuidReturn = getIrsProxy().uploadImage(LocationInfoHelper.prepareLocationInfoForVdsCommand(getParameters().getUploadInfo()), getParameters().getStoragePoolId().toString(), getParameters().getStorageDomainId().toString(), getParameters().getImageGroupId().toString(), getParameters().getImageId().toString());
    proceedProxyReturnValue();
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(new Guid(uuidReturn.uuid), AsyncTaskType.copyImage, getParameters().getStoragePoolId()));
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with AsyncTaskCreationInfo

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

the class AddVmLeaseVDSCommand method executeIrsBrokerCommand.

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

Example 3 with AsyncTaskCreationInfo

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

the class HttpImageTaskVDSCommand method executeHttpMethod.

protected void executeHttpMethod(final T method) {
    int responseCode = -1;
    VdsManager manager = resourceManager.getVdsManager(getParameters().getVdsId());
    final HttpClient httpclient = manager.getVdsProxy().getHttpClient();
    try {
        FutureTask<Integer> futureTask = new FutureTask(() -> httpclient.executeMethod(method));
        Future<Integer> f = ThreadPoolUtil.execute(futureTask);
        if (f.get(Config.<Integer>getValue(getConfigValueTimeLimitForOperation()), TimeUnit.MINUTES) == null) {
            responseCode = futureTask.get();
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    } catch (Exception e) {
        log.debug("Exception", e);
        throw createNetworkException(e);
    }
    if (responseCode == getSuccessCode()) {
        Guid createdTask = Guid.createGuidFromString(processResponseHeaderValue(getMethod(), "Task-Id", null));
        getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(createdTask, getCreatedTaskType(), getParameters().getStoragePoolId()));
        handleOkResponse();
        getVDSReturnValue().setSucceeded(true);
        return;
    }
    processResponseHeaderValue(getMethod(), "Content-type", "application/json");
    String response;
    try {
        response = getMethod().getResponseBodyAsString();
    } catch (Exception e) {
        throw createNetworkException(e);
    }
    Map<String, Object> resultMap = null;
    try {
        resultMap = new ObjectMapper().readValue(response, HashMap.class);
        status = new StatusOnlyReturn(resultMap);
    } catch (Exception e) {
        throwVdsErrorException("failed to parse response " + response, EngineError.GeneralException);
    }
    proceedProxyReturnValue();
}
Also used : HashMap(java.util.HashMap) AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid) StatusOnlyReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn) VDSErrorException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSErrorException) FutureTask(java.util.concurrent.FutureTask) HttpClient(org.apache.commons.httpclient.HttpClient) VdsManager(org.ovirt.engine.core.vdsbroker.VdsManager) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 4 with AsyncTaskCreationInfo

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

the class MergeSnapshotsVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    uuidReturn = mergeSnapshots(getParameters().getStorageDomainId().toString(), getParameters().getStoragePoolId().toString(), getParameters().getVmId().toString(), getParameters().getImageGroupId().toString(), getParameters().getImageId().toString(), getParameters().getImageId2().toString(), String.valueOf(getParameters().getPostZero()).toLowerCase(), getParameters().isDiscard());
    proceedProxyReturnValue();
    Guid taskID = new Guid(uuidReturn.uuid);
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(taskID, AsyncTaskType.mergeSnapshots, getParameters().getStoragePoolId()));
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with AsyncTaskCreationInfo

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

the class PrepareMergeVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    uuidReturn = getIrsProxy().prepareMerge(getParameters().getStoragePoolId().toString(), SubchainInfoHelper.prepareSubchainInfoForVdsCommand(getParameters().getSubchainInfo()));
    proceedProxyReturnValue();
    Guid taskID = new Guid(uuidReturn.uuid);
    getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(taskID, AsyncTaskType.prepareMerge, getParameters().getStoragePoolId()));
}
Also used : AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid)

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