Search in sources :

Example 71 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class MetricSequenceProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        while (it.hasNext()) {
            CIMInstance blockManifestInstance = null;
            try {
                blockManifestInstance = it.next();
                String elementType = getCIMPropertyValue(blockManifestInstance, Constants.ELEMENTTYPE);
                String elementName = getCIMPropertyValue(blockManifestInstance, Constants.ELEMENTNAME);
                String[] csvSeq = (String[]) blockManifestInstance.getPropertyValue(Constants.CSV_SEQUENCE);
                List<String> csvSequenceList = new LinkedList<String>(Arrays.asList(csvSeq));
                _logger.debug("csvSequenceList: {}", csvSequenceList);
                if (elementType.equals(Constants.VOLUME_ELEMENTTYPE) && elementName.equals(Constants.STORAGEOS_VOLUME_MANIFEST)) {
                    keyMap.put(Constants.STORAGEOS_VOLUME_MANIFEST, csvSequenceList);
                } else if (elementType.equals(Constants.FEPORT_ELEMENTTYPE) && elementName.equals(Constants.STORAGEOS_FEPORT_MANIFEST)) {
                    keyMap.put(Constants.STORAGEOS_FEPORT_MANIFEST, csvSequenceList);
                } else if (elementType.equals(Constants.FEADAPT_ELEMENTTYPE) && elementName.equals(Constants.STORAGEOS_FEADAPT_MANIFEST)) {
                    keyMap.put(Constants.STORAGEOS_FEADAPT_MANIFEST, csvSequenceList);
                } else if (elementType.equals(Constants.SYSTEM_ELEMENTTYPE) && elementName.equals(Constants.STORAGEOS_SYSTEM_MANIFEST)) {
                    keyMap.put(Constants.STORAGEOS_SYSTEM_MANIFEST, csvSequenceList);
                }
            } catch (Exception e) {
                _logger.warn("MetricSequence call failed for {}", getCIMPropertyValue(blockManifestInstance, Constants.INSTANCEID), e);
            }
        }
    } catch (Exception e) {
        _logger.error("Processing MetricSequence call failed", e);
    }
}
Also used : Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) LinkedList(java.util.LinkedList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 72 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class QueryStatisticsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<?> it = (Iterator<?>) resultObj;
        // Only 1 entry per each Array always
        while (it.hasNext()) {
            final CIMInstance queryInstance = (CIMInstance) it.next();
            keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
            addPath(keyMap, operation.getResult(), queryInstance.getObjectPath());
        }
    } catch (Exception e) {
        _logger.error("Failed while processing QueryStatistics :", e);
    }
    resultObj = null;
}
Also used : Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 73 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class SPProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<?> it = (Iterator<?>) resultObj;
    while (it.hasNext()) {
        try {
            final CIMInstance allocatedfrompool = (CIMInstance) it.next();
            CIMObjectPath path = (CIMObjectPath) allocatedfrompool.getProperty("Dependent").getValue();
            if (path.getObjectName().contains(_volume)) {
                String key = createKeyfromPath(path);
                // this check means, validating whether this Volume is
                // managed by Bourne
                Stat metrics = (Stat) getMetrics(keyMap, key);
                _logger.debug("Processing Volume to extract Allocated Capacity: {}", key);
                // Allocated Capacity =
                // CIM_AllocatedFromStoragePool.SpaceConsumed (in bytes)
                metrics.setAllocatedCapacity(Long.parseLong(allocatedfrompool.getProperty(_spaceConsumed).getValue().toString()));
            }
        } catch (Exception e) {
            if (!(e instanceof BaseCollectionException)) {
                _logger.error(" Allocated Capacity : ", e);
            }
        }
    }
    resultObj = null;
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 74 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class VNXAllQuotaDirsProcessor 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 {
            List<Object> quotaDirList = getQueryResponse(responsePacket);
            List<TreeQuota> quotaDirs = new ArrayList<TreeQuota>();
            _logger.info("Received the response size {} ", 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());
                        String id = quotaDir.getTree();
                        quotaDirs.add(quotaDir);
                        _logger.info("Found matching quota dir id: {}", id);
                    }
                    keyMap.put(VNXFileConstants.QUOTA_DIR_LIST, quotaDirs);
                    keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                }
            }
        }
    } 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) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) TreeQuota(com.emc.nas.vnxfile.xmlapi.TreeQuota)

Example 75 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class VNXCifsConfigProcessor 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 cifs config response" + 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> queryResponse = getQueryResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            Boolean enabled = false;
            List<VNXCifsServer> cifsServers = new ArrayList<>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof CifsServer) {
                    CifsServer config = (CifsServer) responseObj;
                    _logger.info("CIFS Interfaces: {}, for VDM: {}", config.getInterfaces(), config.getMover());
                    enabled = true;
                    // Get the domain of cifs server!!!
                    String domain = new String();
                    if (config.getNT40ServerData() != null) {
                        domain = config.getNT40ServerData().getDomain();
                    } else if (config.getW2KServerData() != null) {
                        domain = config.getW2KServerData().getDomain();
                    } else if (config.getStandaloneServerData() != null) {
                        domain = config.getStandaloneServerData().getWorkgroup();
                    }
                    if (!domain.isEmpty()) {
                        _logger.info("domain cofigured for cifs : {}", domain);
                    }
                    VNXCifsServer server = new VNXCifsServer(config.getName(), config.getMover(), config.getType().toString(), config.isMoverIdIsVdm(), config.getInterfaces(), domain);
                    cifsServers.add(server);
                    _logger.info("Add : {}", server.toString());
                }
            }
            keyMap.put(VNXFileConstants.CIFS_SUPPORTED, enabled);
            keyMap.put(VNXFileConstants.CIFS_SERVERS, cifsServers);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx cifs config 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) VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) CifsServer(com.emc.nas.vnxfile.xmlapi.CifsServer) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header)

Aggregations

BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)185 Iterator (java.util.Iterator)66 CIMInstance (javax.cim.CIMInstance)66 CIMObjectPath (javax.cim.CIMObjectPath)59 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)55 IOException (java.io.IOException)47 URI (java.net.URI)47 ArrayList (java.util.ArrayList)47 PostMethod (org.apache.commons.httpclient.methods.PostMethod)36 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)35 Status (com.emc.nas.vnxfile.xmlapi.Status)33 AccessProfile (com.emc.storageos.plugins.AccessProfile)30 List (java.util.List)30 Map (java.util.Map)30 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 StoragePool (com.emc.storageos.db.client.model.StoragePool)27 Header (org.apache.commons.httpclient.Header)27 StoragePort (com.emc.storageos.db.client.model.StoragePort)22 HashSet (java.util.HashSet)18 URISyntaxException (java.net.URISyntaxException)17