use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method verifyDeleteExportRule.
/**
* Verify each export rule that can be added
*
* @param fs
* @param listExportRule
*/
private void verifyDeleteExportRule(List<ExportRule> listExportRule) throws Exception {
if (listExportRule == null) {
return;
}
_log.info("{} Export Rule(s) Requested to Delete {} - Iterating ..", listExportRule.size());
for (ExportRule exportRule : listExportRule) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
_log.info("Verifying Export Rule {}", exportRule.toString());
// is same security flavor found in several exports - report the error
scanForDuplicateSecFlavor(exportRule);
if (!exportRule.isToProceed()) {
_log.info("Same Security Flavor found across the exports {}", exportRule.toString());
break;
}
FileExportRule rule = validateInputAndQueryDB(exportRule);
// If found -- allow to delete.
if (rule != null) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
} else // If not, stop proceed further.
{
_log.info("Export not found to delete");
exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_NOT_FOUND);
}
}
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method saveAndRetrieveExportURIs.
public void saveAndRetrieveExportURIs(List<ExportRule> listExportRule, ExportOperationType type) {
if (listExportRule == null) {
return;
}
for (ExportRule exportRule : listExportRule) {
if (exportRule.isToProceed()) {
FileExportRule rule = new FileExportRule();
copyPropertiesToSave(rule, exportRule);
rule.setOpType(type.name());
URI uri = URIUtil.createId(FileExportRule.class);
rule.setId(uri);
_log.debug("Saving Object {}", rule.toString());
_dbClient.createObject(rule);
allSavedURIs.add(uri);
}
continue;
}
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method validateInputAndQueryDB.
private FileExportRule validateInputAndQueryDB(ExportRule exportRule) throws Exception {
FileExportRule rule = null;
verifyExportSecurity(exportRule);
if (exportRule.isToProceed()) {
rule = new FileExportRule();
copyProperties(rule, exportRule);
rule = getAvailableExportRule(rule);
}
return rule;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method queryExports.
private List<FileExportRule> queryExports(FileShare fs, Snapshot snapshot, boolean isFile) {
try {
ContainmentConstraint containmentConstraint;
if (isFile) {
_log.info("Querying all ExportRules Using FsId {}", fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
} else {
URI snapshotId = snapshot.getId();
_log.info("Querying all ExportRules Using Snapshot Id {}", snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshotId);
}
List<FileExportRule> fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
return fileExportRules;
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return null;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileSystemExportToFileSystemExportRuleMigration method createSnapshotExportRules.
private List<FileExportRule> createSnapshotExportRules(Snapshot snapshot) {
List<FileExportRule> fsExpRuleList = new ArrayList<FileExportRule>();
FSExportMap fsExportMap = snapshot.getFsExports();
if (fsExportMap != null) {
for (String exportKey : fsExportMap.keySet()) {
FileExport fsExport = fsExportMap.get(exportKey);
FileExportRule expRule = new FileExportRule();
expRule.setId(URIUtil.createId(FileExportRule.class));
copyFileExportData(fsExport, expRule);
// Set snapshotId in the end as setSnapshotId() calculates
// snapshotExportIndex with exportPath and security flavor
expRule.setSnapshotId(snapshot.getId());
fsExpRuleList.add(expRule);
}
}
return fsExpRuleList;
}
Aggregations