Search in sources :

Example 1 with StoragePool

use of com.emc.nas.vnxfile.xmlapi.StoragePool in project coprhd-controller by CoprHD.

the class VNXStoragePoolProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    _logger.info("processing vnx storagepool response" + resultObj);
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getQueryResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            List<VNXStoragePool> storagePools = new ArrayList<VNXStoragePool>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                _logger.info("{}", responseObj);
                if (responseObj instanceof StoragePool) {
                    VNXStoragePool vnxPool = new VNXStoragePool();
                    StoragePool storagePool = (StoragePool) responseObj;
                    vnxPool.setName(storagePool.getName());
                    vnxPool.setPoolId(storagePool.getPool());
                    vnxPool.setSize(String.valueOf(storagePool.getSize()));
                    vnxPool.setAutoSize(String.valueOf(storagePool.getAutoSize()));
                    vnxPool.setVirtualProv(String.valueOf(storagePool.isVirtualProvisioning()));
                    vnxPool.setUsedSize(String.valueOf(storagePool.getUsedSize()));
                    SystemStoragePoolData data = storagePool.getSystemStoragePoolData();
                    if (null != data) {
                        String dynamic = String.valueOf(data.isDynamic());
                        vnxPool.setDynamic(dynamic);
                    }
                    _logger.info("VNX Pool Information {}", vnxPool.toString());
                    storagePools.add(vnxPool);
                }
            }
            _logger.info("Number of StorgePools found  : {}", storagePools.size());
            keyMap.put(VNXFileConstants.STORAGEPOOLS, storagePools);
            // Extract session information from the response header.
            Header[] headers = result.getResponseHeaders(VNXFileConstants.CELERRA_SESSION);
            if (null != headers && headers.length > 0) {
                keyMap.put(VNXFileConstants.CELERRA_SESSION, headers[0].getValue());
                _logger.info("Recieved celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx info response due to ", ex);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) StoragePool(com.emc.nas.vnxfile.xmlapi.StoragePool) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) SystemStoragePoolData(com.emc.nas.vnxfile.xmlapi.SystemStoragePoolData)

Aggregations

ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)1 Status (com.emc.nas.vnxfile.xmlapi.Status)1 StoragePool (com.emc.nas.vnxfile.xmlapi.StoragePool)1 SystemStoragePoolData (com.emc.nas.vnxfile.xmlapi.SystemStoragePoolData)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 VNXStoragePool (com.emc.storageos.vnx.xmlapi.VNXStoragePool)1 ArrayList (java.util.ArrayList)1 Header (org.apache.commons.httpclient.Header)1 PostMethod (org.apache.commons.httpclient.methods.PostMethod)1