Search in sources :

Example 46 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap 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

FSExportMap (com.emc.storageos.db.client.model.FSExportMap)46 FileExport (com.emc.storageos.db.client.model.FileExport)33 ArrayList (java.util.ArrayList)22 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)20 FileShare (com.emc.storageos.db.client.model.FileShare)18 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 Snapshot (com.emc.storageos.db.client.model.Snapshot)11 URI (java.net.URI)11 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)9 WorkflowException (com.emc.storageos.workflow.WorkflowException)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)6 List (java.util.List)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)5