Search in sources :

Example 6 with Checkpoint

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

the class VNXSnapshotProcessor method fetchSnapShotDetails.

/**
 * fetches the snapshot details from the checkpoint list.
 *
 * @param stat
 *            : Stat object.
 * @param ckptList
 *            : List of checkpoints.
 */
private void fetchSnapShotDetails(final Stat stat, final List<Object> snapshotList) {
    int snapCount = 0;
    long snapCapacity = 0;
    Checkpoint checkPoint = 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();
        if (fetchNativeId(stat.getNativeGuid()).equals(checkPoint.getCheckpointOf())) {
            snapCount++;
            snapCapacity += (Long.valueOf(checkPoint.getFileSystemSize()) * 1024);
        }
    }
    stat.setSnapshotCount(snapCount);
    stat.setSnapshotCapacity(snapCapacity);
}
Also used : Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint)

Example 7 with Checkpoint

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

the class VNXFileCommApi method deleteFileSystem.

public XMLApiResult deleteFileSystem(final StorageSystem system, final String fileId, final String fileSys, final boolean isForceDelete, FileShare fs) throws VNXException {
    _log.info("Delete VNX File System: fs id {}, Force Delete {}", fileId, isForceDelete);
    XMLApiResult result = new XMLApiResult();
    if (null == fileId || null == fileSys || fileId.trim().equals("") || fileSys.trim().equals("")) {
        result.setCommandFailed();
        result.setMessage("Invalid Input Parameters.");
        return result;
    }
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fileSys);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_ID, fileId);
        _provExecutor.setKeyMap(reqAttributeMap);
        // Before deleting check whether it is available or not on the array - This need to be done as part of
        // deleting un-managed FS.
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE_DELETE));
        boolean isFsAvailable = false;
        _log.debug("Listing VNX File File Systems");
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (null != cmdResult && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            isFsAvailable = (Boolean) _provExecutor.getKeyMap().get(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY);
        }
        if (!isFsAvailable) {
            _log.debug("File System **Not found on array which requested to delete.");
            result.setCommandSuccess();
        // No need to set Inactive and persist here as this will be done in upper layer(FileDeviceController)
        }
        if (isForceDelete) {
            // handle snapshots
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FS_FORCE_DEL_FILE));
            cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
            StorageHADomain dataMover = getDataMover(fs);
            if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
                List<Checkpoint> snaps = (List<Checkpoint>) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOTS_LIST);
                int numSnapshots = (snaps != null) ? snaps.size() : 0;
                _log.info("Number of Snapshots found {} for a file system {}", numSnapshots, fileId);
                if (snaps != null && !snaps.isEmpty()) {
                    for (Checkpoint checkpoint : snaps) {
                        _log.info("Deleting Snapshot having name {} - and id {}", checkpoint.getName(), checkpoint.getCheckpoint());
                        String nativeGuid = NativeGUIDGenerator.getNativeGuidforSnapshot(system, system.getSerialNumber(), checkpoint.getCheckpoint());
                        _log.info("NativeGuid {} built for snapshot {}", nativeGuid, checkpoint.getCheckpoint());
                        Snapshot snapshot = null;
                        List<URI> snapShotUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotNativeGuidConstraint(nativeGuid));
                        _log.info("{} Snapshots found with native guid : {} ", snapShotUris.size(), nativeGuid);
                        if (!snapShotUris.isEmpty()) {
                            _log.info("Retriving Snapshot using URI : {} ", snapShotUris.get(0));
                            snapshot = _dbClient.queryObject(Snapshot.class, snapShotUris.get(0));
                        }
                        if (snapshot != null) {
                            result = deleteAllExportsAndShares(system, dataMover, fs, snapshot);
                            XMLApiResult status = doDeleteSnapshot(system, checkpoint.getCheckpoint(), checkpoint.getName(), false);
                            if (!status.isCommandSuccess()) {
                                String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
                                result.setCommandFailed();
                                result.setMessage(errMsg);
                                return result;
                            }
                        }
                    }
                }
                // Delete All Quota directories of FileShare.
                result = deleteAllQuotaDirs(system, dataMover, fs);
                // Delete Exports/SMB Shares of FileShare
                result = deleteAllExportsAndShares(system, dataMover, fs, null);
            } else {
                String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
                result.setCommandFailed();
                result.setMessage(errMsg);
                return result;
            }
        }
        if (isFsAvailable) {
            _log.debug("File System found on array which requested to delete. Now, deleting on Array.");
            // First unmount it
            StorageHADomain dataMover = getDataMover(fs);
            if (dataMover != null) {
                Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
                // is FS mount still exists?
                if (existingMounts.get(fs.getName()) != null) {
                    // The File system is mounted and we need to unmount it before deleting it
                    String unMountCmd = sshApi.formatUnMountCmd(dataMover.getAdapterName(), fs.getMountPath(), "NFS");
                    _log.info("Unmount FS {}", unMountCmd);
                    sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
                    result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, unMountCmd);
                }
            } else {
                _log.info("No need to Unmount FS {} since there is no mount info", fs.getMountPath());
            }
            _provExecutor.setKeyMap(reqAttributeMap);
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSDEL_FILE));
            cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
            if (null != cmdResult && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
                result.setCommandSuccess();
            } else {
                String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
                result.setCommandFailed();
                result.setMessage(errMsg);
            }
        }
    } catch (Exception e) {
        throw new VNXException("File system delete exception: ", e);
    }
    return result;
}
Also used : XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URI(java.net.URI) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ArrayList(java.util.ArrayList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

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