use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddDeleteExports.
private void ddDeleteExports(DataDomainClient ddClient, String storagePoolId, FSExportMap currentExports, List<FileExport> exportsToDelete) {
if ((currentExports != null && (exportsToDelete != null) && (!exportsToDelete.isEmpty()))) {
for (FileExport fileExport : exportsToDelete) {
String key = fileExport.getFileExportKey();
String ddExportId = null;
FileExport fExport = currentExports.get(key);
if (fExport != null) {
ddExportId = fExport.getNativeId();
}
if (ddExportId != null) {
DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, ddExportId);
if (ddExport.getPathStatus() == DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportId);
}
}
}
}
}
use of com.emc.storageos.db.client.model.FileExport 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.FileExport 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.FileExport in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method doUnexport.
@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppFileStorageDevice doUnexport: {} - start", args.getFileObjId());
for (int expCount = 0; expCount < exportList.size(); expCount++) {
FileExport export = exportList.get(expCount);
String portGroup = findVfilerName(args.getFs());
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
if (export.getPermissions() == null) {
export.setPermissions("ro");
}
String mountPath = export.getMountPath();
String exportPath = export.getPath();
if (!nApi.unexportFS(exportPath, mountPath)) {
_log.error("NetAppFileStorageDevice::doUnexport {} failed", args.getFileObjId());
ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
serviceError.setMessage(genDetailedMessage("doUnexport", args.getFileObjId().toString()));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
} else {
_log.info("NetAppFileStorageDevice doUnexport {} - completed", args.getFileObjId());
result = BiosCommandResult.createSuccessfulResult();
}
}
} catch (NetAppException e) {
_log.error("NetAppFileStorageDevice::doUnexport failed with a NetAppException", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppFileStorageDevice::doUnexport failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
_log.info("NetAppFileStorageDevice doUnexport {} - complete", args.getFileObjId());
return result;
}
use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method validateExportArgs.
// Validate the export arguments for the VNX.
//
// The root user mapping must be an integer or the value 'nobody'. Since
// 'nobody' is the default value on the NetApp, it does not need to be sent.
// The CLI only accepts UIDs (integer values).
private void validateExportArgs(List<FileExport> exports) throws ControllerException {
String rootUser = "";
for (FileExport exp : exports) {
// Validate the root user mapping (specific to VNX)
_log.info("FileExport:Clients:" + exp.getClients() + ":SPName:" + exp.getStoragePortName() + ":SP:" + exp.getStoragePort() + ":rootusermapping:" + exp.getRootUserMapping() + ":perm:" + exp.getPermissions() + ":protocol:" + exp.getProtocol() + ":security:" + exp.getSecurityType() + ":subDir:" + exp.getPath());
rootUser = exp.getRootUserMapping();
try {
if (!rootUser.equalsIgnoreCase("nobody") && !rootUser.equalsIgnoreCase("root")) {
Integer.parseInt(rootUser);
}
} catch (NumberFormatException nfe) {
throw new DeviceControllerException("Invalid Root User Mapping {0} ", new Object[] { nfe });
}
}
}
Aggregations