Search in sources :

Example 1 with ServerConnectionStatusReturn

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

the class JsonRpcVdsServer method disconnectStorageServer.

@Override
public ServerConnectionStatusReturn disconnectStorageServer(int serverType, String spUUID, Map<String, String>[] args) {
    JsonRpcRequest request = new RequestBuilder("StoragePool.disconnectStorageServer").withParameter("storagepoolID", spUUID).withParameter("domainType", serverType).withParameter("connectionParams", args).build();
    Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("statuslist").withResponseType(Object[].class);
    return new ServerConnectionStatusReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) ServerConnectionStatusReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.ServerConnectionStatusReturn)

Example 2 with ServerConnectionStatusReturn

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

the class JsonRpcVdsServer method connectStorageServer.

@Override
public ServerConnectionStatusReturn connectStorageServer(int serverType, String spUUID, Map<String, String>[] args) {
    JsonRpcRequest request = new RequestBuilder("StoragePool.connectStorageServer").withParameter("storagepoolID", spUUID).withParameter("domainType", serverType).withParameter("connectionParams", args).build();
    Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("statuslist").withResponseType(Object[].class);
    return new ServerConnectionStatusReturn(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) ServerConnectionStatusReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.ServerConnectionStatusReturn)

Example 3 with ServerConnectionStatusReturn

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

the class MarshallingTestCase method testAddDomain.

@SuppressWarnings("unchecked")
@Test
public void testAddDomain() throws Exception {
    // Given
    String json = "{\"jsonrpc\": \"2.0\", \"id\": \"4b0838b3-f940-4780-b2f0-fd56c1fbc573\", \"result\": [{\"status\": 0, \"id\": \"00000000-0000-0000-0000-000000000000\"}]}";
    ObjectMapper mapper = new ObjectMapper();
    JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(json));
    Future<JsonRpcResponse> future = mock(Future.class);
    when(future.get()).thenReturn(response);
    JsonRpcClient client = mock(JsonRpcClient.class);
    JsonRpcRequest request = mock(JsonRpcRequest.class);
    when(client.call(request)).thenReturn(future);
    // When
    Map<String, Object> map = new FutureMap(client, request).withResponseKey("statuslist").withResponseType(Object[].class);
    // Then
    ServerConnectionStatusReturn status = new ServerConnectionStatusReturn(map);
    assertEquals("Done", status.getStatus().message);
    assertEquals(0, status.getStatus().code);
    assertEquals(1, status.statusList.length);
    Map<String, Object> result = status.statusList[0];
    assertEquals(0, result.get("status"));
    assertEquals("00000000-0000-0000-0000-000000000000", result.get("id"));
}
Also used : JsonRpcResponse(org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) ServerConnectionStatusReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.ServerConnectionStatusReturn) JsonRpcClient(org.ovirt.vdsm.jsonrpc.client.JsonRpcClient) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Aggregations

ServerConnectionStatusReturn (org.ovirt.engine.core.vdsbroker.vdsbroker.ServerConnectionStatusReturn)3 JsonRpcRequest (org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest)3 RequestBuilder (org.ovirt.vdsm.jsonrpc.client.RequestBuilder)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Test (org.junit.Test)1 JsonRpcClient (org.ovirt.vdsm.jsonrpc.client.JsonRpcClient)1 JsonRpcResponse (org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse)1