Search in sources :

Example 6 with Status

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

Example 7 with Status

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

the class VNXFileQuotaDirectoryIdProcessor 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);
            final String quotaDirName = (String) keyMap.get(VNXFileConstants.QUOTA_DIR_NAME);
            String quotaDirPath = "/" + quotaDirName;
            _logger.info("Quota dir name to match: {} Size of quotadir found {} ", quotaDirName, 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.getPath().equals(quotaDirPath)) {
                            String id = quotaDir.getTree();
                            _logger.info("Found matching quota dir: {}", id);
                            keyMap.put(VNXFileConstants.QUOTA_DIR_ID, id);
                            keyMap.put(VNXFileConstants.QUOTA_DIR_PATH, quotaDir.getPath());
                            keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                            isQuotaDirFound = true;
                            break;
                        }
                    }
                    if (!isQuotaDirFound) {
                        _logger.error("Error in getting the quota dir information.");
                    }
                } 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) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) TreeQuota(com.emc.nas.vnxfile.xmlapi.TreeQuota)

Example 8 with Status

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

the class VNXFileQuotaTreeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX Quota Tree Create/Modify 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("Quota Tree Creation/Modification task desc: {} : severity {}", status, status.getMaxSeverity());
                    if (status.getMaxSeverity() == Severity.OK) {
                        _logger.info("Quota Tree creation/modification success");
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                    } else if (status.getMaxSeverity() == Severity.ERROR) {
                        _logger.info("Quota Tree creation/modification failed");
                        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_FAILURE);
                        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 quota tree 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 9 with Status

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

the class VNXFileSystemCreateProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System 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("NewFileSystem 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 10 with Status

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

the class VNXFileSystemDeleteProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System Delete 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("DeleteFileSystem 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 {
                    if (null != responseObj) {
                        _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 delete 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)

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