Search in sources :

Example 36 with Status

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

the class VNXFileSystemSnapshotRestoreProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System Snapshot Restore response: {}", resultObj);
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getTaskResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof TaskResponse) {
                    TaskResponse taskResp = (TaskResponse) responseObj;
                    status = taskResp.getStatus();
                    _logger.info("FileSystem Snapshot restore task status: {}", status.getMaxSeverity().name());
                    if (status.getMaxSeverity() == Severity.OK) {
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                        // Since the restore worked, the snapshot created by the restore process needs to be removed.
                        // Setting up the name for the next processor.
                        String checkPoint = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
                        checkPoint += RESTORE_CHKPNT;
                        keyMap.put(VNXFileConstants.SNAPSHOT_NAME, checkPoint);
                    } else {
                        processErrorStatus(status, keyMap);
                    }
                    break;
                } else {
                    _logger.info("Response not TaskResponse: {}", responseObj.getClass().getName());
                }
            }
            // 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("Received celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx create file sys response due to ", ex);
        keyMap.put(VNXFileConstants.FAULT_DESC, ex.getMessage());
        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_FAILURE);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) TaskResponse(com.emc.nas.vnxfile.xmlapi.TaskResponse) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 37 with Status

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

the class VNXFileSystemUsageProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing fileshare usage response" + resultObj);
    final PostMethod result = (PostMethod) resultObj;
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            List<Problem> problems = status.getProblem();
            Iterator<Problem> problemsItr = problems.iterator();
            while (problemsItr.hasNext()) {
                Problem problem = problemsItr.next();
                _logger.error("Fault response received due to {} possible cause {}", problem.getDescription(), problem.getDiagnostics());
            }
        } else {
            List<Object> fsUsageInfo = getQueryStatsResponse(responsePacket);
            final List<Stat> statList = (List<Stat>) keyMap.get(Constants._Stats);
            processFileShareInfo(fsUsageInfo, keyMap, statList, dbClient);
            _zeroRecordGenerator.identifyRecordstobeZeroed(keyMap, statList, FileShare.class);
        }
    } catch (final IOException ioEx) {
        _logger.error("IOException occurred while processing the Fileshare capacity response due to {}", ioEx.getMessage());
        throw new VNXFilePluginException("IOException occurred while processing the Fileshare capacity response.", ioEx.getCause());
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the Fileshare capacity response due to {}", ex.getMessage());
        throw new VNXFilePluginException("Exception occurred while processing the Fileshare capacity response.", ex.getCause());
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) DbClient(com.emc.storageos.db.client.DbClient) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) IOException(java.io.IOException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Stat(com.emc.storageos.db.client.model.Stat) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Problem(com.emc.nas.vnxfile.xmlapi.Status.Problem) List(java.util.List)

Example 38 with Status

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

the class VNXSnapshotCreateProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX Snapshot Create response: {}", resultObj);
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getTaskResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof TaskResponse) {
                    TaskResponse taskResp = (TaskResponse) responseObj;
                    status = taskResp.getStatus();
                    _logger.info("NewCheckpoint task desc: {} : severity {}", status, status.getMaxSeverity());
                    if (status.getMaxSeverity() == Severity.OK) {
                        _logger.info("NewCheckpoint creation success");
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                    } else if (status.getMaxSeverity() == Severity.ERROR) {
                        processErrorStatus(status, keyMap);
                        _logger.info("NewCheckpoint creation failed");
                    }
                    break;
                } else {
                    _logger.info("Response not TaskResponse: {}", responseObj.getClass().getName());
                }
            }
            // 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("Received celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx snapshot create response due to ", ex);
        keyMap.put(VNXFileConstants.FAULT_DESC, ex.getMessage());
        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_FAILURE);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) TaskResponse(com.emc.nas.vnxfile.xmlapi.TaskResponse) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 39 with Status

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

the class VNXSnapshotProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing snapshot response" + resultObj);
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> snapshotList = getQueryResponse(responsePacket);
            // file system check point info
            getSnapTotalCapacityOfFileSystems(snapshotList, keyMap);
            Iterator<Object> snapshotItr = snapshotList.iterator();
            if (snapshotItr.hasNext()) {
                status = (Status) snapshotItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    final List<Stat> statList = (List<Stat>) keyMap.get(VNXFileConstants.STATS);
                    Iterator<Stat> statsIterator = statList.iterator();
                    while (statsIterator.hasNext()) {
                        Stat stat = statsIterator.next();
                        fetchSnapShotDetails(stat, snapshotList);
                    }
                } else {
                    processErrorStatus(status, keyMap);
                }
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the snapshot response due to {}", ex.getMessage());
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) Stat(com.emc.storageos.db.client.model.Stat) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) PostMethod(org.apache.commons.httpclient.methods.PostMethod) List(java.util.List) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 40 with Status

use of com.emc.nas.vnxfile.xmlapi.Status 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

Status (com.emc.nas.vnxfile.xmlapi.Status)42 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)33 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)33 PostMethod (org.apache.commons.httpclient.methods.PostMethod)33 Header (org.apache.commons.httpclient.Header)26 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)17 ArrayList (java.util.ArrayList)12 TaskResponse (com.emc.nas.vnxfile.xmlapi.TaskResponse)11 HashMap (java.util.HashMap)5 FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)4 List (java.util.List)4 Mover (com.emc.nas.vnxfile.xmlapi.Mover)3 TreeQuota (com.emc.nas.vnxfile.xmlapi.TreeQuota)3 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)2 MoverOrVdmRef (com.emc.nas.vnxfile.xmlapi.MoverOrVdmRef)2 Problem (com.emc.nas.vnxfile.xmlapi.Status.Problem)2 DbClient (com.emc.storageos.db.client.DbClient)2 Stat (com.emc.storageos.db.client.model.Stat)2 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)2 VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)2