Search in sources :

Example 46 with SMBFileShare

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

SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)46 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)26 FileShare (com.emc.storageos.db.client.model.FileShare)21 Snapshot (com.emc.storageos.db.client.model.Snapshot)16 ArrayList (java.util.ArrayList)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)9 URI (java.net.URI)9 FileExport (com.emc.storageos.db.client.model.FileExport)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 VNXeException (com.emc.storageos.vnxe.VNXeException)8 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)7 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)7 FileObject (com.emc.storageos.db.client.model.FileObject)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5