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");
}
}
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());
}
}
}
}
Aggregations