Search in sources :

Example 1 with StoragePoolInfo

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

the class IsoPrefixVDSCommand method getIsoPrefix.

private String getIsoPrefix() {
    Guid storagePoolId = getParameters().getStoragePoolId();
    String cachedIsoPrefix = storagePoolIdToIsoPrefix.get(storagePoolId);
    if (cachedIsoPrefix != null) {
        return cachedIsoPrefix;
    }
    synchronized (getLockObjForStoragePool(storagePoolId)) {
        cachedIsoPrefix = storagePoolIdToIsoPrefix.get(storagePoolId);
        if (cachedIsoPrefix != null) {
            return cachedIsoPrefix;
        }
        StoragePoolInfo retVal;
        try {
            retVal = getBroker().getStoragePoolInfo(storagePoolId.toString());
        } catch (Exception ex) {
            log.error("IsoPrefix Failed to get storage pool info (vds '{}', pool '{}').", getParameters().getVdsId(), storagePoolId);
            return StringUtils.EMPTY;
        }
        String isoPrefix = getIsoPrefixFromStoragePoolInfoReturnValue(retVal);
        if (!isoPrefix.isEmpty()) {
            storagePoolIdToIsoPrefix.put(storagePoolId, isoPrefix);
        }
        return isoPrefix;
    }
}
Also used : StoragePoolInfo(org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with StoragePoolInfo

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

the class MarshallingTestCase method testStoragePoolInfo.

@SuppressWarnings("unchecked")
@Test
public void testStoragePoolInfo() throws Exception {
    // Given
    String json = "{\"jsonrpc\": \"2.0\", \"id\": \"609b5787-ab3a-485b-8ed8-0bc9a27eda27\", \"result\": {\"info\": {\"spm_id\": 1, \"master_uuid\": \"05a0ad59-1259-4353-b40b-34eb80d8590a\"," + " \"name\": \"Default\", \"version\": \"0\", \"domains\": \"05a0ad59-1259-4353-b40b-34eb80d8590a:Active,6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324:Active,4192b643-fae9-4c1c-8b8b-9c9c6cc10523:Active\", " + "\"pool_status\": \"connected\", \"isoprefix\": \"/rhev/data-center/mnt/192.168.1.10:_export_iso/6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324/images/11111111-1111-1111-1111-111111111111\", " + "\"type\": \"NFS\", \"master_ver\": 1, \"lver\": 0}, \"dominfo\": {\"05a0ad59-1259-4353-b40b-34eb80d8590a\": {\"status\": \"Active\", \"diskfree\": \"43887099904\", \"isoprefix\": \"\"," + " \"alerts\": [], \"disktotal\": \"52710866944\", \"version\": 0}, \"6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324\": {\"status\": \"Active\", \"diskfree\": \"43887099904\", \"isoprefix\": " + "\"/rhev/data-center/mnt/192.168.1.10:_export_iso/6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324/images/11111111-1111-1111-1111-111111111111\", \"alerts\": [], \"disktotal\": \"52710866944\", " + "\"version\": 0}, \"4192b643-fae9-4c1c-8b8b-9c9c6cc10523\": {\"status\": \"Active\", \"isoprefix\": \"\", \"alerts\": [], \"version\": -1}}}}";
    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).withIgnoreResponseKey();
    // Then
    StoragePoolInfo storagePoolInfo = new StoragePoolInfo(map);
    assertEquals("Done", storagePoolInfo.getStatus().message);
    assertEquals(0, storagePoolInfo.getStatus().code);
    Set<String> keys = storagePoolInfo.domainsList.keySet();
    assertEquals(3, keys.size());
    assertTrue(keys.contains("05a0ad59-1259-4353-b40b-34eb80d8590a"));
    assertTrue(keys.contains("6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324"));
    assertTrue(keys.contains("4192b643-fae9-4c1c-8b8b-9c9c6cc10523"));
    Map<String, Object> info = storagePoolInfo.storagePoolInfo;
    assertEquals("/rhev/data-center/mnt/192.168.1.10:_export_iso/6ca00a0d-3f1d-4762-b5ff-c58a6a0a0324/images/11111111-1111-1111-1111-111111111111", info.get("isoprefix"));
}
Also used : JsonRpcResponse(org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) StoragePoolInfo(org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfo) JsonRpcClient(org.ovirt.vdsm.jsonrpc.client.JsonRpcClient) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 3 with StoragePoolInfo

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

the class JsonRpcVdsServer method getStoragePoolInfo.

@Override
public StoragePoolInfo getStoragePoolInfo(String spUUID) {
    JsonRpcRequest request = new RequestBuilder("StoragePool.getInfo").withParameter("storagepoolID", spUUID).build();
    Map<String, Object> response = new FutureMap(this.client, request).withIgnoreResponseKey();
    return new StoragePoolInfo(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StoragePoolInfo(org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfo)

Example 4 with StoragePoolInfo

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

the class JsonRpcIIrsServer method getStoragePoolInfo.

@Override
public StoragePoolInfo getStoragePoolInfo(String spUUID) {
    // duplicated in IVdsServer#getStoragePoolInfo
    JsonRpcRequest request = new RequestBuilder("StoragePool.getInfo").withParameter("storagepoolID", spUUID).build();
    Map<String, Object> response = new FutureMap(this.client, request).withIgnoreResponseKey();
    return new StoragePoolInfo(response);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) StoragePoolInfo(org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfo)

Aggregations

StoragePoolInfo (org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfo)4 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 Guid (org.ovirt.engine.core.compat.Guid)1 JsonRpcClient (org.ovirt.vdsm.jsonrpc.client.JsonRpcClient)1 JsonRpcResponse (org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse)1