Search in sources :

Example 11 with Status

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

the class VNXFileSystemExpandProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System expand 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 != null) {
                    if (responseObj instanceof TaskResponse) {
                        TaskResponse taskResp = (TaskResponse) responseObj;
                        status = taskResp.getStatus();
                        _logger.info("FileSystem expand 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());
                    }
                } else {
                    _logger.warn("FileSystem expand task response is null");
                }
            }
            // 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 file sys expand 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 12 with Status

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

the class VNXFileSystemIdProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
    String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
    boolean foundId = false;
    Iterator<Object> iterator = filesystemList.iterator();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if (status.getMaxSeverity() == Severity.OK) {
            while (iterator.hasNext()) {
                FileSystem fileSystem = (FileSystem) iterator.next();
                if (fileSystem.getName().equals(fsName) || fileSystem.getFileSystem().equals(fsId)) {
                    String id = fileSystem.getFileSystem();
                    _logger.info("Found matching file system: {}", id);
                    keyMap.put(VNXFileConstants.FILESYSTEM_ID, id);
                    keyMap.put(VNXFileConstants.FILESYSTEM, fileSystem);
                    keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.TRUE);
                    foundId = true;
                    break;
                }
            }
            if (!foundId) {
                _logger.error("Did not find file system ID for {}", fsName);
                keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.FALSE);
            }
        } else {
            throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Example 13 with Status

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

the class VNXFileSystemIdProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("Processing VNX File System ID Query response: {}", resultObj);
    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);
            keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx fileShare 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 14 with Status

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

the class VNXFileSystemInfoProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    Iterator<Object> iterator = filesystemList.iterator();
    Map<String, String> volFilesystemMap = new HashMap<String, String>();
    Set<String> moverIds = new HashSet<String>();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if (status.getMaxSeverity() == Severity.OK) {
            while (iterator.hasNext()) {
                FileSystem fileSystem = (FileSystem) iterator.next();
                volFilesystemMap.put(fileSystem.getVolume(), fileSystem.getFileSystem());
                List<MoverOrVdmRef> roFileSysHosts = fileSystem.getRoFileSystemHosts();
                Iterator<MoverOrVdmRef> roFileSysHostItr = roFileSysHosts.iterator();
                while (roFileSysHostItr.hasNext()) {
                    MoverOrVdmRef mover = roFileSysHostItr.next();
                    moverIds.add(mover.getMover());
                }
            }
        } else {
            throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
    keyMap.put(VNXFileConstants.MOVERLIST, moverIds);
    keyMap.put(VNXFileConstants.VOLFILESHAREMAP, volFilesystemMap);
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) HashMap(java.util.HashMap) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) MoverOrVdmRef(com.emc.nas.vnxfile.xmlapi.MoverOrVdmRef) HashSet(java.util.HashSet)

Example 15 with Status

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

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