Search in sources :

Example 6 with FileExportRule

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);
        }
    }
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 7 with FileExportRule

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;
    }
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) URI(java.net.URI)

Example 8 with FileExportRule

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;
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 9 with FileExportRule

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;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 10 with FileExportRule

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;
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ArrayList(java.util.ArrayList) FileExport(com.emc.storageos.db.client.model.FileExport) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Aggregations

FileExportRule (com.emc.storageos.db.client.model.FileExportRule)37 URI (java.net.URI)13 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)11 URISyntaxException (java.net.URISyntaxException)11 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)10 FileShare (com.emc.storageos.db.client.model.FileShare)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10 ExportRule (com.emc.storageos.model.file.ExportRule)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 ArrayList (java.util.ArrayList)8 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 Snapshot (com.emc.storageos.db.client.model.Snapshot)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)5 FileExport (com.emc.storageos.db.client.model.FileExport)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 WorkflowException (com.emc.storageos.workflow.WorkflowException)5 StringSet (com.emc.storageos.db.client.model.StringSet)4