Search in sources :

Example 11 with FileSMBShare

use of com.emc.storageos.volumecontroller.FileSMBShare in project coprhd-controller by CoprHD.

the class FileDeviceController method recordFileDeviceOperation.

public static void recordFileDeviceOperation(DbClient dbClient, OperationTypeEnum opType, boolean opStatus, String evDesc, String extensions, Object... extParam) {
    String evType;
    if (evDesc == null || evDesc.isEmpty()) {
        evDesc = opType.getDescription();
    }
    evType = opType.getEvType(opStatus);
    String opStage = AuditLogManager.AUDITOP_END;
    _log.info("opType: {} detail: {}", opType.toString(), evType + ':' + evDesc);
    FileShare fs = null;
    Snapshot snapshotObj = null;
    QuotaDirectory quotaDirObj = null;
    if (extParam[0] instanceof Snapshot) {
        snapshotObj = (Snapshot) extParam[0];
        fs = (FileShare) extParam[1];
        recordSnapshotEvent(dbClient, snapshotObj, fs, evType, evDesc, extensions);
    } else if (extParam[0] instanceof QuotaDirectory) {
        quotaDirObj = (QuotaDirectory) extParam[0];
        fs = (FileShare) extParam[1];
        recordQuotaDirectoryEvent(dbClient, quotaDirObj, fs, evType, evDesc, extensions);
    } else if (extParam[0] instanceof FileShare) {
        fs = (FileShare) extParam[0];
        recordFsEvent(dbClient, fs, evType, evDesc, extensions);
    } else {
        _log.error("unrecognized param list");
    }
    FileSMBShare smbShare = null;
    switch(opType) {
        case CREATE_FILE_SYSTEM:
            auditFile(dbClient, opType, opStatus, opStage, fs.getLabel(), fs.getVirtualArray().toString(), (fs.getProject() != null) ? fs.getProject().toString() : null);
            break;
        case DELETE_FILE_SYSTEM:
            auditFile(dbClient, opType, opStatus, opStage, fs.getId().toString(), ((StorageSystem) extParam[1]).getId().toString());
            break;
        case DELETE_FILE_SNAPSHOT:
            auditFile(dbClient, opType, opStatus, opStage, snapshotObj.getId().toString(), ((StorageSystem) extParam[2]).getId().toString());
            break;
        case EXPORT_FILE_SYSTEM:
        case UPDATE_EXPORT_RULES_FILE_SYSTEM:
        case UPDATE_FILE_SYSTEM_SHARE_ACL:
        case UNEXPORT_FILE_SYSTEM:
            auditFile(dbClient, opType, opStatus, opStage, fs.getId().toString(), ((StorageSystem) extParam[1]).getId().toString(), extensions);
            break;
        case EXPAND_FILE_SYSTEM:
        case REDUCE_FILE_SYSTEM:
            auditFile(dbClient, opType, opStatus, opStage, fs.getId().toString(), extParam[1]);
            break;
        case CREATE_FILE_SYSTEM_SHARE:
        case DELETE_FILE_SYSTEM_SHARE:
            smbShare = (FileSMBShare) extParam[1];
            auditFile(dbClient, opType, opStatus, opStage, smbShare.getName(), smbShare.getPermissionType(), smbShare.getPermission(), smbShare.getMaxUsers(), smbShare.getDescription(), fs.getId().toString());
            break;
        case RESTORE_FILE_SNAPSHOT:
            URI snapshot = (URI) extParam[1];
            auditFile(dbClient, opType, opStatus, opStage, snapshot, fs.getId().toString());
            break;
        case CREATE_FILE_SYSTEM_SNAPSHOT:
            auditFile(dbClient, opType, opStatus, opStage, snapshotObj.getLabel(), snapshotObj.getId(), fs.getId().toString());
            break;
        case EXPORT_FILE_SNAPSHOT:
        case UPDATE_EXPORT_RULES_FILE_SNAPSHOT:
        case UPDATE_FILE_SNAPSHOT_SHARE_ACL:
        case UNEXPORT_FILE_SNAPSHOT:
            auditFile(dbClient, opType, opStatus, opStage, snapshotObj.getId().toString(), ((StorageSystem) extParam[2]).getId().toString(), extensions);
            break;
        case CREATE_FILE_SNAPSHOT_SHARE:
        case DELETE_FILE_SNAPSHOT_SHARE:
            smbShare = (FileSMBShare) extParam[2];
            auditFile(dbClient, opType, opStatus, opStage, smbShare.getName(), smbShare.getPermissionType(), smbShare.getPermission(), smbShare.getMaxUsers(), smbShare.getDescription(), snapshotObj.getId().toString());
            break;
        case CREATE_FILE_SYSTEM_QUOTA_DIR:
        case DELETE_FILE_SYSTEM_QUOTA_DIR:
        case UPDATE_FILE_SYSTEM_QUOTA_DIR:
            auditFile(dbClient, opType, opStatus, opStage, quotaDirObj.getLabel(), quotaDirObj.getId(), fs.getId().toString());
            break;
        case DELETE_FILE_SYSTEM_SHARE_ACL:
            auditFile(dbClient, opType, opStatus, opStage, fs.getId().toString(), ((StorageSystem) extParam[1]).getId().toString(), extensions);
            break;
        case DELETE_FILE_SNAPSHOT_SHARE_ACL:
            auditFile(dbClient, opType, opStatus, opStage, snapshotObj.getId().toString(), ((StorageSystem) extParam[2]).getId().toString(), extensions);
            break;
        case ASSIGN_FILE_SYSTEM_SNAPSHOT_SCHEDULE:
        case UNASSIGN_FILE_SYSTEM_SNAPSHOT_SCHEDULE:
            auditFile(dbClient, opType, opStatus, opStage, fs.getId().toString(), ((SchedulePolicy) extParam[1]).getId().toString(), extensions);
            break;
        default:
            _log.error("unrecognized fileshare operation type");
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) FileSMBShare(com.emc.storageos.volumecontroller.FileSMBShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) SchedulePolicy(com.emc.storageos.db.client.model.SchedulePolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with FileSMBShare

use of com.emc.storageos.volumecontroller.FileSMBShare 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)12 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)12 FileShare (com.emc.storageos.db.client.model.FileShare)9 Snapshot (com.emc.storageos.db.client.model.Snapshot)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 Operation (com.emc.storageos.db.client.model.Operation)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)4 VNXeException (com.emc.storageos.vnxe.VNXeException)4 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)4 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)4 Consumes (javax.ws.rs.Consumes)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)2 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)2