Search in sources :

Example 16 with ResponsePacket

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

the class VNXSnapshotIdProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing snapshot 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 isSnapshotFound = false;
            boolean isFSMatch = false;
            String id = "";
            List<Object> snapshotList = getQueryResponse(responsePacket);
            final String snapName = (String) keyMap.get(VNXFileConstants.SNAPSHOT_NAME);
            final String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
            _logger.info("Snapshot name to match: {} Size of snaps found {} ", snapName, snapshotList.size());
            Iterator<Object> snapshotItr = snapshotList.iterator();
            if (snapshotItr.hasNext()) {
                Status status = (Status) snapshotItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    while (snapshotItr.hasNext()) {
                        Checkpoint point = (Checkpoint) snapshotItr.next();
                        _logger.debug("searching snapshot: {}", point.getName());
                        if (point.getName().equals(snapName)) {
                            id = point.getCheckpoint();
                            _logger.info("Found matching snapshot: {}", id);
                            isSnapshotFound = true;
                            _logger.info("Checking if FS matches: {}", fsId);
                            if (fsId.equalsIgnoreCase(point.getCheckpointOf())) {
                                keyMap.put(VNXFileConstants.SNAPSHOT_ID, id);
                                keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                                _logger.info("FS matched successfully: {}", fsId);
                                isFSMatch = true;
                                break;
                            }
                        }
                    }
                    if (isSnapshotFound && !isFSMatch) {
                        _logger.error("Snapshot creation failed due to: Snapshot {} already exists", id);
                    }
                    if (!isSnapshotFound) {
                        _logger.error("Error in getting the snapshot information.");
                    }
                } else {
                    _logger.error("Error in getting the snapshot information.");
                }
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the snapshot 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) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) PostMethod(org.apache.commons.httpclient.methods.PostMethod) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 17 with ResponsePacket

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

the class VNXFileSystemMountProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX Mount 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 system = (TaskResponse) responseObj;
                    status = system.getStatus();
                    _logger.info("Mount task response status: {}", status.getMaxSeverity().name());
                    if (status.getMaxSeverity() == Severity.OK) {
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                    } 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("Recieved celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx prov 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 18 with ResponsePacket

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

the class VNXFileSystemUnexportProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System Unexport 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 Unexport task response status: {}", status.getMaxSeverity().name());
                    if (status.getMaxSeverity() == Severity.OK) {
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                    } 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 19 with ResponsePacket

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

the class VNXDataMoverNameProcessor 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 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) 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 20 with ResponsePacket

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

the class VNXFSSnapshotsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing snapshot id 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);
            List<Checkpoint> snapsList = new ArrayList<Checkpoint>();
            final String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
            _logger.info("Looking for all snapshots of filesystem {}", fsId);
            Iterator<Object> snapshotItr = snapshotList.iterator();
            if (snapshotItr.hasNext()) {
                status = (Status) snapshotItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    while (snapshotItr.hasNext()) {
                        Checkpoint point = (Checkpoint) snapshotItr.next();
                        _logger.debug("searching snapshot: {} - {}", point.getName(), point.getCheckpointOf());
                        if (point.getCheckpointOf().equalsIgnoreCase(fsId)) {
                            String id = point.getCheckpoint();
                            String localFSId = point.getCheckpointOf();
                            _logger.info("Found matching snapshot: {} and checkpoint of {}", id, localFSId);
                            snapsList.add(point);
                        }
                    }
                    _logger.info("Number of Snapshots found for FS : {} are : {}", fsId, snapsList.size());
                    keyMap.put(VNXFileConstants.SNAPSHOTS_LIST, snapsList);
                    keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                } else {
                    _logger.error("Error in getting the snapshot information.");
                    processErrorStatus(status, keyMap);
                }
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the snapshot 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) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

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