Search in sources :

Example 31 with QuotaDirectory

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

Aggregations

QuotaDirectory (com.emc.storageos.db.client.model.QuotaDirectory)31 FileShareQuotaDirectory (com.emc.storageos.volumecontroller.FileShareQuotaDirectory)17 FileShare (com.emc.storageos.db.client.model.FileShare)15 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)11 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 URI (java.net.URI)9 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 MapQuotaDirectory (com.emc.storageos.api.mapper.functions.MapQuotaDirectory)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 URISyntaxException (java.net.URISyntaxException)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)4