use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class VNXeUnexportFileSystemJob method updateSnapExport.
private Snapshot updateSnapExport(DbClient dbClient, VNXeApiClient apiClient) {
URI snapId = getTaskCompleter().getId();
Snapshot snapObj = dbClient.queryObject(Snapshot.class, snapId);
FSExportMap exports = snapObj.getFsExports();
if (exports == null) {
_logger.info("No exports found in the file system. ");
return snapObj;
}
if (exportInfo != null) {
FileExport export = exportInfo.getFileExport();
FileExport existExport = exports.get(export.getFileExportKey());
if (existExport != null) {
exports.remove(existExport.getFileExportKey());
dbClient.persistObject(snapObj);
}
}
return snapObj;
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
_logger.info("exporting the file system: " + args.getFsName());
if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
args.initFileObjExports();
}
for (FileExport exp : exportList) {
VNXeApiClient apiClient = getVnxUnityClient(storage);
String fsId = args.getFs().getNativeId();
String fsName = args.getFsName();
String permission = exp.getPermissions();
String path = "/";
String subdirName = "";
String mountPathArg = exp.getMountPath();
String comments = exp.getComments();
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
String exportKey = exp.getFileExportKey();
FileShareExport newExport = new FileShareExport(exp);
try {
AccessEnum access = null;
List<String> roClients = null;
List<String> rwClients = null;
List<String> rootClients = null;
FileExport existingExport = null;
if (args.getFileOperation()) {
FSExportMap exportMap = args.getFileObjExports();
existingExport = exportMap.get(exportKey);
} else {
FSExportMap exportMap = args.getSnapshotExports();
existingExport = exportMap.get(exportKey);
}
if (existingExport != null) {
if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
access = AccessEnum.READWRITE;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (rwClients == null) {
rwClients = new ArrayList<String>();
}
rwClients.addAll(existingExport.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
access = AccessEnum.READ;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (roClients == null) {
roClients = new ArrayList<String>();
}
roClients.addAll(existingExport.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
access = AccessEnum.ROOT;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (rootClients == null) {
rootClients = new ArrayList<String>();
}
rootClients.addAll(existingExport.getClients());
}
}
}
if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
access = AccessEnum.READWRITE;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (rwClients == null) {
rwClients = new ArrayList<String>();
}
rwClients.addAll(exp.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
access = AccessEnum.READ;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (roClients == null) {
roClients = new ArrayList<String>();
}
roClients.addAll(exp.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
access = AccessEnum.ROOT;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (rootClients == null) {
rootClients = new ArrayList<String>();
}
rootClients.addAll(exp.getClients());
}
}
if (args.getFileOperation()) {
String mountPathFs = args.getFsMountPath();
if (!mountPathArg.equals(mountPathFs)) {
// subdirectory specified.
subdirName = mountPathArg.substring(mountPathFs.length() + 1);
path += subdirName;
}
String shareName = VNXeUtils.buildNfsShareName(fsName, subdirName);
job = apiClient.exportFileSystem(fsId, roClients, rwClients, rootClients, access, path, shareName, null, comments);
if (job != null) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, true);
ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
return BiosCommandResult.createErrorResult(error);
}
} else {
String snapId = args.getSnapNativeId();
String snapName = args.getSnapshotName();
String shareName = VNXeUtils.buildNfsShareName(snapName, path);
job = apiClient.createNfsShareForSnap(snapId, roClients, rwClients, rootClients, access, path, shareName, comments);
if (job != null) {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, false);
ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
return BiosCommandResult.createErrorResult(error);
}
}
} catch (VNXeException e) {
_logger.error("Export file system got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("export file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
_logger.info("Export job submitted");
}
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteFS.
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteFS {} - start", args.getFsId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteFS failed, provider unreachable");
String op = "FS delete";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
// Delete the exports for this file system
FSExportMap exportMap = args.getFsExports();
List<FileExport> exportMapvalues = null;
if (exportMap != null) {
exportMapvalues = new ArrayList<>(exportMap.values());
}
if ((exportMap != null) && (exportMapvalues != null)) {
try {
ddDeleteExports(ddClient, storagePool.getNativeId(), exportMap, exportMapvalues);
} catch (DataDomainApiException dde) {
_log.error("Unable to delete exports for the FS: ", dde);
}
}
// Delete the SMB shares for this file system
SMBShareMap shareMap = args.getFsShares();
List<SMBFileShare> shareMapValues = null;
if (shareMap != null) {
shareMapValues = new ArrayList<>(shareMap.values());
}
if ((shareMap != null) && (shareMapValues != null)) {
try {
ddDeleteShares(ddClient, storagePool.getNativeId(), shareMap, shareMapValues);
} catch (DataDomainApiException dde) {
_log.error("Unable to delete cifs shares for the FS: ", dde);
}
}
// Delete mtree on the DD array
DDServiceStatus ddSvcStatus = ddClient.deleteMTree(storagePool.getNativeId(), args.getFs().getNativeId());
_log.info("DataDomainFileStorageDevice doDeleteFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doDeleteFS failed, device error", e);
return BiosCommandResult.createErrorResult(e);
} catch (DataDomainResourceNotFoundException e) {
_log.error("doDeleteFS failed, Mtree not found.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
_log.info("DataDomainFileStorageDevice doExport {} - start", args.getFileObjId());
// Snapshot Export operation is not supported by Data Domain.
if (args.getFileOperation() == false) {
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.doCreateSnapshotExportFailed());
}
if ((exportList == null) || (exportList.isEmpty())) {
return BiosCommandResult.createSuccessfulResult();
}
try {
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doExport failed, provider unreachable");
String op = "FS export";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
if ((args.getFsExports() == null) || (args.getFsExports().isEmpty())) {
// Initialize exports map
args.initFileObjExports();
}
// Go through the list of new exports and add each to create list
// if not in the list of existing exports or to the modify list if
// contained in the existing list
FSExportMap currExpMap = args.getFsExports();
List<FileExport> modifyFileExports = new ArrayList<>();
List<FileExport> createFileExports = new ArrayList<>();
ddInitCreateModifyFileExportLists(currExpMap, exportList, modifyFileExports, createFileExports);
// Create new exports and add to file export map
ddCreateExports(ddClient, args.getStoragePool().getNativeId(), args.getFsExports(), createFileExports);
// Modify existing exports
ddModifyExports(ddClient, args.getStoragePool().getNativeId(), args.getFsExports(), modifyFileExports);
_log.info("DataDomainFileStorageDevice doExport {} - complete", args.getFileObjId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doExport failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method netAppDeleteNFSExports.
private Boolean netAppDeleteNFSExports(StorageSystem storage, FSExportMap exportMap) throws NetAppException {
int failedCount = 0;
Iterator<Map.Entry<String, FileExport>> it = exportMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, FileExport> entry = it.next();
String key = entry.getKey();
FileExport fsExport = entry.getValue();
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
if (!nApi.deleteNFS(fsExport.getPath())) {
failedCount++;
} else {
exportMap.remove(key);
}
}
if (failedCount > 0) {
return false;
} else {
return true;
}
}
Aggregations