Search in sources :

Example 1 with Checkpoint

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

the class VNXFileCommApi method getCheckpointsOfFilesystem.

/**
 * Gets the list of file system checkpoints
 *
 * @param system storage system details
 * @param fsId the file system ID
 * @return List of checkpoints
 */
@SuppressWarnings("unchecked")
public List<Checkpoint> getCheckpointsOfFilesystem(StorageSystem system, String fsId) {
    _log.info("Check snapshot of file system : {}", fsId);
    List<Checkpoint> checkpoints = null;
    try {
        if (null == fsId || fsId.trim().equals("")) {
            _log.error("FS ID is null or empty: {}", fsId);
            throw VNXException.exceptions.getFileSystemSnapshotsFailed("FS ID is null or empty.");
        }
        Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_ID, fsId);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FS_SNAPSHOT_QUERY));
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (VNXFileConstants.CMD_SUCCESS.equals(cmdResult)) {
            checkpoints = (List<Checkpoint>) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOTS_LIST);
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            throw VNXException.exceptions.getFileSystemSnapshotsFailed(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return checkpoints;
}
Also used : Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 2 with Checkpoint

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

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

the class VNXFSSnapshotsProcessor 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());
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> snapshotList = getQueryResponse(responsePacket);
            List<Checkpoint> snapsList = new ArrayList<Checkpoint>();
            final String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
            _logger.info("Looking for all snapshots of filesystem {}", fsId);
            Iterator<Object> snapshotItr = snapshotList.iterator();
            if (snapshotItr.hasNext()) {
                status = (Status) snapshotItr.next();
                if (status.getMaxSeverity() == Severity.OK) {
                    while (snapshotItr.hasNext()) {
                        Checkpoint point = (Checkpoint) snapshotItr.next();
                        _logger.debug("searching snapshot: {} - {}", point.getName(), point.getCheckpointOf());
                        if (point.getCheckpointOf().equalsIgnoreCase(fsId)) {
                            String id = point.getCheckpoint();
                            String localFSId = point.getCheckpointOf();
                            _logger.info("Found matching snapshot: {} and checkpoint of {}", id, localFSId);
                            snapsList.add(point);
                        }
                    }
                    _logger.info("Number of Snapshots found for FS : {} are : {}", fsId, snapsList.size());
                    keyMap.put(VNXFileConstants.SNAPSHOTS_LIST, snapsList);
                    keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
                } else {
                    _logger.error("Error in getting the snapshot information.");
                    processErrorStatus(status, keyMap);
                }
            }
        }
    } 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) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 4 with Checkpoint

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

the class VNXFileStorageDeviceXML method doCheckFSDependencies.

@Override
public BiosCommandResult doCheckFSDependencies(StorageSystem storage, FileDeviceInputOutput args) {
    _log.info("Checking file system {} has dependencies in storage array: {}", args.getFsName(), storage.getLabel());
    boolean hasDependency = true;
    FileShare fs = args.getFs();
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        String fsMountPath = args.getFsMountPath();
        Map<String, String> nfsShares = vnxComm.getNFSExport(storage, args);
        hasDependency = (nfsShares != null && !nfsShares.isEmpty());
        if (!hasDependency) {
            Map<String, String> cifsShares = vnxComm.getCIFSExport(storage, args);
            hasDependency = (cifsShares != null && !cifsShares.isEmpty());
        }
        if (!hasDependency) {
            List<Checkpoint> snapshots = vnxComm.getCheckpointsOfFilesystem(storage, fs.getNativeId());
            hasDependency = (snapshots != null && !snapshots.isEmpty());
        }
        if (hasDependency) {
            _log.error("File system has dependencies on array: {}", args.getFsName());
            DeviceControllerException e = DeviceControllerException.exceptions.fileSystemHasDependencies(fsMountPath);
            return BiosCommandResult.createErrorResult(e);
        }
        _log.info("File system has no dependencies on array: {}", args.getFsName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (Exception ex) {
        _log.error("Checking FS dependencies failed.", ex);
        throw ex;
    } finally {
        clearContext(context);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 5 with Checkpoint

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

the class VNXSnapshotProcessor method getSnapTotalCapacityOfFileSystems.

/**
 * get the fs and its snapshot in Map<fileSystemId, Map<SnapshotId, snapshotsize>>
 *
 * @param snapshotList
 * @param keyMap
 */
private void getSnapTotalCapacityOfFileSystems(final List<Object> snapshotList, Map<String, Object> keyMap) {
    // snapshot map with fsId's
    Map<String, Map<String, Long>> snapCapFSMap = new HashMap<String, Map<String, Long>>();
    int snapCount = 0;
    long snapCapacity = 0;
    Checkpoint checkPoint = null;
    Map<String, Long> snapCapMap = null;
    // first element is stat object and remaining elem are snapshot's
    Iterator<Object> snapshotItr = snapshotList.iterator();
    snapshotItr.next();
    // processing snapshot list
    while (snapshotItr.hasNext()) {
        checkPoint = (Checkpoint) snapshotItr.next();
        snapCapacity = checkPoint.getFileSystemSize();
        // check if already have fsid in map
        snapCapMap = snapCapFSMap.get(checkPoint.getCheckpointOf());
        if (snapCapMap == null) {
            snapCapMap = new HashMap<String, Long>();
        }
        snapCapMap.put(checkPoint.getCheckpoint(), Long.valueOf(snapCapacity));
        snapCount++;
        snapCapFSMap.put(checkPoint.getCheckpointOf(), snapCapMap);
        _logger.info("filesystem id {} and snapshot id : {} ", checkPoint.getCheckpointOf(), checkPoint.getCheckpoint());
    }
    _logger.info("total filesystems- {} and total snapshots- : {} ", snapCapFSMap.size(), String.valueOf(snapCount));
    // add to keymap for further process data
    keyMap.put(VNXFileConstants.SNAP_CAPACITY_MAP, snapCapFSMap);
    return;
}
Also used : Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint)

Aggregations

Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)7 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)3 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)2 Status (com.emc.nas.vnxfile.xmlapi.Status)2 FileObject (com.emc.storageos.db.client.model.FileObject)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 PostMethod (org.apache.commons.httpclient.methods.PostMethod)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 Snapshot (com.emc.storageos.db.client.model.Snapshot)1 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)1 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)1