Search in sources :

Example 91 with BaseCollectionException

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

the class VNXLoginProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod postMethod = (PostMethod) resultObj;
    try {
        Header[] headers = postMethod.getResponseHeaders("Set-Cookie");
        if (null != headers && headers.length > 0) {
            keyMap.put(VNXFileConstants.COOKIE, headers[0].getValue());
            _logger.debug("Recieved cookie information from the Server.");
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the login response due to {}", ex.getMessage());
        throw new VNXFilePluginException("Exception occurred while processing the login response.", ex.getCause());
    } finally {
        postMethod.releaseConnection();
    }
}
Also used : Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 92 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException 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 93 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException 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 94 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException 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)

Example 95 with BaseCollectionException

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

the class VNXVDMProcessor 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 info 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<VNXVdm> vdms = new ArrayList<VNXVdm>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof Vdm) {
                    Vdm system = (Vdm) responseObj;
                    if (system.getState() == VdmState.LOADED) {
                        VNXVdm vdm = new VNXVdm(system.getName(), system.getMover(), system.getVdm(), system.getState().name());
                        vdm.setInterfaces(system.getInterfaces().getLi());
                        vdms.add(vdm);
                    } else {
                        _logger.info("Ignoring VDM {} because not LOADED {}", system.getName(), system.getState().value());
                    }
                }
            }
            keyMap.put(VNXFileConstants.VDM_INFO, vdms);
            // 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) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) Vdm(com.emc.nas.vnxfile.xmlapi.Vdm)

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