use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileOperationUtils method getExportRules.
public static List<ExportRule> getExportRules(URI id, boolean allDirs, String subDir, DbClient dbClient) {
FileShare fs = dbClient.queryObject(FileShare.class, id);
List<ExportRule> exportRule = new ArrayList<>();
// Query All Export Rules Specific to a File System.
List<FileExportRule> exports = queryDBFSExports(fs, dbClient);
_log.info("Number of existing exports found : {} ", exports.size());
if (allDirs) {
// ALL EXPORTS
for (FileExportRule rule : exports) {
ExportRule expRule = new ExportRule();
// Copy Props
copyPropertiesToSave(rule, expRule, fs);
exportRule.add(expRule);
}
} else if (subDir != null && subDir.length() > 0) {
// Filter for a specific Sub Directory export
for (FileExportRule rule : exports) {
if (rule.getExportPath().endsWith("/" + subDir)) {
ExportRule expRule = new ExportRule();
// Copy Props
copyPropertiesToSave(rule, expRule, fs);
exportRule.add(expRule);
}
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
for (FileExportRule rule : exports) {
if (rule.getExportPath().equalsIgnoreCase(fs.getPath())) {
ExportRule expRule = new ExportRule();
// Copy Props
copyPropertiesToSave(rule, expRule, fs);
exportRule.add(expRule);
}
}
}
_log.info("Number of export rules returning {}", exportRule.size());
return exportRule;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class NetAppApi method modifyNFSShare.
public Boolean modifyNFSShare(String exportPath, List<ExportRule> exportRules) throws NetAppException {
try {
if (netAppFacade == null) {
_logger.warn("Invalid Facade found {} creating now...", netAppFacade);
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
_logger.warn("Facade created : {} ", netAppFacade);
}
_logger.info("NetApp Inputs for modifyNFSShare exportPath: {} , exportRules size {}", exportPath, exportRules.size());
List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
for (ExportRule rule : exportRules) {
com.iwave.ext.netapp.utils.ExportRule netAppRule = new com.iwave.ext.netapp.utils.ExportRule();
copyPropertiesToSave(netAppRule, rule);
netAppCompatableRules.add(netAppRule);
}
netAppFacade.modifyNFSShare(exportPath, netAppCompatableRules);
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
}
return true;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class NetAppApi method exportNewFS.
public Boolean exportNewFS(String exportPath, List<ExportRule> exportRules) throws NetAppException {
try {
List<String> fsList = null;
if (netAppFacade == null) {
_logger.warn("Invalid Facade found {} creating now...", netAppFacade);
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
_logger.warn("Facade created : {} ", netAppFacade);
}
_logger.info("NetApp Inputs for exportNewFS exportPath: {} , exportRules size {}", exportPath, exportRules.size());
List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
for (ExportRule rule : exportRules) {
com.iwave.ext.netapp.utils.ExportRule netAppRule = new com.iwave.ext.netapp.utils.ExportRule();
copyPropertiesToSave(netAppRule, rule);
netAppCompatableRules.add(netAppRule);
}
fsList = netAppFacade.addNewNFSShare(exportPath, netAppCompatableRules);
if (fsList.isEmpty()) {
return false;
}
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
}
return true;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class NetAppClusterApi method modifyNFSShare.
public Boolean modifyNFSShare(String fsName, String qtreeName, String exportPath, ExportRule oldRule, ExportRule newRule) throws NetAppCException {
try {
netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
_logger.info("NetApp Inputs for modifyNFSShare exportPath: {} ", exportPath);
List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
com.iwave.ext.netapp.utils.ExportRule netAppOldRule = new com.iwave.ext.netapp.utils.ExportRule();
copyPropertiesToSave(netAppOldRule, oldRule);
netAppCompatableRules.add(netAppOldRule);
com.iwave.ext.netapp.utils.ExportRule netAppNewRule = new com.iwave.ext.netapp.utils.ExportRule();
copyPropertiesToSave(netAppNewRule, newRule);
netAppCompatableRules.add(netAppNewRule);
netAppClusterFacade.modifyNFSShare(fsName, qtreeName, exportPath, netAppOldRule, netAppNewRule);
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppCException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
}
return true;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
try {
// TODO - These lines may be removed once DD snapshot APIs become available.
if (!args.getFileOperation()) {
// Snapshot Export operation is not supported by Data Domain.
ServiceError serviceError = DeviceControllerErrors.datadomain.operationNotSupported();
serviceError.setMessage("Data Domain does not support snapshot export");
return BiosCommandResult.createErrorResult(serviceError);
}
_log.info("DataDomainFileStorageDevice deleteExportRules - start");
FileShare fs = args.getFs();
// List of existing export rules
List<ExportRule> existingExports = args.getExistingDBExportRules();
if ((existingExports == null) || (existingExports.isEmpty())) {
_log.info("Export rule delete, file system {} does not have an existing export to delete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
}
_log.info("Number of existng Rules found {}", existingExports.size());
// Build export path, adding sub-directory if not null and non-empty
String exportPath;
String subDir = args.getSubDirectory();
StringBuilder expPath = new StringBuilder();
if (!args.getFileOperation()) {
expPath.append(args.getSnapshotPath());
} else {
expPath.append(args.getFs().getPath());
}
if ((subDir != null) && (subDir.length() > 0)) {
expPath.append("/");
expPath.append(subDir);
}
exportPath = expPath.toString();
// Data Domain attaches a prefix to every file system path
expPath = new StringBuilder();
if (!exportPath.startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
expPath.append(DataDomainApiConstants.FS_PATH_BASE);
}
expPath.append(exportPath);
_log.info("exportPath : {}", expPath);
args.setExportPath(expPath.toString());
for (ExportRule expRule : existingExports) {
if (expRule.getExportPath().equals(expPath.toString())) {
args.setObjIdOnDevice(expRule.getDeviceExportId());
break;
}
}
// Do we need to delete all subdirectories as well?
boolean allDirs = args.isAllDir();
// List of IDs of exports to delete
List<String> exportIdsToDelete = new ArrayList<>();
exportIdsToDelete.add(args.getObjIdOnDevice());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("deleteExportRules failed, provider unreachable");
String op = "Delete export rules";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
if (allDirs) {
// Add to the list of IDs of exports to delete
buildListOfIdsToDelete(ddClient, storagePool.getNativeId(), expPath.toString(), exportIdsToDelete);
}
doDeleteExports(ddClient, storagePool.getNativeId(), exportIdsToDelete);
_log.info("DataDomainFileStorageDevice deleteExportRules {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException dde) {
_log.error("Export update failed, device error:", dde);
return BiosCommandResult.createErrorResult(dde);
}
}
Aggregations