use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileDeviceController method queryFileExports.
private List<FileExportRule> queryFileExports(FileDeviceInputOutput args) {
List<FileExportRule> fileExportRules = null;
try {
ContainmentConstraint containmentConstraint;
if (args.getFileOperation()) {
FileShare fs = args.getFs();
_log.info("Querying all ExportRules Using FsId {}", fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
} else {
URI snapshotId = args.getSnapshotId();
_log.info("Querying all ExportRules Using Snapshot Id {}", snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshotId);
}
fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return fileExportRules;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileDeviceController method doDeleteExportRulesFromDB.
private void doDeleteExportRulesFromDB(boolean allDirs, String subDir, FileDeviceInputOutput args) throws Exception {
// Query All Export Rules Specific to a File System.
// queryExports
List<FileExportRule> exports = queryFileExports(args);
if (exports != null && !exports.isEmpty()) {
if (allDirs) {
// ALl EXPORTS
_log.info("Doing CRUD Operations on all DB FileExportRules for requested fs");
for (FileExportRule rule : exports) {
_log.info("Deleting export rule from DB having path {} - Rule :{}", rule.getExportPath(), rule);
rule.setInactive(true);
_dbClient.updateObject(rule);
}
} else if (subDir != null && !subDir.isEmpty()) {
// Filter for a specific Sub Directory export
_log.info("Doing CRUD Operations on DB FileExportRules Specific to SubDirectory {}", subDir);
for (FileExportRule rule : exports) {
if (rule.getExportPath().endsWith("/" + subDir)) {
_log.info("Deleting Subdiretcory export rule from DB having path {} - Rule :{}", rule.getExportPath(), rule);
rule.setInactive(true);
_dbClient.updateObject(rule);
}
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
for (FileExportRule rule : exports) {
if (args.getFileOperation() && rule.getExportPath().equalsIgnoreCase(args.getFsPath())) {
_log.info("Deleting export rule from DB having path {} - Rule :{}", rule.getExportPath(), rule);
rule.setInactive(true);
_dbClient.updateObject(rule);
} else if (args.getFileOperation() == false && rule.getExportPath().equalsIgnoreCase(args.getSnapshotPath())) {
_log.info("Deleting snapshot export rule from DB having path {} - Rule :{}", rule.getExportPath(), rule);
rule.setInactive(true);
_dbClient.updateObject(rule);
}
}
}
}
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileDeviceController method getAvailableExportRule.
private FileExportRule getAvailableExportRule(FileExportRule exportRule, FileDeviceInputOutput args) throws URISyntaxException {
String exportIndex = exportRule.getFsExportIndex();
if (!args.getFileOperation()) {
exportIndex = exportRule.getSnapshotExportIndex();
}
_log.info("Retriving DB Model using its index {}", exportIndex);
FileExportRule rule = null;
URIQueryResultList result = new URIQueryResultList();
if (!args.getFileOperation()) {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(exportIndex), result);
} else {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(exportIndex), result);
}
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
if (result.iterator().hasNext()) {
rule = _dbClient.queryObject(FileExportRule.class, it.next());
if (rule != null && !rule.getInactive()) {
_log.info("Existing DB Model found {}", rule);
break;
}
}
}
return rule;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getFSExportRuleMap.
/**
* This method generates export map for the file system export rules.
*
* @param fs File System Object
* @param dbClient
* @return
*/
public static HashMap<String, List<ExportRule>> getFSExportRuleMap(FileShare fs, DbClient dbClient) {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
List<FileExportRule> fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileExportRule.class, containmentConstraint);
HashMap<String, List<ExportRule>> exportRulesMap = new HashMap<String, List<ExportRule>>();
for (FileExportRule fileExportRule : fileExportRules) {
if (exportRulesMap.get(fileExportRule.getExportPath()) == null) {
List<ExportRule> exportRules = new ArrayList<ExportRule>();
ExportRule exportRule = convertFileExportRuleToExportRule(fileExportRule);
exportRules.add(exportRule);
exportRulesMap.put(fileExportRule.getExportPath(), exportRules);
} else {
List<ExportRule> exportRules = exportRulesMap.get(fileExportRule.getExportPath());
ExportRule exportRule = convertFileExportRuleToExportRule(fileExportRule);
exportRules.add(exportRule);
}
}
return exportRulesMap;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method createRule.
private void createRule(UnManagedFileExportRule orig, List<FileExportRule> fsExportRules) {
FileExportRule dest = new FileExportRule();
dest.setId(URIUtil.createId(FileExportRule.class));
dest.setFileSystemId(orig.getFileSystemId());
dest.setExportPath(orig.getExportPath());
dest.setSecFlavor(orig.getSecFlavor());
dest.setAnon(orig.getAnon());
dest.setMountPoint(orig.getMountPoint());
dest.setDeviceExportId(orig.getDeviceExportId());
if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
}
if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
}
if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
dest.setRootHosts(new StringSet(orig.getRootHosts()));
}
_logger.info("Ingesting Export Rule : {}", dest);
fsExportRules.add(dest);
}
Aggregations