Search in sources :

Example 1 with UnManagedFileExportRule

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule in project coprhd-controller by CoprHD.

the class UnManagedFilesystemService method createRule.

private void createRule(UnManagedFileExportRule orig, List<FileExportRule> fsExportRules) {
    FileExportRule dest = new FileExportRule();
    dest.setId(URIUtil.createId(FileExportRule.class));
    dest.setFileSystemId(orig.getFileSystemId());
    dest.setExportPath(orig.getExportPath());
    dest.setSecFlavor(orig.getSecFlavor());
    dest.setAnon(orig.getAnon());
    dest.setMountPoint(orig.getMountPoint());
    dest.setDeviceExportId(orig.getDeviceExportId());
    if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
        dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
    }
    if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
        dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
    }
    if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
        dest.setRootHosts(new StringSet(orig.getRootHosts()));
    }
    _logger.info("Ingesting Export Rule : {}", dest);
    fsExportRules.add(dest);
}
Also used : UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 2 with UnManagedFileExportRule

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method getUnManagedFSExportMap.

/**
 * Generate Export Map for UnManagedFileSystem
 * Ignore exports with multiple exports for the same path
 * Ignore exports that have multiple security flavors
 * Ignore exports with multiple paths
 * Ignore exports not found on the array
 * Ignore exports which have the same internal export key ( <sec, perm, root-mapping>)
 *
 * @param umfs
 * @param isilonExportIds
 * @param storagePort
 * @param fsPath
 * @param isilonApi
 * @return boolean
 */
private boolean getUnManagedFSExportMap(UnManagedFileSystem umfs, HashSet<Integer> isilonExportIds, StoragePort storagePort, String fsPath, String zoneName, IsilonApi isilonApi, List<UnManagedFileExportRule> expRules) {
    UnManagedFSExportMap exportMap = new UnManagedFSExportMap();
    int generatedExportCount = 0;
    ArrayList<IsilonExport> isilonExports = new ArrayList<>();
    if (isilonExportIds != null && isilonExportIds.size() > 1) {
        _log.info("Found multiple export rules for file system path {}, {} ", fsPath, isilonExportIds.size());
    }
    for (Integer expId : isilonExportIds) {
        IsilonExport exp = getIsilonExport(isilonApi, expId, zoneName);
        if (exp == null) {
            _log.info("Ignoring export {} as it is not found", expId);
            continue;
        }
        for (String expPath : exp.getPaths()) {
            if (expPath != null && !expPath.equalsIgnoreCase(fsPath) && !expPath.startsWith(fsPath + "/")) {
                _log.info("Ignoring export {} as it's path doesn't match with file path {} ", expId, fsPath);
                continue;
            }
        }
        isilonExports.add(exp);
    }
    StringSet secTypes = new StringSet();
    for (IsilonExport exp : isilonExports) {
        String csSecurityTypes = "";
        Set<String> orderedList = new TreeSet<>();
        // store all security flavor separated by comma(,)
        for (String sec : exp.getSecurityFlavors()) {
            String securityFlavor = sec;
            // Isilon Maps sys to unix and we do this conversion during export from ViPR
            if (sec.equalsIgnoreCase(UNIXSECURITY)) {
                securityFlavor = SYSSECURITY;
            }
            orderedList.add(securityFlavor);
        }
        Iterator<String> secIter = orderedList.iterator();
        csSecurityTypes = secIter.next().toString();
        while (secIter.hasNext()) {
            csSecurityTypes += "," + secIter.next().toString();
        }
        if (!csSecurityTypes.isEmpty() && secTypes.contains(csSecurityTypes)) {
            _log.warn("Ignoring file system exports {}, as it contains multiple export rules with same security {}", fsPath, csSecurityTypes);
            return false;
        }
        secTypes.add(csSecurityTypes);
        String path = exp.getPaths().get(0);
        // Get User
        String rootUserMapping = "";
        String mapAllUserMapping = "";
        if (exp.getMap_root() != null && exp.getMap_root().getUser() != null) {
            rootUserMapping = exp.getMap_root().getUser();
        } else if (exp.getMap_all() != null && exp.getMap_all().getUser() != null) {
            mapAllUserMapping = exp.getMap_all().getUser();
        }
        String resolvedUser = (rootUserMapping != null && (!rootUserMapping.isEmpty())) ? rootUserMapping : mapAllUserMapping;
        // Create Export rule!!
        UnManagedFileExportRule expRule = new UnManagedFileExportRule();
        expRule.setExportPath(path);
        expRule.setSecFlavor(csSecurityTypes);
        expRule.setAnon(resolvedUser);
        expRule.setDeviceExportId(exp.getId().toString());
        expRule.setFileSystemId(umfs.getId());
        expRule.setMountPoint(storagePort.getPortNetworkId() + ":" + path);
        if (exp != null && exp.getReadOnlyClients() != null && !exp.getReadOnlyClients().isEmpty()) {
            UnManagedFSExport unManagedROFSExport = new UnManagedFSExport(exp.getReadOnlyClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, RO, resolvedUser, NFS, storagePort.getPortName(), path, exp.getPaths().get(0));
            unManagedROFSExport.setIsilonId(exp.getId().toString());
            exportMap.put(unManagedROFSExport.getFileExportKey(), unManagedROFSExport);
            generatedExportCount++;
            expRule.setReadOnlyHosts(new StringSet(exp.getReadOnlyClients()));
        }
        if (exp != null && exp.getReadWriteClients() != null && !exp.getReadWriteClients().isEmpty()) {
            UnManagedFSExport unManagedRWFSExport = new UnManagedFSExport(exp.getReadWriteClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, RW, resolvedUser, NFS, storagePort.getPortName(), path, exp.getPaths().get(0));
            unManagedRWFSExport.setIsilonId(exp.getId().toString());
            exportMap.put(unManagedRWFSExport.getFileExportKey(), unManagedRWFSExport);
            generatedExportCount++;
            expRule.setReadWriteHosts(new StringSet(exp.getReadWriteClients()));
        }
        if (exp != null && exp.getRootClients() != null && !exp.getRootClients().isEmpty()) {
            UnManagedFSExport unManagedROOTFSExport = new UnManagedFSExport(exp.getRootClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, ROOT, resolvedUser, NFS, storagePort.getPortName(), path, path);
            unManagedROOTFSExport.setIsilonId(exp.getId().toString());
            exportMap.put(unManagedROOTFSExport.getFileExportKey(), unManagedROOTFSExport);
            generatedExportCount++;
            expRule.setRootHosts(new StringSet(exp.getRootClients()));
        }
        if (exp.getReadOnlyClients() != null && exp.getReadWriteClients() != null && exp.getRootClients() != null) {
            // Check Clients size
            if (exp.getReadOnlyClients().isEmpty() && exp.getReadWriteClients().isEmpty() && exp.getRootClients().isEmpty()) {
                if (exp.getReadOnly()) {
                    // This is a read only export for all hosts
                    UnManagedFSExport unManagedROFSExport = new UnManagedFSExport(exp.getClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, RO, rootUserMapping, NFS, storagePort.getPortName(), path, path);
                    unManagedROFSExport.setIsilonId(exp.getId().toString());
                    exportMap.put(unManagedROFSExport.getFileExportKey(), unManagedROFSExport);
                    generatedExportCount++;
                    // This is a read only export for all hosts
                    expRule.setReadOnlyHosts(new StringSet(exp.getClients()));
                } else {
                    // Not read Only case
                    if (exp.getMap_all() != null && exp.getMap_all().getUser() != null && exp.getMap_all().getUser().equalsIgnoreCase(ROOT)) {
                        // All hosts with root permission
                        UnManagedFSExport unManagedROOTFSExport = new UnManagedFSExport(exp.getClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, ROOT, mapAllUserMapping, NFS, storagePort.getPortName(), path, path);
                        unManagedROOTFSExport.setIsilonId(exp.getId().toString());
                        exportMap.put(unManagedROOTFSExport.getFileExportKey(), unManagedROOTFSExport);
                        generatedExportCount++;
                        // All hosts with root permission
                        expRule.setRootHosts(new StringSet(exp.getClients()));
                    } else if (exp.getMap_all() != null) {
                        // All hosts with RW permission
                        UnManagedFSExport unManagedRWFSExport = new UnManagedFSExport(exp.getClients(), storagePort.getPortName(), storagePort.getPortName() + ":" + path, csSecurityTypes, RW, rootUserMapping, NFS, storagePort.getPortName(), path, path);
                        unManagedRWFSExport.setIsilonId(exp.getId().toString());
                        exportMap.put(unManagedRWFSExport.getFileExportKey(), unManagedRWFSExport);
                        generatedExportCount++;
                        // All hosts with RW permission
                        expRule.setReadWriteHosts(new StringSet(exp.getClients()));
                    }
                }
            }
        }
        // Create Export rule for the export!!!
        expRules.add(expRule);
    }
    if (exportMap.values().size() < generatedExportCount) {
        // The keys are not unique and so all the exports are not valid
        _log.info("Ignoring Exports because they have multiple exports with the same internal export key <sec, perm, root-mapping>. Expected {} got {}", generatedExportCount, exportMap.values().size());
        return false;
    }
    // Return valid
    UnManagedFSExportMap allExportMap = umfs.getFsUnManagedExportMap();
    if (allExportMap == null) {
        allExportMap = new UnManagedFSExportMap();
    }
    allExportMap.putAll(exportMap);
    umfs.setFsUnManagedExportMap(allExportMap);
    return true;
}
Also used : IsilonExport(com.emc.storageos.isilon.restapi.IsilonExport) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport) TreeSet(java.util.TreeSet) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)

Example 3 with UnManagedFileExportRule

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method getUnManagedFSExportRules.

/**
 * Generate Export Map for UnManagedFileSystem
 * Ignore exports with multiple exports for the same path
 * Ignore exports that have multiple security flavors
 * Ignore exports with multiple paths
 * Ignore exports not found on the array
 * Ignore exports which have the same internal export key ( <sec, perm, root-mapping>)
 *
 * @param umfs
 * @param expIdMap
 * @param storagePort
 * @param fsPath
 * @param isilonApi
 * @return boolean
 */
private List<UnManagedFileExportRule> getUnManagedFSExportRules(UnManagedFileSystem umfs, HashMap<String, HashSet<Integer>> expIdMap, StoragePort storagePort, String fsPath, String zoneName, IsilonApi isilonApi) {
    List<UnManagedFileExportRule> exportRules = new ArrayList<UnManagedFileExportRule>();
    UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
    List<UnManagedFileExportRule> exportRulesTemp = null;
    boolean isAllRulesValid = true;
    for (String expMapPath : expIdMap.keySet()) {
        HashSet<Integer> isilonExportIds = new HashSet<>();
        _log.info("getUnManagedFSExportMap {} : export ids : {}", expMapPath, expIdMap.get(expMapPath));
        isilonExportIds = expIdMap.get(expMapPath);
        if (isilonExportIds != null && !isilonExportIds.isEmpty()) {
            exportRulesTemp = getUnManagedFSExportRules(umfs, storagePort, isilonExportIds, expMapPath, zoneName, isilonApi);
            // validate export rules for each path
            if (null != exportRulesTemp && !exportRulesTemp.isEmpty()) {
                isAllRulesValid = validationUtility.validateUnManagedExportRules(exportRulesTemp, false);
                if (isAllRulesValid) {
                    _log.info("Validating rules success for export {}", expMapPath);
                    exportRules.addAll(exportRulesTemp);
                } else {
                    _log.info("Ignroing the rules for export {}", expMapPath);
                    isAllRulesValid = false;
                }
            }
        }
    }
    if (exportRules.isEmpty() || false == isAllRulesValid) {
        umfs.setHasExports(false);
        _log.info("FileSystem " + fsPath + " does not have valid ViPR exports ");
        exportRules.clear();
    }
    return exportRules;
}
Also used : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 4 with UnManagedFileExportRule

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method discoverUnManagedNewExports.

private void discoverUnManagedNewExports(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
    storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
    String detailedStatusMessage = "Discovery of Data Domain Unmanaged Exports started";
    storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
    // Used to cache UMFS once retrieved from DB
    Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
    // Used to Save the rules to DB
    List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<UnManagedFileExportRule>();
    try {
        // Get exports on the array and loop through each export.
        DDExportList exportList = ddClient.getExports(storageSystem.getNativeGuid());
        // Verification Utility
        UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
        for (DDExportInfo exp : exportList.getExports()) {
            DDExportInfoDetail export = ddClient.getExport(storageSystem.getNativeGuid(), exp.getId());
            if (export.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
                continue;
            }
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), export.getMtreeID());
            // Get UMFS from cache if possible, otherwise try to retrieve from DB
            UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
            if (unManagedFS == null) {
                unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
            }
            // Used for rules validation
            List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
            if (unManagedFS != null) {
                // Add UMFS to cache
                existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
                // Build ViPR export rules from the export retrieved from the array
                List<UnManagedFileExportRule> exportRules = applyAllSecurityRules(export, unManagedFS.getId());
                _log.info("Number of exports discovered for file system {} is {}", unManagedFS.getId(), exportRules.size());
                for (UnManagedFileExportRule dbExportRule : exportRules) {
                    _log.info("Un Managed File Export Rule : {}", dbExportRule);
                    String fsExportRulenativeId = dbExportRule.getFsExportIndex();
                    _log.info("Native Id using to build Native Guid {}", fsExportRulenativeId);
                    String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, fsExportRulenativeId);
                    _log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
                    dbExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
                    dbExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
                    // Build all export rules list.
                    unManagedExportRules.add(dbExportRule);
                }
                // apply as per API SVC Validations.
                if (!unManagedExportRules.isEmpty()) {
                    boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
                    if (isAllRulesValid) {
                        _log.info("Validating rules success for export {}", export.getPath());
                        for (UnManagedFileExportRule exportRule : unManagedExportRules) {
                            UnManagedFileExportRule existingRule = checkUnManagedFsExportRuleExistsInDB(_dbClient, exportRule.getNativeGuid());
                            if (existingRule == null) {
                                newUnManagedExportRules.add(exportRule);
                            } else {
                                // Remove the existing rule.
                                existingRule.setInactive(true);
                                _dbClient.persistObject(existingRule);
                                newUnManagedExportRules.add(exportRule);
                            }
                        }
                        unManagedFS.setHasExports(true);
                        unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                        _dbClient.persistObject(unManagedFS);
                        _log.info("File System {} has Exports and their size is {}", unManagedFS.getId(), newUnManagedExportRules.size());
                    } else {
                        _log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", export.getPath());
                        // Don't consider the file system with invalid exports!!!
                        unManagedFS.setInactive(true);
                    }
                }
                // Adding this additional logic to avoid OOM
                if (newUnManagedExportRules.size() == MAX_UMFS_RECORD_SIZE) {
                    _log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
                    _dbClient.persistObject(newUnManagedExportRules);
                    newUnManagedExportRules.clear();
                }
            } else {
                _log.info("FileSystem " + fsUnManagedFsNativeGuid + " is not present in ViPR DB. Hence ignoring " + export + " export");
            }
        }
        if (!newUnManagedExportRules.isEmpty()) {
            // Update UnManagedFilesystem
            _dbClient.persistObject(newUnManagedExportRules);
            _log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
        }
        if (!existingUnManagedFileSystems.isEmpty()) {
            // Update UnManagedFilesystem
            _dbClient.persistObject(existingUnManagedFileSystems.values());
            _log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeded
        detailedStatusMessage = String.format("Discovery completed successfully for Data Domain: %s", storageSystem.getId().toString());
        storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
    } catch (DataDomainApiException dde) {
        _log.error("discoverStorage failed.  Storage system: " + storageSystem.getId());
    } catch (Exception e) {
        _log.error("discoverStorage failed. Storage system: " + storageSystem.getId(), e);
    } finally {
        if (storageSystem != null) {
            try {
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) HashMap(java.util.HashMap) DDExportList(com.emc.storageos.datadomain.restapi.model.DDExportList) ArrayList(java.util.ArrayList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Example 5 with UnManagedFileExportRule

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method applyAllSecurityRules.

/**
 * Build viPR export rules from the export retrieved from the array
 *
 * @param export - detailed info on the export retrieved from the array
 * @param fileSystemId - URI of the unmanaged
 * @return List of UnManagedFileExportRule
 * @throws IOException
 */
// TODO:Account for multiple security rules and security flavors
private List<UnManagedFileExportRule> applyAllSecurityRules(DDExportInfoDetail export, URI fileSystemId) {
    List<UnManagedFileExportRule> expRules = new ArrayList<UnManagedFileExportRule>();
    // hosts --> Map<permission, set of hosts>
    // ruleMap --> Map<security flavor, hosts>
    Map<String, Map<String, StringSet>> ruleMap = new HashMap<>();
    Map<String, DDOptionInfo> ddClients = new HashMap<>();
    for (DDExportClient ddExpClient : export.getClients()) {
        String clientName = ddExpClient.getName();
        String clientOptions = ddExpClient.getOptions();
        DDOptionInfo optionInfo = DDOptionInfo.parseOptions(clientOptions);
        ddClients.put(clientName, optionInfo);
        if (ruleMap.get(optionInfo.security) == null) {
            ruleMap.put(optionInfo.security, new HashMap<String, StringSet>());
        }
        if (optionInfo.permission.equals(DataDomainApiConstants.PERMISSION_RO)) {
            if (ruleMap.get(optionInfo.security).get(DataDomainApiConstants.PERMISSION_RO) == null) {
                ruleMap.get(optionInfo.security).put(DataDomainApiConstants.PERMISSION_RO, new StringSet());
            }
            ruleMap.get(optionInfo.security).get(DataDomainApiConstants.PERMISSION_RO).add(clientName);
        }
        if (optionInfo.permission.equals(DataDomainApiConstants.PERMISSION_RW)) {
            if (ruleMap.get(optionInfo.security).get(DataDomainApiConstants.PERMISSION_RW) == null) {
                ruleMap.get(optionInfo.security).put(DataDomainApiConstants.PERMISSION_RW, new StringSet());
            }
            ruleMap.get(optionInfo.security).get(DataDomainApiConstants.PERMISSION_RW).add(clientName);
        }
    }
    // Now build the rules.
    Set<String> securityTypes = ruleMap.keySet();
    for (String secType : securityTypes) {
        UnManagedFileExportRule expRule = new UnManagedFileExportRule();
        expRule.setDeviceExportId(export.getId());
        expRule.setFileSystemId(fileSystemId);
        expRule.setExportPath(export.getPath());
        expRule.setMountPoint(export.getPath());
        expRule.setSecFlavor(secType);
        expRule.setAnon(DataDomainApiConstants.ROOT);
        // Read only hosts
        if (ruleMap.get(secType).get(DataDomainApiConstants.PERMISSION_RO) != null) {
            StringSet roHosts = ruleMap.get(secType).get(DataDomainApiConstants.PERMISSION_RO);
            for (String client : roHosts) {
                if (ddClients.get(client).rootMapping.equals(DataDomainApiConstants.ROOT_SQUASH)) {
                    expRule.setAnon(DataDomainApiConstants.ROOT_SQUASH);
                }
            }
            expRule.setReadOnlyHosts(roHosts);
        }
        // Read write hosts
        if (ruleMap.get(secType).get(DataDomainApiConstants.PERMISSION_RW) != null) {
            StringSet rwHosts = ruleMap.get(secType).get(DataDomainApiConstants.PERMISSION_RW);
            for (String client : rwHosts) {
                if (ddClients.get(client).rootMapping.equals(DataDomainApiConstants.ROOT_SQUASH)) {
                    expRule.setAnon(DataDomainApiConstants.ROOT_SQUASH);
                }
            }
            expRule.setReadWriteHosts(rwHosts);
        }
        expRules.add(expRule);
    }
    return expRules;
}
Also used : UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDOptionInfo(com.emc.storageos.datadomain.restapi.DDOptionInfo) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Aggregations

UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)25 ArrayList (java.util.ArrayList)19 StringSet (com.emc.storageos.db.client.model.StringSet)10 IOException (java.io.IOException)9 URI (java.net.URI)9 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)8 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 HashMap (java.util.HashMap)7 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 UnManagedExportVerificationUtility (com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 StringMap (com.emc.storageos.db.client.model.StringMap)5 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)5 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)5 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)4 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3