Search in sources :

Example 61 with StatusOnlyReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method glusterSnapshotConfigSet.

@Override
public StatusOnlyReturn glusterSnapshotConfigSet(String configName, String configValue) {
    JsonRpcRequest request = new RequestBuilder("GlusterSnapshot.configSet").withParameter("optionName", configName).withParameter("optionValue", configValue).build();
    Map<String, Object> response = new FutureMap(this.client, request).withIgnoreResponseKey();
    return new StatusOnlyReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StatusOnlyReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn)

Example 62 with StatusOnlyReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method destroy.

@Override
public StatusOnlyReturn destroy(String vmId) {
    JsonRpcRequest request = new RequestBuilder("VM.destroy").withParameter("vmID", vmId).build();
    Map<String, Object> response = new FutureMap(this.client, request);
    return new StatusOnlyReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StatusOnlyReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn)

Example 63 with StatusOnlyReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method hibernate.

@Override
public StatusOnlyReturn hibernate(String vmId, String hiberVolHandle) {
    JsonRpcRequest request = new RequestBuilder("VM.hibernate").withParameter("vmID", vmId).withParameter("hibernationVolHandle", hiberVolHandle).build();
    Map<String, Object> response = new FutureMap(this.client, request);
    return new StatusOnlyReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StatusOnlyReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn)

Example 64 with StatusOnlyReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn 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 65 with StatusOnlyReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method glusterVolumeGeoRepSessionStart.

@Override
public StatusOnlyReturn glusterVolumeGeoRepSessionStart(String volumeName, String remoteHost, String remoteVolumeName, String userName, Boolean force) {
    JsonRpcRequest request = new RequestBuilder("GlusterVolume.geoRepSessionStart").withParameter("volumeName", volumeName).withParameter("remoteHost", remoteHost).withParameter("remoteVolumeName", remoteVolumeName).withOptionalParameter("remoteUserName", userName).withParameter("force", force).build();
    Map<String, Object> response = new FutureMap(this.client, request);
    return new StatusOnlyReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StatusOnlyReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn)

Aggregations

StatusOnlyReturn (org.ovirt.engine.core.vdsbroker.vdsbroker.StatusOnlyReturn)118 JsonRpcRequest (org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest)117 RequestBuilder (org.ovirt.vdsm.jsonrpc.client.RequestBuilder)117 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 FutureTask (java.util.concurrent.FutureTask)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 AsyncTaskCreationInfo (org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)1 Guid (org.ovirt.engine.core.compat.Guid)1 VdsManager (org.ovirt.engine.core.vdsbroker.VdsManager)1 VDSErrorException (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSErrorException)1