Search in sources :

Example 66 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class FileDeviceController method deleteQDExportsAndShares.

/**
 * Delete NFS exports and shares file system quota directory
 *
 * @param storage
 * @param fs
 * @param quotaDirObj
 * @param task
 */
private void deleteQDExportsAndShares(URI storage, FileShare fs, QuotaDirectory quotaDirObj, String task) {
    FSExportMap fsExportMap = fs.getFsExports();
    String quotaName = quotaDirObj.getName();
    boolean isExported = false;
    // delete export
    if (fsExportMap != null && !fsExportMap.isEmpty()) {
        // check the quota directory is exported
        for (FileExport fileExport : fsExportMap.values()) {
            if (quotaName.equals(fileExport.getSubDirectory()) && fileExport.getPath().endsWith(quotaName)) {
                isExported = true;
                _log.info("Delete the nfs sub directory export path {} and key {}", fileExport.getPath(), fileExport.getFileExportKey());
            }
        }
        if (true == isExported) {
            // delete the export of quota directory
            this.deleteExportRules(storage, fs.getId(), false, quotaName, task);
        }
    }
    // delete fileshare of quota directory
    SMBShareMap smbShareMap = fs.getSMBFileShares();
    if (smbShareMap != null && !smbShareMap.isEmpty()) {
        FileSMBShare fileSMBShare = null;
        List<FileSMBShare> fileSMBShares = new ArrayList<FileSMBShare>();
        for (SMBFileShare smbFileShare : smbShareMap.values()) {
            // check for quotaname in native fs path
            if (true == (smbFileShare.getPath().endsWith(quotaName))) {
                fileSMBShare = new FileSMBShare(smbFileShare);
                _log.info("Delete the cifs sub directory path of quota directory {}", smbFileShare.getPath());
                fileSMBShares.add(fileSMBShare);
            }
        }
        if (fileSMBShares != null && !fileSMBShares.isEmpty()) {
            // delete shares
            for (FileSMBShare tempFileSMBShare : fileSMBShares) {
                this.deleteShare(storage, fs.getId(), tempFileSMBShare, task);
                _log.info("Delete SMB Share Name{} for quota ", tempFileSMBShare.getName());
            }
        }
    }
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileSMBShare(com.emc.storageos.volumecontroller.FileSMBShare)

Aggregations

FileExport (com.emc.storageos.db.client.model.FileExport)66 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)33 ArrayList (java.util.ArrayList)32 FileShare (com.emc.storageos.db.client.model.FileShare)31 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)29 Snapshot (com.emc.storageos.db.client.model.Snapshot)21 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)20 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)18 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)16 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)14 VNXeException (com.emc.storageos.vnxe.VNXeException)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 URI (java.net.URI)10 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)8 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)8 FileObject (com.emc.storageos.db.client.model.FileObject)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7