Search in sources :

Example 6 with ResponsePacket

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

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

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

Example 9 with ResponsePacket

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

the class VNXDataMoverInterfaceProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    // TODO Auto-generated method stub
    final PostMethod result = (PostMethod) resultObj;
    _logger.info("processing PortMetrics 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();
            LogicalNetworkDevice logicalNetworkDevice = null;
            // this interface to pysical port map.
            Map<String, List<String>> interPortMap = null;
            // this is mover to interportMap
            Map<String, Map<String, List<String>>> moverInterMap = new HashMap<String, Map<String, List<String>>>();
            Map<String, String> portSpeedMap = new HashMap<String, String>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof LogicalNetworkDevice) {
                    logicalNetworkDevice = (LogicalNetworkDevice) responseObj;
                    // get logical device map
                    interPortMap = moverInterMap.get(logicalNetworkDevice.getMover());
                    if (interPortMap == null) {
                        interPortMap = new HashMap<String, List<String>>();
                    }
                    // process logical network device
                    processNetworkDevice(logicalNetworkDevice, interPortMap);
                    // add to map <movername, Map<interfaceIP, List<physicalport>>
                    if (!interPortMap.isEmpty()) {
                        moverInterMap.put(logicalNetworkDevice.getMover(), interPortMap);
                    }
                    // process logical network device speed
                    processPortSpeed(logicalNetworkDevice, portSpeedMap);
                }
            }
            keyMap.put(VNXFileConstants.INTREFACE_PORT_MAP, moverInterMap);
            // STORAGE_PORT_SPEED_MAP
            keyMap.put(VNXFileConstants.LOGICAL_NETWORK_SPEED_MAP, portSpeedMap);
            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 Port Metrics information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the Port Metrics response due to {}", ex.getMessage());
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) PostMethod(org.apache.commons.httpclient.methods.PostMethod) HashMap(java.util.HashMap) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) LogicalNetworkDevice(com.emc.nas.vnxfile.xmlapi.LogicalNetworkDevice) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) ArrayList(java.util.ArrayList) NameList(com.emc.nas.vnxfile.xmlapi.NameList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with ResponsePacket

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

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