Search in sources :

Example 6 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 7 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 8 with UnManagedFileExportRule

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

the class NetAppClusterModeCommIntf method applyAllSecurityRules.

/**
 * check Pre Existing Storage File Export Rules exists in DB
 *
 * @param nativeGuid
 * @return unManageFileExport Rule
 * @throws IOException
 */
// TODO:Account for multiple security rules and security flavors
private List<UnManagedFileExportRule> applyAllSecurityRules(ExportsRuleInfo export, String storagePortAddress, URI fileSystemId) {
    List<UnManagedFileExportRule> expRules = new ArrayList<UnManagedFileExportRule>();
    for (SecurityRuleInfo deviceSecurityRule : export.getSecurityRuleInfos()) {
        ExportSecurityType[] securityFlavors = ExportSecurityType.values();
        boolean secFlavorSupported = false;
        for (ExportSecurityType sec : securityFlavors) {
            if (sec.name().equalsIgnoreCase(deviceSecurityRule.getSecFlavor())) {
                secFlavorSupported = true;
                break;
            }
        }
        if (secFlavorSupported) {
            UnManagedFileExportRule expRule = new UnManagedFileExportRule();
            expRule.setFileSystemId(fileSystemId);
            expRule.setExportPath(export.getPathname());
            expRule.setSecFlavor(deviceSecurityRule.getSecFlavor());
            expRule.setMountPoint(storagePortAddress + ":" + export.getPathname());
            String anon = deviceSecurityRule.getAnon();
            // TODO: This functionality has to be revisited to handle uids for anon.
            if ((null != anon) && (anon.equals(ROOT_UID))) {
                anon = ROOT_USER_ACCESS;
            } else {
                anon = DEFAULT_ANONMOUS_ACCESS;
            }
            expRule.setAnon(anon);
            if ((null != deviceSecurityRule.getRoot()) && !(deviceSecurityRule.getRoot()).isEmpty()) {
                StringSet rootHosts = new StringSet();
                for (ExportsHostnameInfo exportHost : deviceSecurityRule.getRoot()) {
                    boolean negate = false;
                    if (exportHost.getNegate() != null) {
                        negate = exportHost.getNegate();
                    }
                    if (!negate) {
                        if (null != exportHost.getName()) {
                            rootHosts.add(exportHost.getName());
                        }
                    }
                }
                expRule.setRootHosts(rootHosts);
            }
            if ((null != deviceSecurityRule.getReadWrite()) && !(deviceSecurityRule.getReadWrite()).isEmpty()) {
                StringSet readWriteHosts = new StringSet();
                for (ExportsHostnameInfo exportHost : deviceSecurityRule.getReadWrite()) {
                    boolean negate = false;
                    if (exportHost.getNegate() != null) {
                        negate = exportHost.getNegate();
                    }
                    if (!negate) {
                        if (null != exportHost.getName()) {
                            if (expRule.getRootHosts() != null) {
                                if (!expRule.getRootHosts().contains(exportHost.getName())) {
                                    readWriteHosts.add(exportHost.getName());
                                }
                            } else {
                                readWriteHosts.add(exportHost.getName());
                            }
                        }
                    }
                }
                expRule.setReadWriteHosts(readWriteHosts);
            }
            if ((null != deviceSecurityRule.getReadOnly()) && !(deviceSecurityRule.getReadOnly()).isEmpty()) {
                StringSet readOnlyHosts = new StringSet();
                for (ExportsHostnameInfo exportHost : deviceSecurityRule.getReadOnly()) {
                    boolean negate = false;
                    if (exportHost.getNegate() != null) {
                        negate = exportHost.getNegate();
                    }
                    if (!negate) {
                        if (null != exportHost.getName()) {
                            boolean checkRWPermissions = false;
                            if (expRule.getRootHosts() != null) {
                                if (!expRule.getRootHosts().contains(exportHost.getName())) {
                                    checkRWPermissions = true;
                                }
                            } else {
                                checkRWPermissions = true;
                            }
                            if (checkRWPermissions) {
                                if (expRule.getReadWriteHosts() != null) {
                                    if (!expRule.getReadWriteHosts().contains(exportHost.getName())) {
                                        readOnlyHosts.add(exportHost.getName());
                                    }
                                } else {
                                    readOnlyHosts.add(exportHost.getName());
                                }
                            }
                        }
                    }
                }
                expRule.setReadOnlyHosts(readOnlyHosts);
            }
            if (!((expRule.getReadOnlyHosts() == null || expRule.getReadOnlyHosts().isEmpty()) && (expRule.getReadWriteHosts() == null || expRule.getReadWriteHosts().isEmpty()) && (expRule.getRootHosts() == null || expRule.getRootHosts().isEmpty()))) {
                expRules.add(expRule);
            }
        }
    }
    return expRules;
}
Also used : UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) SecurityRuleInfo(com.iwave.ext.netapp.model.SecurityRuleInfo) StringSet(com.emc.storageos.db.client.model.StringSet) ExportSecurityType(com.emc.storageos.model.file.FileExportUpdateParams.ExportSecurityType) ExportsHostnameInfo(com.iwave.ext.netapp.model.ExportsHostnameInfo)

Example 9 with UnManagedFileExportRule

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

the class NetAppClusterModeCommIntf method discoverUnManagedNewExports.

private void discoverUnManagedNewExports(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
    String detailedStatusMessage = "Discovery of NetAppC Unmanaged Exports started";
    unManagedExportRulesInsert = new ArrayList<UnManagedFileExportRule>();
    unManagedExportRulesUpdate = new ArrayList<UnManagedFileExportRule>();
    // Used to Save the rules to DB
    List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<UnManagedFileExportRule>();
    NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    Collection<String> attrs = new ArrayList<String>();
    for (String property : ntpPropertiesList) {
        attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
    }
    try {
        List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
        List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
        for (StorageVirtualMachineInfo svmInfo : svms) {
            netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).svm(svmInfo.getName()).build();
            // Get exports on the array and loop through each export.
            List<ExportsRuleInfo> exports = netAppCApi.listNFSExportRules(null);
            // Verification Utility
            UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
            for (ExportsRuleInfo deviceExport : exports) {
                String filesystem = deviceExport.getPathname();
                _logger.info("Export Path {}", filesystem);
                String nativeId = filesystem;
                String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), nativeId);
                UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
                boolean fsAlreadyExists = unManagedFs == null ? false : true;
                // Used as for rules validation
                List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
                List<UnManagedFileExportRule> unManagedExportRulesToInsert = new ArrayList<UnManagedFileExportRule>();
                List<UnManagedFileExportRule> unManagedExportRulesToUpdate = new ArrayList<UnManagedFileExportRule>();
                if (fsAlreadyExists) {
                    _logger.debug("retrieve info for file system: " + filesystem);
                    String svm = getOwningSVM(filesystem, fileSystemInfo);
                    // Use IP address of SVM.
                    String addr = getSVMAddress(svm, svms);
                    UnManagedFSExportMap tempUnManagedExpMap = new UnManagedFSExportMap();
                    createExportMap(deviceExport, tempUnManagedExpMap, addr);
                    if (tempUnManagedExpMap.size() > 0) {
                        unManagedFs.setFsUnManagedExportMap(tempUnManagedExpMap);
                        _logger.debug("Export map for NetAppC UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getFsUnManagedExportMap());
                    }
                    List<UnManagedFileExportRule> exportRules = applyAllSecurityRules(deviceExport, addr, unManagedFs.getId());
                    _logger.info("Number of export rules discovered for file system {} is {}", unManagedFs.getId(), exportRules.size());
                    for (UnManagedFileExportRule dbExportRule : exportRules) {
                        _logger.info("Un Managed File Export Rule : {}", dbExportRule);
                        String fsExportRulenativeId = dbExportRule.getFsExportIndex();
                        _logger.info("Native Id using to build Native Guid {}", fsExportRulenativeId);
                        String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, fsExportRulenativeId);
                        _logger.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
                        UnManagedFileExportRule unManagedExportRule = checkUnManagedFsExportRuleExistsInDB(_dbClient, fsUnManagedFileExportRuleNativeGuid);
                        UnManagedFileExportRule unManagedExpRule = null;
                        if (unManagedExportRule == null) {
                            unManagedExportRule = new UnManagedFileExportRule();
                            unManagedExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
                            unManagedExportRule.setFileSystemId(unManagedFs.getId());
                            unManagedExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
                            unManagedExpRule = copyProperties(unManagedExportRule, dbExportRule);
                            unManagedExportRulesToInsert.add(unManagedExpRule);
                            // Build all export rules list.
                            unManagedExportRules.add(unManagedExpRule);
                            _logger.info("Unmanaged File Export Rule : {}", unManagedExpRule);
                        } else {
                            dbExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
                            dbExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
                            unManagedExportRulesToInsert.add(dbExportRule);
                            // Build all export rules list.
                            unManagedExportRules.add(dbExportRule);
                            // Delete the existing rule!!
                            unManagedExportRule.setInactive(true);
                            unManagedExportRulesToUpdate.add(unManagedExportRule);
                            _logger.info("Unmanaged File Export Rule : {}", dbExportRule);
                        }
                    }
                    // apply as per API SVC Validations.
                    if (!unManagedExportRules.isEmpty()) {
                        boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
                        if (isAllRulesValid) {
                            _logger.info("Validating rules success for export {}", filesystem);
                            unManagedExportRulesInsert.addAll(unManagedExportRulesToInsert);
                            unManagedExportRulesUpdate.addAll(unManagedExportRulesToUpdate);
                            unManagedFs.setHasExports(true);
                            unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                            _dbClient.persistObject(unManagedFs);
                            _logger.info("File System {} has Exports and their size is {}", unManagedFs.getId(), newUnManagedExportRules.size());
                        } else {
                            _logger.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", filesystem);
                            // Delete the UMFS as it having invalid rule!!!
                            unManagedFs.setInactive(true);
                            _dbClient.persistObject(unManagedFs);
                        }
                    }
                    // Adding this additional logic to avoid OOM
                    if (unManagedExportRulesInsert.size() == MAX_UMFS_RECORD_SIZE) {
                        // Add UnManagedFileSystem
                        _partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
                        unManagedExportRulesInsert.clear();
                        unManagedExportRulesToInsert.clear();
                    }
                    if (unManagedExportRulesUpdate.size() == MAX_UMFS_RECORD_SIZE) {
                        // Update UnManagedFilesystem
                        _partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
                        unManagedExportRulesUpdate.clear();
                        unManagedExportRulesToUpdate.clear();
                    }
                } else {
                    _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + deviceExport + " export");
                }
            }
        }
        if (!unManagedExportRulesInsert.isEmpty()) {
            // Add UnManagedFileSystem
            _partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
            unManagedExportRulesInsert.clear();
        }
        if (!unManagedExportRulesUpdate.isEmpty()) {
            // Update UnManagedFilesystem
            _partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
            unManagedExportRulesUpdate.clear();
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
    } catch (NetAppCException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed.  Storage system: " + storageSystemId);
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportsRuleInfo(com.iwave.ext.netapp.model.ExportsRuleInfo) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) StorageVirtualMachineInfo(com.iwave.ext.netappc.StorageVirtualMachineInfo) 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) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)

Example 10 with UnManagedFileExportRule

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

the class NetAppFileCommunicationInterface method applyAllSecurityRules.

/**
 * check Pre Existing Storage File Export Rules exists in DB
 *
 * @param nativeGuid
 * @return unManageFileExport Rule
 * @throws IOException
 */
// TODO:Account for multiple security rules and security flavors
private List<UnManagedFileExportRule> applyAllSecurityRules(ExportsRuleInfo export, String storagePortAddress, URI fileSystemId) {
    List<UnManagedFileExportRule> expRules = new ArrayList<UnManagedFileExportRule>();
    for (SecurityRuleInfo deviceSecurityRule : export.getSecurityRuleInfos()) {
        UnManagedFileExportRule expRule = new UnManagedFileExportRule();
        expRule.setFileSystemId(fileSystemId);
        expRule.setExportPath(export.getPathname());
        expRule.setSecFlavor(deviceSecurityRule.getSecFlavor());
        expRule.setMountPoint(storagePortAddress + ":" + export.getPathname());
        String anon = deviceSecurityRule.getAnon();
        // TODO: This functionality has to be revisited to handle uids for anon.
        if ((null != anon) && (anon.equals(ROOT_UID))) {
            anon = ROOT_USER_ACCESS;
        } else {
            anon = DEFAULT_ANONMOUS_ACCESS;
        }
        expRule.setAnon(anon);
        if ((null != deviceSecurityRule.getReadOnly()) && !deviceSecurityRule.getReadOnly().isEmpty()) {
            StringSet readOnlyHosts = new StringSet();
            for (ExportsHostnameInfo exportHost : deviceSecurityRule.getReadOnly()) {
                if (null != exportHost.getName()) {
                    readOnlyHosts.add(exportHost.getName());
                }
            }
            expRule.setReadOnlyHosts(readOnlyHosts);
        }
        if ((null != deviceSecurityRule.getReadWrite()) && !deviceSecurityRule.getReadWrite().isEmpty()) {
            StringSet readWriteHosts = new StringSet();
            for (ExportsHostnameInfo exportHost : deviceSecurityRule.getReadWrite()) {
                if (null != exportHost.getName()) {
                    readWriteHosts.add(exportHost.getName());
                }
            }
            expRule.setReadWriteHosts(readWriteHosts);
        }
        if ((null != deviceSecurityRule.getRoot()) && !deviceSecurityRule.getRoot().isEmpty()) {
            StringSet rootHosts = new StringSet();
            for (ExportsHostnameInfo exportHost : deviceSecurityRule.getRoot()) {
                if (null != exportHost.getName()) {
                    rootHosts.add(exportHost.getName());
                }
            }
            expRule.setRootHosts(rootHosts);
        }
        expRules.add(expRule);
    }
    return expRules;
}
Also used : UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) SecurityRuleInfo(com.iwave.ext.netapp.model.SecurityRuleInfo) StringSet(com.emc.storageos.db.client.model.StringSet) ExportsHostnameInfo(com.iwave.ext.netapp.model.ExportsHostnameInfo)

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