Search in sources :

Example 21 with Status

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

the class VNXFileSystemsProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private List<VNXFileSystem> processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    Iterator<Object> iterator = filesystemList.iterator();
    List<VNXFileSystem> processedFileSystem = new ArrayList<VNXFileSystem>();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if ((status.getMaxSeverity() == Severity.OK) || (status.getMaxSeverity() == Severity.WARNING)) {
            Map<String, FileSystem> fileSystems = new HashMap<String, FileSystem>();
            Map<String, FileSystemCapacityInfo> fileSysCapacityInfos = new HashMap<String, FileSystemCapacityInfo>();
            while (iterator.hasNext()) {
                Object obj = iterator.next();
                if (obj instanceof FileSystem) {
                    FileSystem fs = (FileSystem) obj;
                    if (fs.isInternalUse() == false) {
                        fileSystems.put(fs.getFileSystem(), fs);
                    }
                } else if (obj instanceof FileSystemCapacityInfo) {
                    FileSystemCapacityInfo fsCapacityInfo = (FileSystemCapacityInfo) obj;
                    fileSysCapacityInfos.put(fsCapacityInfo.getFileSystem(), fsCapacityInfo);
                }
            }
            Iterator it = fileSystems.keySet().iterator();
            while (it.hasNext()) {
                String fsId = (String) it.next();
                FileSystem fileSystem = fileSystems.get(fsId);
                FileSystemCapacityInfo fsCapacity = fileSysCapacityInfos.get(fsId);
                List<String> pools = new ArrayList<String>();
                if (null != fileSystem.getStoragePools()) {
                    pools = fileSystem.getStoragePools();
                }
                String poolId = "";
                if (null != pools) {
                    poolId = pools.get(0);
                }
                StringBuffer debugInfo = new StringBuffer();
                debugInfo.append("VNXFileSystem : " + fileSystem.getName());
                debugInfo.append(" Pool : " + poolId);
                long totalCapacity = 0;
                VNXFileSystem vnxFS = new VNXFileSystem(fileSystem.getName(), Integer.valueOf(fileSystem.getFileSystem()));
                if (fileSystem.isVirtualProvisioning()) {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THIN.name());
                    FileSystemAutoExtInfo autoExtInfo = fileSystem.getFileSystemAutoExtInfo();
                    if (null != autoExtInfo) {
                        totalCapacity = autoExtInfo.getAutoExtensionMaxSize();
                        totalCapacity = totalCapacity * MBTOBYTECONVERTER;
                    } else {
                        totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                    }
                } else {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name());
                    totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                }
                vnxFS.setStoragePool(poolId);
                debugInfo.append(" fsCapacity.getVolumeSize() : " + fsCapacity.getVolumeSize());
                vnxFS.setTotalCapacity(totalCapacity + "");
                vnxFS.setUsedCapcity("0");
                if (null != fsCapacity.getResourceUsage()) {
                    // We can get Used capacity
                    // Size is in MB, convert to Bytes
                    debugInfo.append(" fsCapacity.getUsedCapacity:" + fsCapacity.getResourceUsage().getSpaceUsed());
                    long usedCapacity = fsCapacity.getResourceUsage().getSpaceUsed() * MBTOBYTECONVERTER;
                    vnxFS.setUsedCapcity(usedCapacity + "");
                }
                debugInfo.append(" Total Capacity :" + vnxFS.getTotalCapacity());
                debugInfo.append(" Used Capacity :" + vnxFS.getUsedCapacity());
                _logger.debug(debugInfo.toString());
                processedFileSystem.add(vnxFS);
            }
        } else {
            throw new com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
    return processedFileSystem;
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) HashMap(java.util.HashMap) FileSystemCapacityInfo(com.emc.nas.vnxfile.xmlapi.FileSystemCapacityInfo) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) ArrayList(java.util.ArrayList) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) Iterator(java.util.Iterator) FileSystemAutoExtInfo(com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject)

Example 22 with Status

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

the class VNXFileSystemsProcessor 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.");
        }
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> filesystemList = getQueryResponse(responsePacket);
            List<VNXFileSystem> processedFileSystems = processFilesystemList(filesystemList, keyMap);
            keyMap.put(VNXFileConstants.FILESYSTEMS, processedFileSystems);
            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(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.FAULT_DESC, ex.getMessage());
        keyMap.put(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.CMD_RESULT, com.emc.storageos.plugins.metering.vnxfile.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) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Example 23 with Status

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

the class VNXSnapshotDeleteProcessor method processResult.

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

Example 24 with Status

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

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

the class VNXStoragePortGroupsProcessor 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 datamovers 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<VNXDataMover> movers = new ArrayList<VNXDataMover>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof Mover) {
                    VNXDataMover vnxMover = new VNXDataMover();
                    Mover mover = (Mover) responseObj;
                    vnxMover.setId(Integer.valueOf(mover.getMover()));
                    vnxMover.setName(mover.getName());
                    vnxMover.setRole(mover.getRole().value());
                    _logger.debug("Port Group Information : {}", vnxMover.toString());
                    movers.add(vnxMover);
                }
            }
            _logger.info("Number of Port Groups found : {}", movers.size());
            keyMap.put(VNXFileConstants.STORAGE_PORT_GROUPS, movers);
            // 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) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Mover(com.emc.nas.vnxfile.xmlapi.Mover) VNXDataMover(com.emc.storageos.vnx.xmlapi.VNXDataMover) VNXDataMover(com.emc.storageos.vnx.xmlapi.VNXDataMover) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header)

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