Search in sources :

Example 21 with ResponsePacket

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

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

the class VNXSnapshotProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    _logger.info("processing snapshot 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);
            // file system check point info
            getSnapTotalCapacityOfFileSystems(snapshotList, keyMap);
            Iterator<Object> snapshotItr = snapshotList.iterator();
            if (snapshotItr.hasNext()) {
                status = (Status) snapshotItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    final List<Stat> statList = (List<Stat>) keyMap.get(VNXFileConstants.STATS);
                    Iterator<Stat> statsIterator = statList.iterator();
                    while (statsIterator.hasNext()) {
                        Stat stat = statsIterator.next();
                        fetchSnapShotDetails(stat, snapshotList);
                    }
                } else {
                    processErrorStatus(status, keyMap);
                }
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the snapshot response due to {}", ex.getMessage());
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) Stat(com.emc.storageos.db.client.model.Stat) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) PostMethod(org.apache.commons.httpclient.methods.PostMethod) List(java.util.List) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 23 with ResponsePacket

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

the class VNXStoragePortsProcessor 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 storageport 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<VNXDataMoverIntf> dmIntfs = new ArrayList<VNXDataMoverIntf>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof MoverInterface) {
                    MoverInterface mover = (MoverInterface) responseObj;
                    // Check that the interface is up and not an internal network interface.
                    String name = mover.getName();
                    if (mover.isUp() && !name.startsWith("el")) {
                        VNXDataMoverIntf vnxMover = new VNXDataMoverIntf(mover.getName(), mover.getIpAddress(), mover.getMover());
                        _logger.debug("Port Information : {}", vnxMover.toString());
                        dmIntfs.add(vnxMover);
                    }
                }
            }
            _logger.info("Number of Ports found  : {}", dmIntfs.size());
            keyMap.put(VNXFileConstants.STORAGE_PORTS, dmIntfs);
            // 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 storage ports information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx storage ports info response due to ", ex);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) PostMethod(org.apache.commons.httpclient.methods.PostMethod) MoverInterface(com.emc.nas.vnxfile.xmlapi.MoverInterface) ArrayList(java.util.ArrayList) VNXDataMoverIntf(com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header)

Example 24 with ResponsePacket

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

the class VNXStoragePoolProcessor 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 storagepool 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<VNXStoragePool> storagePools = new ArrayList<VNXStoragePool>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                _logger.info("{}", responseObj);
                if (responseObj instanceof StoragePool) {
                    VNXStoragePool vnxPool = new VNXStoragePool();
                    StoragePool storagePool = (StoragePool) responseObj;
                    vnxPool.setName(storagePool.getName());
                    vnxPool.setPoolId(storagePool.getPool());
                    vnxPool.setSize(String.valueOf(storagePool.getSize()));
                    vnxPool.setAutoSize(String.valueOf(storagePool.getAutoSize()));
                    vnxPool.setVirtualProv(String.valueOf(storagePool.isVirtualProvisioning()));
                    vnxPool.setUsedSize(String.valueOf(storagePool.getUsedSize()));
                    SystemStoragePoolData data = storagePool.getSystemStoragePoolData();
                    if (null != data) {
                        String dynamic = String.valueOf(data.isDynamic());
                        vnxPool.setDynamic(dynamic);
                    }
                    _logger.info("VNX Pool Information {}", vnxPool.toString());
                    storagePools.add(vnxPool);
                }
            }
            _logger.info("Number of StorgePools found  : {}", storagePools.size());
            keyMap.put(VNXFileConstants.STORAGEPOOLS, storagePools);
            // 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) StoragePool(com.emc.nas.vnxfile.xmlapi.StoragePool) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) SystemStoragePoolData(com.emc.nas.vnxfile.xmlapi.SystemStoragePoolData)

Example 25 with ResponsePacket

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

the class VNXStoragePortStatsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    _logger.info("processing moversStats response" + resultObj);
    try {
        List<Stat> newstatsList = null;
        Map<String, List<String>> interPortMap = null;
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        List<Stat> statsList = (List<Stat>) keyMap.get(VNXFileConstants.STATS);
        final DbClient dbClient = (DbClient) keyMap.get(VNXFileConstants.DBCLIENT);
        /*
             * step --> 1 get the interface map for mover and interface map contain values as storage ports
             * <MoverId, Map<interfaceIP, list<physicalPortName>>
             */
        Map<String, Map<String, List<String>>> moverInterMap = (Map<String, Map<String, List<String>>>) keyMap.get(VNXFileConstants.INTREFACE_PORT_MAP);
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        List<Object> moversStats = getQueryStatsResponse(responsePacket);
        Iterator<Object> iterator = moversStats.iterator();
        // get the storagesystem from db
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        // process Mover stats contains samples for each data mover and calculate port metrics
        while (iterator.hasNext()) {
            MoverNetStats moverNetStats = (MoverNetStats) iterator.next();
            // process mover stats per data mover
            String moverId = moverNetStats.getMover();
            // get interfaces and their list ports for mover id
            interPortMap = moverInterMap.get(moverId);
            // get the sample data of mover or VDM
            List<MoverNetStats.Sample> sampleList = moverNetStats.getSample();
            Map<String, BigInteger> stringMapPortIOs = new HashMap<String, BigInteger>();
            /*
                 * step -->2 get the io-ops of physical ports from samples
                 * <physicalPortName, Big(input + output band)>
                 */
            getPortIOTraffic(sampleList, stringMapPortIOs);
            // stats sample time
            long sampleTime = sampleList.get(0).getTime();
            /* step -->3 process the port metrics and update storageport object and store in db */
            newstatsList = processPortStatsInfo(interPortMap, stringMapPortIOs, storageSystem, dbClient, sampleTime);
            // finally add to stat object
            statsList.addAll(newstatsList);
        }
        // calculate the avg port utilization for VDM and store in db
        portMetricsProcessor.dataMoverAvgPortMetrics(profile.getSystemId());
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the volume stats response due to {}", ex.getMessage());
    } finally {
        result.releaseConnection();
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) PostMethod(org.apache.commons.httpclient.methods.PostMethod) HashMap(java.util.HashMap) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Stat(com.emc.storageos.db.client.model.Stat) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MoverNetStats(com.emc.nas.vnxfile.xmlapi.MoverNetStats) HashMap(java.util.HashMap) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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