Search in sources :

Example 6 with FileSnapshotRestRep

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

the class FileStorageUtils method restoreFileSnapshot.

public static void restoreFileSnapshot(URI snapshotId) {
    Task<FileSnapshotRestRep> task = execute(new RestoreFileSnapshot(snapshotId));
    addAffectedResource(task);
}
Also used : FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) RestoreFileSnapshot(com.emc.sa.service.vipr.file.tasks.RestoreFileSnapshot)

Example 7 with FileSnapshotRestRep

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

the class FileStorageUtils method shareFileSnapshot.

public static URI shareFileSnapshot(URI snapshotId, String shareName, String shareComment) {
    Task<FileSnapshotRestRep> task = execute(new CreateFileSnapshotShare(snapshotId, shareName, shareComment));
    addAffectedResource(task);
    return task.getResourceId();
}
Also used : FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) CreateFileSnapshotShare(com.emc.sa.service.vipr.file.tasks.CreateFileSnapshotShare)

Example 8 with FileSnapshotRestRep

use of com.emc.storageos.model.file.FileSnapshotRestRep 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 9 with FileSnapshotRestRep

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

the class FileSnapshotsDataTable method fetch.

public static List<FileSnapshot> fetch(URI projectId) {
    if (projectId == null) {
        return Collections.EMPTY_LIST;
    }
    ViPRCoreClient client = getViprClient();
    List<FileSnapshotRestRep> fileSnapshots = client.fileSnapshots().findByProject(projectId);
    List<FileSnapshot> results = Lists.newArrayList();
    for (FileSnapshotRestRep fileSnapshot : fileSnapshots) {
        results.add(new FileSnapshot(fileSnapshot));
    }
    return results;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep)

Example 10 with FileSnapshotRestRep

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

the class FileSnapshots method deleteSnapshotShare.

@FlashException(referrer = { "snapshot" })
public static void deleteSnapshotShare(String snapshotId, String shareName) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    Task<FileSnapshotRestRep> task = client.fileSnapshots().removeShare(uri(snapshotId), shareName);
    flash.put("info", MessagesUtils.get("resources.filesnapshot.share.deactivate"));
    snapshot(snapshotId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) FlashException(controllers.util.FlashException)

Aggregations

FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)21 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 DeactivateFileSnapshotExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule)3 Task (com.emc.vipr.client.Task)3 FlashException (controllers.util.FlashException)3 CreateFileSnapshot (com.emc.sa.service.vipr.file.tasks.CreateFileSnapshot)2 ExportRule (com.emc.storageos.model.file.ExportRule)2 ExportRules (com.emc.storageos.model.file.ExportRules)2 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2 SnapshotExportUpdateParams (com.emc.storageos.model.file.SnapshotExportUpdateParams)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 CreateFileSnapshotExport (com.emc.sa.service.vipr.file.tasks.CreateFileSnapshotExport)1 CreateFileSnapshotShare (com.emc.sa.service.vipr.file.tasks.CreateFileSnapshotShare)1 DeactivateFileSnapshot (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshot)1 DeactivateFileSnapshotExport (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExport)1 DeactivateFileSnapshotShare (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotShare)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