Search in sources :

Example 31 with ResponsePacket

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

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

the class VNXControlStationProcessor 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 info 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();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof CelerraSystem) {
                    CelerraSystem system = (CelerraSystem) responseObj;
                    VNXControlStation cs = new VNXControlStation(system.getSerial(), system.getVersion());
                    keyMap.put(VNXFileConstants.CONTROL_STATION_INFO, cs);
                    break;
                }
            }
            // 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) VNXControlStation(com.emc.storageos.vnx.xmlapi.VNXControlStation) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) CelerraSystem(com.emc.nas.vnxfile.xmlapi.CelerraSystem) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 33 with ResponsePacket

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

the class VNXDataMoverIdProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        // 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 info from the Server.");
        }
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> dataMoverList = getQueryResponse(responsePacket);
            processDataMoverList(dataMoverList, keyMap);
            keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx data mover due to {}", ex.getMessage());
        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) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Example 34 with ResponsePacket

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

the class VNXFSQuotaDirsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing quota dir id response" + resultObj);
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            boolean isQuotaDirFound = false;
            List<Object> quotaDirList = getQueryResponse(responsePacket);
            List<TreeQuota> quotaDirs = new ArrayList<TreeQuota>();
            final String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
            _logger.info("Quota dirs for parent file systems to match: {} Size of quotadir found {} ", fsId, quotaDirList.size());
            Iterator<Object> quotaDirItr = quotaDirList.iterator();
            if (quotaDirItr.hasNext()) {
                Status status = (Status) quotaDirItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    while (quotaDirItr.hasNext()) {
                        TreeQuota quotaDir = (TreeQuota) quotaDirItr.next();
                        _logger.debug("searching quota dir: {}", quotaDir.getTree());
                        if (quotaDir.getFileSystem().equalsIgnoreCase(fsId)) {
                            String id = quotaDir.getTree();
                            quotaDirs.add(quotaDir);
                            _logger.info("Found matching quota dir: {}", id);
                            isQuotaDirFound = true;
                        }
                    }
                    if (isQuotaDirFound) {
                        _logger.info("Number of Quota dirs found for FS : {} are : {}", fsId, quotaDirs.size());
                        keyMap.put(VNXFileConstants.QUOTA_DIR_LIST, quotaDirs);
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                    }
                } else {
                    _logger.error("Error in getting the quota dir information.");
                }
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the quota dir response due to {}", ex.getMessage());
        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) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) TreeQuota(com.emc.nas.vnxfile.xmlapi.TreeQuota)

Example 35 with ResponsePacket

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

the class VNXFileSystemInfoProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        // 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 info from the Server.");
        }
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> filesystemList = getQueryResponse(responsePacket);
            processFilesystemList(filesystemList, keyMap);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx fileShare response due to {}", ex.getMessage());
    } 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) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Aggregations

ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)35 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)35 PostMethod (org.apache.commons.httpclient.methods.PostMethod)35 Status (com.emc.nas.vnxfile.xmlapi.Status)33 Header (org.apache.commons.httpclient.Header)26 TaskResponse (com.emc.nas.vnxfile.xmlapi.TaskResponse)11 ArrayList (java.util.ArrayList)10 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)9 List (java.util.List)5 Stat (com.emc.storageos.db.client.model.Stat)4 TreeQuota (com.emc.nas.vnxfile.xmlapi.TreeQuota)3 Map (java.util.Map)3 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)2 DbClient (com.emc.storageos.db.client.DbClient)2 HashMap (java.util.HashMap)2 CelerraSystem (com.emc.nas.vnxfile.xmlapi.CelerraSystem)1 CifsServer (com.emc.nas.vnxfile.xmlapi.CifsServer)1 LogicalNetworkDevice (com.emc.nas.vnxfile.xmlapi.LogicalNetworkDevice)1 Mover (com.emc.nas.vnxfile.xmlapi.Mover)1 MoverInterface (com.emc.nas.vnxfile.xmlapi.MoverInterface)1