Search in sources :

Example 1 with SnapshotExportUpdateParams

use of com.emc.storageos.model.file.SnapshotExportUpdateParams in project coprhd-controller by CoprHD.

the class FileStorageUtils method updateFileSnapshotExport.

public static String updateFileSnapshotExport(URI fileSnapshotId, String subDirectory, FileExportRule[] fileExportRules) {
    List<ExportRule> exportRuleList = getFileSnapshotExportRules(fileSnapshotId, false, subDirectory);
    Set<String> existingRuleSet = Sets.newHashSet();
    for (ExportRule rule : exportRuleList) {
        existingRuleSet.add(rule.getSecFlavor());
    }
    List<ExportRule> exportRuleListToAdd = Lists.newArrayList();
    List<ExportRule> exportRuleListToModify = Lists.newArrayList();
    for (FileExportRule rule : fileExportRules) {
        ExportRule exportRule = new ExportRule();
        exportRule.setFsID(fileSnapshotId);
        exportRule.setSecFlavor(rule.security);
        String rootUserMapping = rule.rootUserMapping;
        String domain = rule.domain;
        if (StringUtils.isNotBlank(domain)) {
            rootUserMapping = domain.trim() + "\\" + rootUserMapping.trim();
        }
        exportRule.setAnon(rootUserMapping);
        Set<String> exportHosts = new HashSet<String>(rule.exportHosts);
        switch(rule.getPermission()) {
            case "ro":
                exportRule.setReadOnlyHosts(exportHosts);
                break;
            case "rw":
                exportRule.setReadWriteHosts(exportHosts);
                break;
            case "root":
                exportRule.setRootHosts(exportHosts);
                break;
            default:
                break;
        }
        if (existingRuleSet.contains(exportRule.getSecFlavor())) {
            exportRuleListToModify.add(exportRule);
        } else {
            exportRuleListToAdd.add(exportRule);
        }
    }
    SnapshotExportUpdateParams params = new SnapshotExportUpdateParams();
    if (!exportRuleListToAdd.isEmpty()) {
        ExportRules exportRulesToAdd = new ExportRules();
        exportRulesToAdd.setExportRules(exportRuleListToAdd);
        params.setExportRulesToAdd(exportRulesToAdd);
    }
    if (!exportRuleListToModify.isEmpty()) {
        ExportRules exportRulesToModify = new ExportRules();
        exportRulesToModify.setExportRules(exportRuleListToModify);
        params.setExportRulesToModify(exportRulesToModify);
    }
    Task<FileSnapshotRestRep> task = execute(new UpdateFileSnapshotExport(fileSnapshotId, subDirectory, params));
    addAffectedResource(task);
    String exportId = task.getResourceId().toString();
    logInfo("file.storage.export.task", exportId, task.getOpId());
    return exportId;
}
Also used : SnapshotExportUpdateParams(com.emc.storageos.model.file.SnapshotExportUpdateParams) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) FindFileSnapshotExportRules(com.emc.sa.service.vipr.file.tasks.FindFileSnapshotExportRules) FindFileSystemExportRules(com.emc.sa.service.vipr.file.tasks.FindFileSystemExportRules) ExportRules(com.emc.storageos.model.file.ExportRules) DeactivateFileSystemExportRule(com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule) DeactivateFileSnapshotExportRule(com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) HashSet(java.util.HashSet) UpdateFileSnapshotExport(com.emc.sa.service.vipr.file.tasks.UpdateFileSnapshotExport)

Example 2 with SnapshotExportUpdateParams

use of com.emc.storageos.model.file.SnapshotExportUpdateParams in project coprhd-controller by CoprHD.

the class FileSnapshots method save.

@FlashException(referrer = { "snapshot" })
public static void save(Boolean edit, String id, String fsPath, String exportPath, String security, String anon, @As(",") List<String> ro, @As(",") List<String> rw, @As(",") List<String> root) {
    ExportRule rule = new ExportRule();
    rule.setAnon(anon);
    rule.setSecFlavor(security);
    // Clean up endpoints list by removing all empty items if any
    List<String> empty = Arrays.asList("");
    rw.removeAll(empty);
    ro.removeAll(empty);
    root.removeAll(empty);
    if (!ro.isEmpty()) {
        rule.setReadOnlyHosts(FileUtils.buildEndpointList(ro));
    }
    if (!rw.isEmpty()) {
        rule.setReadWriteHosts(FileUtils.buildEndpointList(rw));
    }
    if (!root.isEmpty()) {
        rule.setRootHosts(FileUtils.buildEndpointList(root));
    }
    List<ExportRule> addRules = Lists.newArrayList();
    addRules.add(rule);
    ExportRules exportRules = new ExportRules();
    exportRules.setExportRules(addRules);
    SnapshotExportUpdateParams params = new SnapshotExportUpdateParams();
    if (!edit) {
        params.setExportRulesToAdd(exportRules);
    } else {
        params.setExportRulesToModify(exportRules);
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    client.fileSnapshots().updateExport(uri(id), null, params);
    flash.put("info", MessagesUtils.get("resources.filesystem.export.update"));
    snapshot(id);
}
Also used : SnapshotExportUpdateParams(com.emc.storageos.model.file.SnapshotExportUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FlashException(controllers.util.FlashException)

Example 3 with SnapshotExportUpdateParams

use of com.emc.storageos.model.file.SnapshotExportUpdateParams in project coprhd-controller by CoprHD.

the class FileSnapshots method deleteSnapshotExport.

@FlashException(referrer = { "snapshot" })
public static void deleteSnapshotExport(String snapshotId, String security, String exportPath) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    ExportRule rule = new ExportRule();
    rule.setSecFlavor(security);
    List<ExportRule> list = Lists.newArrayList();
    list.add(rule);
    ExportRules exportRules = new ExportRules();
    exportRules.setExportRules(list);
    SnapshotExportUpdateParams params = new SnapshotExportUpdateParams();
    params.setExportRulesToDelete(exportRules);
    FileSnapshotRestRep snapshot = client.fileSnapshots().get(uri(snapshotId));
    String subDir = FileUtils.findSubDirectory(snapshot.getMountPath(), exportPath);
    client.fileSnapshots().updateExport(uri(snapshotId), subDir, params);
    flash.put("info", MessagesUtils.get("resources.filesnapshot.export.deactivate"));
    snapshot(snapshotId);
}
Also used : SnapshotExportUpdateParams(com.emc.storageos.model.file.SnapshotExportUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FlashException(controllers.util.FlashException)

Aggregations

ExportRule (com.emc.storageos.model.file.ExportRule)3 ExportRules (com.emc.storageos.model.file.ExportRules)3 SnapshotExportUpdateParams (com.emc.storageos.model.file.SnapshotExportUpdateParams)3 FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 FlashException (controllers.util.FlashException)2 DeactivateFileSnapshotExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule)1 DeactivateFileSystemExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule)1 FindFileSnapshotExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSnapshotExportRules)1 FindFileSystemExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSystemExportRules)1 UpdateFileSnapshotExport (com.emc.sa.service.vipr.file.tasks.UpdateFileSnapshotExport)1 HashSet (java.util.HashSet)1