Search in sources :

Example 11 with MountInfo

use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.

the class FileDeviceController method addStepsForDeleteFileSystems.

public String addStepsForDeleteFileSystems(Workflow workflow, String waitFor, List<FileDescriptor> filesystems, String taskId) throws InternalException {
    List<FileDescriptor> sourceDescriptors = FileDescriptor.filterByType(filesystems, FileDescriptor.Type.FILE_DATA, FileDescriptor.Type.FILE_EXISTING_SOURCE, FileDescriptor.Type.FILE_MIRROR_SOURCE);
    // Segregate by device.
    Map<URI, List<FileDescriptor>> deviceMap = FileDescriptor.getDeviceMap(sourceDescriptors);
    // Add a step to delete the fileshares in each device.
    for (URI deviceURI : deviceMap.keySet()) {
        filesystems = deviceMap.get(deviceURI);
        List<URI> fileshareURIs = FileDescriptor.getFileSystemURIs(filesystems);
        for (URI uriFile : fileshareURIs) {
            FileShare fsObj = _dbClient.queryObject(FileShare.class, uriFile);
            // unmount exports only if FULL delete
            if (FileControllerConstants.DeleteTypeEnum.FULL.toString().equalsIgnoreCase(filesystems.get(0).getDeleteType())) {
                waitFor = createMethod(workflow, waitFor, CHECK_FILESYSTEM_DEPENDENCIES_METHOD, null, "Check File System dependencies: NFS and CIFS exports and snapshots", fsObj.getStorageDevice(), new Object[] { fsObj.getStorageDevice(), fsObj.getId() });
                // get all the mounts and generate steps for unmounting them
                List<MountInfo> mountList = getAllMountedExports(uriFile, null, true);
                for (MountInfo mount : mountList) {
                    Object[] args = new Object[] { mount.getHostId(), mount.getFsId(), mount.getMountPath() };
                    waitFor = createMethod(workflow, waitFor, UNMOUNT_FILESYSTEM_EXPORT_METHOD, null, "Unmounting path:" + mount.getMountPath(), fsObj.getStorageDevice(), args);
                }
            } else {
                // Only remove the mounts from CoPRHD database if Inventory Only delete
                Object[] args = new Object[] { uriFile };
                waitFor = createMethod(workflow, waitFor, CHECK_IF_MOUNT_EXISTS_ON_HOST, null, "Confirming mount dependencies for fs:" + fsObj.getId(), fsObj.getStorageDevice(), args);
            }
            if (fsObj != null && fsObj.getMirrorfsTargets() != null) {
                for (String mirrorTarget : fsObj.getMirrorfsTargets()) {
                    URI targetURI = URI.create(mirrorTarget);
                    FileShare fsTargObj = _dbClient.queryObject(FileShare.class, targetURI);
                    if (fsTargObj != null && !fsTargObj.getInactive()) {
                        _log.info("addStepsForDeleteFileSystems - deleting target fs {} for file system {}", fsTargObj.getId(), fsObj.getId());
                        workflow.createStep(DELETE_FILESYSTEMS_STEP, String.format("Deleting fileshares:%n%s", asList(targetURI)), waitFor, fsTargObj.getStorageDevice(), getDeviceType(fsTargObj.getStorageDevice()), this.getClass(), deleteFileSharesMethod(fsTargObj.getStorageDevice(), asList(targetURI), filesystems.get(0).isForceDelete(), filesystems.get(0).getDeleteType(), taskId), null, null);
                    }
                }
            }
            // Dont delete the source file system for delete only targets operation!!
            if (!filesystems.get(0).isDeleteTargetOnly()) {
                _log.info("addStepsForDeleteFileSystems - deleting source fs {} ", fsObj.getId());
                workflow.createStep(DELETE_FILESYSTEMS_STEP, String.format("Deleting fileshares:%n%s", fileshareURIs), waitFor, deviceURI, getDeviceType(deviceURI), this.getClass(), deleteFileSharesMethod(deviceURI, fileshareURIs, filesystems.get(0).isForceDelete(), filesystems.get(0).getDeleteType(), taskId), null, null);
            }
        }
    }
    return waitFor = DELETE_FILESYSTEMS_STEP;
}
Also used : Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) FileObject(com.emc.storageos.db.client.model.FileObject) DataObject(com.emc.storageos.db.client.model.DataObject) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Aggregations

MountInfo (com.emc.storageos.model.file.MountInfo)11 FileMountInfo (com.emc.storageos.db.client.model.FileMountInfo)6 ArrayList (java.util.ArrayList)5 FileObject (com.emc.storageos.db.client.model.FileObject)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 Snapshot (com.emc.storageos.db.client.model.Snapshot)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 FileSnapshotWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter)2 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)2 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)2 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)2 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2