Search in sources :

Example 56 with ExportRule

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

the class FileOrchestrationUtils method convertFileExportRuleToExportRule.

/**
 * @param fileExportRule
 * @return ExportRule
 */
public static ExportRule convertFileExportRuleToExportRule(FileExportRule fileExportRule) {
    ExportRule exportRule = new ExportRule();
    exportRule.setAnon(fileExportRule.getAnon());
    exportRule.setExportPath(fileExportRule.getExportPath());
    exportRule.setFsID(fileExportRule.getFileSystemId());
    exportRule.setMountPoint(fileExportRule.getMountPoint());
    exportRule.setReadOnlyHosts(fileExportRule.getReadOnlyHosts());
    exportRule.setReadWriteHosts(fileExportRule.getReadWriteHosts());
    exportRule.setRootHosts(fileExportRule.getRootHosts());
    exportRule.setSecFlavor(fileExportRule.getSecFlavor());
    exportRule.setSnapShotID(fileExportRule.getSnapshotId());
    exportRule.setDeviceExportId(fileExportRule.getDeviceExportId());
    return exportRule;
}
Also used : ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 57 with ExportRule

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

the class FileOrchestrationUtils method checkForExportRuleToModify.

/**
 * This method checks for export rules that has to modified on target file system
 *
 * @param sourceExportRuleMap
 * @param targetExportRuleMap
 * @param exportRulesToModify
 */
public static void checkForExportRuleToModify(HashMap<String, ExportRule> sourceExportRuleMap, HashMap<String, ExportRule> targetExportRuleMap, List<ExportRule> exportRulesToModify) {
    for (String secFlavour : sourceExportRuleMap.keySet()) {
        if (targetExportRuleMap.get(secFlavour) != null) {
            boolean isExportRuleToModify = false;
            ExportRule sourceExportRule = sourceExportRuleMap.get(secFlavour);
            ExportRule targetExportRule = targetExportRuleMap.get(secFlavour);
            // Check for RW Hosts
            if (isEndPointsDifferent(sourceExportRule.getReadWriteHosts(), targetExportRule.getReadWriteHosts())) {
                isExportRuleToModify = true;
                targetExportRule.setReadWriteHosts(sourceExportRule.getReadWriteHosts());
            }
            // Check for RO Hosts
            if (isEndPointsDifferent(sourceExportRule.getReadOnlyHosts(), targetExportRule.getReadOnlyHosts())) {
                isExportRuleToModify = true;
                targetExportRule.setReadOnlyHosts(sourceExportRule.getReadOnlyHosts());
            }
            // Check for Root Hosts
            if (isEndPointsDifferent(sourceExportRule.getRootHosts(), targetExportRule.getRootHosts())) {
                isExportRuleToModify = true;
                targetExportRule.setRootHosts(sourceExportRule.getRootHosts());
            }
            // Check for Anon
            if (sourceExportRule.getAnon() != null && !sourceExportRule.getAnon().equals(targetExportRule.getAnon())) {
                isExportRuleToModify = true;
                targetExportRule.setAnon(sourceExportRule.getAnon());
            }
            if (isExportRuleToModify) {
                exportRulesToModify.add(targetExportRule);
            }
        }
    }
}
Also used : ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 58 with ExportRule

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

the class FileSnapshotService method getSnapshotExportRules.

/**
 * Get Snapshot Export Rules
 *
 * @param id
 *            the URN of a file system
 * @param allDirs
 *            All Dirs within a file system
 * @param subDir
 *            sub-directory within a file system
 * @brief List the export rules for a snapshot
 * @return ExportRules
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/export")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ExportRules getSnapshotExportRules(@PathParam("id") URI id, @QueryParam("allDirs") boolean allDirs, @QueryParam("subDir") String subDir) {
    _log.info("Request recieved to list snapshotExports with Id : {}", new Object[] { id });
    // Validate the FS id.
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    Snapshot snapshot = queryResource(id);
    ExportRules exportRules = new ExportRules();
    List<ExportRule> exportRule = new ArrayList<>();
    // Query All Export Rules Specific to a File System.
    List<FileExportRule> exports = queryDBSnapshotExports(snapshot);
    _log.info("Number of existing snapshot exports found : {} ", exports.size());
    // All EXPORTS
    for (FileExportRule rule : exports) {
        ExportRule expRule = new ExportRule();
        // Copy Props
        copyPropertiesToSave(rule, expRule, snapshot);
        exportRule.add(expRule);
    }
    _log.info("Number of snapshot export rules returning {}", exportRule.size());
    exportRules.setExportRules(exportRule);
    return exportRules;
}
Also used : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) ExportRules(com.emc.storageos.model.file.ExportRules) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 59 with ExportRule

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

the class FileStorageUtils method updateFileSystemExport.

public static String updateFileSystemExport(URI fileSystemId, String subDirectory, FileExportRule[] fileExportRules, boolean bypassDnsCheck) {
    List<ExportRule> exportRuleList = getFileSystemExportRules(fileSystemId, 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(fileSystemId);
        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);
        }
    }
    FileShareExportUpdateParams params = new FileShareExportUpdateParams();
    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);
    }
    params.setBypassDnsCheck(bypassDnsCheck);
    Task<FileShareRestRep> task = execute(new UpdateFileSystemExport(fileSystemId, subDirectory, params));
    addAffectedResource(task);
    String exportId = task.getResourceId().toString();
    logInfo("file.storage.export.task", exportId, task.getOpId());
    return exportId;
}
Also used : UpdateFileSystemExport(com.emc.sa.service.vipr.file.tasks.UpdateFileSystemExport) 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) FileShareExportUpdateParams(com.emc.storageos.model.file.FileShareExportUpdateParams) 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) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) HashSet(java.util.HashSet)

Example 60 with ExportRule

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

the class FileSnapshots method snapshotExports.

public static void snapshotExports(String snapshotId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<ExportRule> exports = client.fileSnapshots().getExport(uri(snapshotId), true, "");
    renderArgs.put("permissionTypeOptions", Lists.newArrayList(FileShareExport.Permissions.values()));
    render(exports);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRule(com.emc.storageos.model.file.ExportRule)

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