Search in sources :

Example 21 with ExportRule

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

the class FileUtils method getFSExportRulesInfo.

public static ExportRuleInfo getFSExportRulesInfo(URI id, String exportPath, String security) {
    String path = StringUtils.defaultString(exportPath);
    String sec = StringUtils.defaultString(security);
    List<ExportRule> rules = getFSExportRules(id);
    List<EndpointInfo> infos = Lists.newArrayList();
    ExportRuleInfo exportRuleInfo = new ExportRuleInfo();
    for (ExportRule rule : rules) {
        if ((path.isEmpty() || rule.getExportPath().equals(path)) && (sec.isEmpty() || rule.getSecFlavor().equals(sec))) {
            if (rule.getReadWriteHosts() != null && !rule.getReadWriteHosts().isEmpty()) {
                for (String endpoint : rule.getReadWriteHosts()) {
                    infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.rw.name()));
                }
            }
            if (rule.getReadOnlyHosts() != null && !rule.getReadOnlyHosts().isEmpty()) {
                for (String endpoint : rule.getReadOnlyHosts()) {
                    infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.ro.name()));
                }
            }
            if (rule.getRootHosts() != null && !rule.getRootHosts().isEmpty()) {
                for (String endpoint : rule.getRootHosts()) {
                    infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.root.name()));
                }
            }
            exportRuleInfo.setAnon(rule.getAnon());
            exportRuleInfo.setSecurity(getSecurityFlavorList(rule.getSecFlavor()));
            exportRuleInfo.setEndpointsInfo(infos);
        }
    }
    return exportRuleInfo;
}
Also used : ExportRule(com.emc.storageos.model.file.ExportRule)

Example 22 with ExportRule

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

the class FileUtils method getFSExportRules.

public static List<ExportRule> getFSExportRules(URI id) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<ExportRule> rules = Lists.newArrayList();
    if (URIUtil.isType(id, Snapshot.class)) {
        rules = client.fileSnapshots().getExport(id, true, "");
    } else if (URIUtil.isType(id, FileShare.class)) {
        rules = client.fileSystems().getExport(id, true, "");
    }
    return rules;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRule(com.emc.storageos.model.file.ExportRule) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 23 with ExportRule

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

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

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

Aggregations

ExportRule (com.emc.storageos.model.file.ExportRule)67 ArrayList (java.util.ArrayList)27 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 FileShare (com.emc.storageos.db.client.model.FileShare)16 ExportRules (com.emc.storageos.model.file.ExportRules)13 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 HashSet (java.util.HashSet)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 HashMap (java.util.HashMap)10 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)8 Snapshot (com.emc.storageos.db.client.model.Snapshot)7 FileExport (com.emc.storageos.db.client.model.FileExport)6 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 URI (java.net.URI)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 VNXeException (com.emc.storageos.vnxe.VNXeException)4 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)4