Search in sources :

Example 6 with ExportRules

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

use of com.emc.storageos.model.file.ExportRules 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)

Example 8 with ExportRules

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

the class FileSystems method save.

@FlashException(referrer = { "fileSystem" })
public static void save(Boolean edit, String id, String fsPath, String exportPath, String security, String anon, String subDir, @As(",") List<String> ro, @As(",") List<String> rw, @As(",") List<String> root, Boolean bypassDnsCheck) {
    ExportRule rule = new ExportRule();
    rule.setFsID(uri(id));
    rule.setMountPoint(fsPath);
    rule.setExportPath(exportPath);
    rule.setAnon(anon);
    rule.setSecFlavor(security);
    // Clean up endpoints list by removing all empty items
    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);
    FileShareExportUpdateParams params = new FileShareExportUpdateParams();
    params.setBypassDnsCheck(bypassDnsCheck);
    if (!edit) {
        params.setExportRulesToAdd(exportRules);
    } else {
        params.setExportRulesToModify(exportRules);
        subDir = FileUtils.findSubDirectory(fsPath, exportPath);
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    client.fileSystems().updateExport(uri(id), subDir, params);
    flash.put("info", MessagesUtils.get("resources.filesystem.export.update"));
    fileSystem(id);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRules(com.emc.storageos.model.file.ExportRules) FileShareExportUpdateParams(com.emc.storageos.model.file.FileShareExportUpdateParams) ExportRule(com.emc.storageos.model.file.ExportRule) FlashException(controllers.util.FlashException)

Example 9 with ExportRules

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

the class FileSystems method getExport.

/**
 * Gets the list of export rules for the given file system by ID.
 * <p>
 * API Call: <tt>GET /file/filesystems/{id}/export</tt>
 *
 * @param id
 *            the ID of the file system.
 * @param allDirs
 *            boolean value for indicating for all directories
 * @param subDir
 *            string indicating on what subdirectory to query
 * @return the list of export rules for the file system.
 */
public List<ExportRule> getExport(URI id, boolean allDirs, String subDir) {
    UriBuilder builder = client.uriBuilder(getExportUrl());
    if (allDirs) {
        builder.queryParam(ALLDIR_PARAM, allDirs);
    } else if (subDir != null) {
        builder.queryParam(SUBDIR_PARAM, subDir);
    }
    URI targetUri = builder.build(id);
    ExportRules response = client.getURI(ExportRules.class, targetUri);
    return defaultList(response.getExportRules());
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI)

Example 10 with ExportRules

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

the class FileSnapshots method getExport.

/**
 * Gets the list of export rules for the given file system by ID.
 * <p>
 * API Call: <tt>GET /file/snapshots/{id}/exports</tt>
 *
 * @param id
 *            the ID of the snapshot.
 * @param allDirs
 *            boolean value for indicating for all directories
 * @param subDir
 *            string indicating on what subdirectory to query
 * @return the list of export rules for the file system.
 */
public List<ExportRule> getExport(URI id, boolean allDirs, String subDir) {
    UriBuilder builder = client.uriBuilder(getExportUrl());
    if (allDirs) {
        builder.queryParam(ALLDIR_PARAM, allDirs);
    } else if (subDir != null) {
        builder.queryParam(SUBDIR_PARAM, subDir);
    }
    URI targetUri = builder.build(id);
    ExportRules response = client.getURI(ExportRules.class, targetUri);
    return defaultList(response.getExportRules());
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI)

Aggregations

ExportRules (com.emc.storageos.model.file.ExportRules)16 ExportRule (com.emc.storageos.model.file.ExportRule)13 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)4 FlashException (controllers.util.FlashException)4 ExportOperationErrorType (com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType)3 FileShareExportUpdateParams (com.emc.storageos.model.file.FileShareExportUpdateParams)3 SnapshotExportUpdateParams (com.emc.storageos.model.file.SnapshotExportUpdateParams)3 HashSet (java.util.HashSet)3 DeactivateFileSnapshotExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule)2 DeactivateFileSystemExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule)2 FindFileSnapshotExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSnapshotExportRules)2 FindFileSystemExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSystemExportRules)2 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2 FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2