Search in sources :

Example 1 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class StorageSystemDataCollectionService method discoverScaleIO.

/**
 * Collect Data for ScaleIO system
 *
 * @param param ScaleIO discovery information
 * @return Data collected for ScaleIO system
 */
@POST
@Path("/scaleio")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ScaleIOSystemDataRestRep discoverScaleIO(ScaleIOCollectDataParam param) {
    log.debug("discovering ScaleIO: {}", param.getIPAddress());
    URI baseURI = URI.create(ScaleIOConstants.getAPIBaseURI(param.getIPAddress(), param.getPortNumber()));
    ScaleIORestClient client = (ScaleIORestClient) scaleIORestClientFactory.getRESTClient(baseURI, param.getUserName(), param.getPassword());
    ScaleIOSystemDataRestRep sio = null;
    try {
        // collect and map scaleIO system
        ScaleIOSystem system = client.getSystem();
        sio = ScaleIODataMapper.map(system);
        // collect sds,device,fault set, and protection domain data
        List<ScaleIOSDS> allSDS = client.queryAllSDS();
        Map<String, ScaleIOProtectionDomain> pdMap = null;
        List<ScaleIOProtectionDomain> pdList = client.getProtectionDomains();
        if (null != pdList) {
            pdMap = pdList.stream().collect(Collectors.toMap(ScaleIOProtectionDomain::getId, p -> p));
        }
        List<ScaleIOFaultSet> fsList = client.queryAllFaultSets();
        Map<String, ScaleIOFaultSet> fsMap = null;
        if (null != fsList) {
            fsMap = client.queryAllFaultSets().stream().collect(Collectors.toMap(ScaleIOFaultSet::getId, f -> f));
        }
        Map<String, ScaleIOStoragePool> spMap = client.queryAllStoragePools().stream().collect(Collectors.toMap(ScaleIOStoragePool::getId, s -> s));
        // map SDS data
        List<ScaleIOSDSDataRestRep> scaleIOSDSDataRestReps = new ArrayList<ScaleIOSDSDataRestRep>();
        for (ScaleIOSDS sds : allSDS) {
            ScaleIOSDSDataRestRep sdsData = ScaleIODataMapper.map(sds);
            // map device data
            List<ScaleIODevice> devices = client.getSdsDevices(sds.getId());
            List<ScaleIODeviceDataRestRep> scaleIODeviceDataRestReps = new ArrayList<ScaleIODeviceDataRestRep>();
            if (null != devices) {
                for (ScaleIODevice device : devices) {
                    ScaleIODeviceDataRestRep scaleIODeviceDataRestRep = ScaleIODataMapper.map(device);
                    // map storagepool data
                    scaleIODeviceDataRestRep.setStoragePool(ScaleIODataMapper.map(spMap.get(device.getStoragePoolId())));
                    scaleIODeviceDataRestReps.add(scaleIODeviceDataRestRep);
                }
                sdsData.setDevices(scaleIODeviceDataRestReps);
            }
            // map fault set data
            if (null != fsMap) {
                sdsData.setFaultSet(ScaleIODataMapper.map(fsMap.get(sds.getFaultSetId())));
            }
            // map protection domain and IP data
            if (null != pdMap) {
                sdsData.setProtectionDomain(ScaleIODataMapper.map(pdMap.get(sds.getProtectionDomainId())));
            }
            sdsData.setIpList(ScaleIODataMapper.mapIpList(sds.getIpList()));
            scaleIOSDSDataRestReps.add(sdsData);
        }
        sio.setSdsList(scaleIOSDSDataRestReps);
        // collect and map SDC data
        List<ScaleIOSDC> allSDC = client.queryAllSDC();
        List<ScaleIOSDCDataRestRep> scaleIOSDCDataRestReps = new ArrayList<ScaleIOSDCDataRestRep>();
        for (ScaleIOSDC sdc : allSDC) {
            ScaleIOSDCDataRestRep sdcData = ScaleIODataMapper.map(sdc);
            // map device data
            List<ScaleIOVolume> volumes = client.getSdcVolumes(sdc.getId());
            List<ScaleIOVolumeDataRestRep> scaleIOVolumeDataRestReps = new ArrayList<ScaleIOVolumeDataRestRep>();
            if (null != volumes) {
                for (ScaleIOVolume volume : volumes) {
                    ScaleIOVolumeDataRestRep scaleIOVolumeDataRestRep = ScaleIODataMapper.map(volume);
                    // map storagepool data
                    scaleIOVolumeDataRestRep.setStoragePool(ScaleIODataMapper.map(spMap.get(volume.getStoragePoolId())));
                    scaleIOVolumeDataRestReps.add(scaleIOVolumeDataRestRep);
                }
                sdcData.setVolumes(scaleIOVolumeDataRestReps);
            }
            scaleIOSDCDataRestReps.add(sdcData);
        }
        sio.setSdcList(scaleIOSDCDataRestReps);
    } catch (ScaleIOException e) {
        log.error(String.format("Exception was encountered in the ScaleIO client when connecting to instance %s", param.getIPAddress()), e);
        throw APIException.badRequests.storageSystemClientException(SCALEIO, e.getLocalizedMessage());
    } catch (JSONException e) {
        log.error(String.format("Exception was encountered when attempting to discover ScaleIO Instance %s", param.getIPAddress()), e);
        throw APIException.badRequests.cannotDiscoverStorageSystemUnexpectedResponse(SCALEIO);
    }
    return sio;
}
Also used : ScaleIOFaultSet(com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet) Role(com.emc.storageos.security.authorization.Role) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) LoggerFactory(org.slf4j.LoggerFactory) ScaleIOSDCDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep) ScaleIOSystemDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ScaleIOCollectDataParam(com.emc.storageos.model.collectdata.ScaleIOCollectDataParam) ArrayList(java.util.ArrayList) ScaleIOProtectionDomain(com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) Map(java.util.Map) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) URI(java.net.URI) ScaleIOConstants(com.emc.storageos.scaleio.api.ScaleIOConstants) ScaleIOSDSDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep) POST(javax.ws.rs.POST) Logger(org.slf4j.Logger) ScaleIODeviceDataRestRep(com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep) ScaleIOSDC(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ScaleIODataMapper(com.emc.storageos.api.mapper.ScaleIODataMapper) Collectors(java.util.stream.Collectors) ScaleIORestClientFactory(com.emc.storageos.scaleio.api.restapi.ScaleIORestClientFactory) ScaleIODevice(com.emc.storageos.scaleio.api.restapi.response.ScaleIODevice) List(java.util.List) JSONException(org.codehaus.jettison.json.JSONException) DefaultPermissions(com.emc.storageos.security.authorization.DefaultPermissions) ScaleIOSDS(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS) ScaleIOVolumeDataRestRep(com.emc.storageos.model.collectdata.ScaleIOVolumeDataRestRep) ScaleIOSystem(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) ArrayList(java.util.ArrayList) ScaleIOVolumeDataRestRep(com.emc.storageos.model.collectdata.ScaleIOVolumeDataRestRep) ScaleIOSystemDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep) ScaleIOSystem(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem) ScaleIOProtectionDomain(com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain) URI(java.net.URI) ScaleIODeviceDataRestRep(com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) ScaleIOSDSDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep) ScaleIOSDCDataRestRep(com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep) ScaleIODevice(com.emc.storageos.scaleio.api.restapi.response.ScaleIODevice) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) JSONException(org.codehaus.jettison.json.JSONException) ScaleIOSDS(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) ScaleIOFaultSet(com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) ScaleIOSDC(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIORestClient method getProtectionDomainStoragePools.

/**
 * Get the storage pools in the protection domain
 *
 * @param pdId The protection domain ID
 * @return The List of storage pools
 * @throws JSONException
 */
public List<ScaleIOStoragePool> getProtectionDomainStoragePools(String pdId) throws Exception {
    ClientResponse response = get(URI.create(ScaleIOConstants.getProtectionDomainStoragePoolURI(pdId)));
    List<ScaleIOStoragePool> pools = getResponseObjects(ScaleIOStoragePool.class, response);
    for (ScaleIOStoragePool pool : pools) {
        ScaleIOStoragePool poolResult = getStoragePoolStats(pool.getId());
        pool.setCapacityAvailableForVolumeAllocationInKb(poolResult.getCapacityAvailableForVolumeAllocationInKb());
        pool.setMaxCapacityInKb(poolResult.getMaxCapacityInKb());
    }
    return pools;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)

Example 3 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIORestClientTest method testQuerySDSdetails.

// @Test
public void testQuerySDSdetails() {
    List<ScaleIOSDS> result = null;
    Map<String, ScaleIOProtectionDomain> pdMap = null;
    Map<String, ScaleIOFaultSet> fsMap = null;
    Map<String, ScaleIOStoragePool> spMap = null;
    try {
        result = restClient.queryAllSDS();
        pdMap = restClient.getProtectionDomains().stream().collect(Collectors.toMap(ScaleIOProtectionDomain::getId, p -> p));
        List<ScaleIOFaultSet> fsList = restClient.queryAllFaultSets();
        if (null != fsList) {
            fsMap = restClient.queryAllFaultSets().stream().collect(Collectors.toMap(ScaleIOFaultSet::getId, f -> f));
        }
        spMap = restClient.queryAllStoragePools().stream().collect(Collectors.toMap(ScaleIOStoragePool::getId, s -> s));
        for (ScaleIOSDS sds : result) {
            List<ScaleIODevice> devices = restClient.getSdsDevices(sds.getId());
            String sdsId = sds.getId();
            String sdsPort = sds.getPort();
            String sdsIp = sds.getIpList().get(0).getIp();
            String sdsPd = null;
            if (null != pdMap) {
                sdsPd = pdMap.get(sds.getProtectionDomainId()).getName();
            }
            String sdsFs = null;
            if (null != fsMap) {
                sdsFs = fsMap.get(sds.getFaultSetId()).getName();
            }
            // Gson gson = new GsonBuilder().setPrettyPrinting().create();
            // System.out.println(gson.toJson(sds));
            System.out.printf("Sds id : %s  port : %s  IP: %s  PD: %s FS: %s %n", sdsId, sdsPort, sdsIp, sdsPd, sdsFs);
            for (ScaleIODevice device : devices) {
                String spName = spMap.get(device.getStoragePoolId()).getName();
                System.out.printf("\t Storage Pool name: %s device: %s %n", spName, device.getDeviceCurrentPathName());
            }
        }
    } catch (Exception e) {
        log.error("Exception: ", e);
    }
}
Also used : ScaleIODevice(com.emc.storageos.scaleio.api.restapi.response.ScaleIODevice) ScaleIOProtectionDomain(com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain) ScaleIOSDS(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) ScaleIOFaultSet(com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet)

Example 4 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIORestClient method getStoragePoolStats.

/**
 * Get the Storage Pool detail data
 *
 * @param poolId The storage pool ID
 * @return The details of the storage pool
 * @throws Exception
 */
public ScaleIOStoragePool getStoragePoolStats(String poolId) throws Exception {
    ClientResponse response = get(URI.create(ScaleIOConstants.getStoragePoolStatsURI(poolId)));
    ScaleIOStoragePool pool = getResponseObject(ScaleIOStoragePool.class, response);
    pool.setId(poolId);
    return pool;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)

Example 5 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIORestClient method queryStoragePool.

/**
 * Get the detail information for a pool
 *
 * @param poolId The storage pool native Id
 * @return The storage pool information
 * @throws Exception
 */
public ScaleIOStoragePool queryStoragePool(String poolId) throws Exception {
    ClientResponse response = get(URI.create(ScaleIOConstants.getStoragePoolStatsURI(poolId)));
    ScaleIOStoragePool pool = getResponseObject(ScaleIOStoragePool.class, response);
    ScaleIOStoragePool poolStats = getStoragePoolStats(poolId);
    pool.setCapacityAvailableForVolumeAllocationInKb(poolStats.getCapacityAvailableForVolumeAllocationInKb());
    pool.setMaxCapacityInKb(poolStats.getMaxCapacityInKb());
    return pool;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)

Aggregations

ScaleIOStoragePool (com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)8 ScaleIOProtectionDomain (com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain)3 ScaleIOSDS (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 ScaleIOException (com.emc.storageos.scaleio.ScaleIOException)2 ScaleIORestClient (com.emc.storageos.scaleio.api.restapi.ScaleIORestClient)2 ScaleIODevice (com.emc.storageos.scaleio.api.restapi.response.ScaleIODevice)2 ScaleIOFaultSet (com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet)2 ScaleIOSDC (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC)2 ScaleIOSystem (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ScaleIODataMapper (com.emc.storageos.api.mapper.ScaleIODataMapper)1 ScaleIOCollectDataParam (com.emc.storageos.model.collectdata.ScaleIOCollectDataParam)1 ScaleIODeviceDataRestRep (com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep)1 ScaleIOSDCDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep)1 ScaleIOSDSDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep)1 ScaleIOSystemDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep)1 ScaleIOVolumeDataRestRep (com.emc.storageos.model.collectdata.ScaleIOVolumeDataRestRep)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1