Search in sources :

Example 1 with UnManagedFSExport

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

the class VNXFileCommunicationInterface method associateExportWithFS.

private void associateExportWithFS(UnManagedFileSystem vnxufs, String exportPath, Map<String, String> fsExportInfo, String mountPath, StoragePort storagePort) {
    try {
        String security = fsExportInfo.get(VNXFileConstants.SECURITY_TYPE);
        if (security == null) {
            security = FileShareExport.SecurityTypes.sys.toString();
        } else {
            String[] securityFlavorArr = security.split(VNXFileConstants.SECURITY_SEPARATORS);
            if (securityFlavorArr.length == 0) {
                security = FileShareExport.SecurityTypes.sys.toString();
            } else {
                security = securityFlavorArr[0];
            }
        }
        // Assign storage port to unmanaged FS
        vnxufs.getFileSystemInformation().remove(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
        if (storagePort != null) {
            StringSet storagePorts = new StringSet();
            storagePorts.add(storagePort.getId().toString());
            vnxufs.getFileSystemInformation().put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
        }
        // Get protocol, NFS by default
        String protocol = fsExportInfo.get(VNXFileConstants.PROTOCOL);
        if (protocol == null) {
            protocol = StorageProtocol.File.NFS.toString();
        }
        List<String> accessHosts = null;
        List<String> roHosts = null;
        List<String> rwHosts = null;
        List<String> rootHosts = null;
        // TODO all hosts
        String hosts = fsExportInfo.get(VNXFileConstants.ACCESS);
        if (hosts != null) {
            accessHosts = new ArrayList<String>(Arrays.asList(hosts.split(VNXFileConstants.HOST_SEPARATORS)));
        }
        hosts = fsExportInfo.get(VNXFileConstants.RO);
        if (hosts != null) {
            roHosts = new ArrayList<String>(Arrays.asList(hosts.split(VNXFileConstants.HOST_SEPARATORS)));
            ;
        }
        hosts = fsExportInfo.get(VNXFileConstants.RW);
        if (hosts != null) {
            rwHosts = new ArrayList<String>(Arrays.asList(hosts.split(VNXFileConstants.HOST_SEPARATORS)));
            ;
        }
        hosts = fsExportInfo.get(VNXFileConstants.ACCESS);
        if (hosts != null) {
            if (rwHosts == null) {
                rwHosts = new ArrayList();
            }
            rwHosts.addAll(Arrays.asList(hosts.split(VNXFileConstants.HOST_SEPARATORS)));
        }
        hosts = fsExportInfo.get(VNXFileConstants.ROOT);
        if (hosts != null) {
            rootHosts = new ArrayList<String>(Arrays.asList(hosts.split(VNXFileConstants.HOST_SEPARATORS)));
            ;
        }
        String anonUser = fsExportInfo.get(VNXFileConstants.ANON);
        // "ro" permission.
        if ((accessHosts != null) && (roHosts == null)) {
            // The non-null roHosts case is covered further below
            // Create a new unmanaged export
            UnManagedFSExport unManagedfileExport = createUnManagedExportWithAccessHosts(accessHosts, rwHosts, exportPath, security, storagePort, anonUser, protocol);
            associateExportMapWithFS(vnxufs, unManagedfileExport);
            StringBuffer debugInfo = new StringBuffer();
            debugInfo.append("VNXFileExport: ");
            debugInfo.append(" Hosts : " + accessHosts.toString());
            debugInfo.append(" Mount point : " + exportPath);
            debugInfo.append(" Permission : " + unManagedfileExport.getPermissions());
            debugInfo.append(" Protocol : " + unManagedfileExport.getProtocol());
            debugInfo.append(" Security type : " + unManagedfileExport.getSecurityType());
            debugInfo.append(" Root user mapping : " + unManagedfileExport.getRootUserMapping());
            _logger.debug(debugInfo.toString());
        }
        if (roHosts != null) {
            UnManagedFSExport unManagedfileExport = createUnManagedExportWithRoHosts(roHosts, accessHosts, exportPath, security, storagePort, anonUser, protocol);
            associateExportMapWithFS(vnxufs, unManagedfileExport);
            StringBuffer debugInfo = new StringBuffer();
            debugInfo.append("VNXFileExport: ");
            debugInfo.append(" Hosts : " + roHosts.toString());
            debugInfo.append(" Mount point : " + exportPath);
            debugInfo.append(" Permission : " + unManagedfileExport.getPermissions());
            debugInfo.append(" Protocol : " + unManagedfileExport.getProtocol());
            debugInfo.append(" Security type : " + unManagedfileExport.getSecurityType());
            debugInfo.append(" Root user mapping : " + unManagedfileExport.getRootUserMapping());
            _logger.debug(debugInfo.toString());
        }
        if (rwHosts != null) {
            UnManagedFSExport unManagedfileExport = createUnManagedExportWithRwHosts(rwHosts, exportPath, security, storagePort, anonUser, protocol);
            associateExportMapWithFS(vnxufs, unManagedfileExport);
            StringBuffer debugInfo = new StringBuffer();
            debugInfo.append("VNXFileExport: ");
            debugInfo.append(" Hosts : " + rwHosts.toString());
            debugInfo.append(" Mount point : " + exportPath);
            debugInfo.append(" Permission : " + unManagedfileExport.getPermissions());
            debugInfo.append(" Protocol : " + unManagedfileExport.getProtocol());
            debugInfo.append(" Security type : " + unManagedfileExport.getSecurityType());
            debugInfo.append(" Root user mapping : " + unManagedfileExport.getRootUserMapping());
            _logger.debug(debugInfo.toString());
        }
        if (rootHosts != null) {
            UnManagedFSExport unManagedfileExport = createUnManagedExportWithRootHosts(rootHosts, exportPath, security, storagePort, anonUser, protocol);
            // TODO Separate create map and associate
            associateExportMapWithFS(vnxufs, unManagedfileExport);
            StringBuffer debugInfo = new StringBuffer();
            debugInfo.append("VNXFileExport: ");
            debugInfo.append(" Hosts : " + rootHosts.toString());
            debugInfo.append(" Mount point : " + exportPath);
            debugInfo.append(" Permission : " + unManagedfileExport.getPermissions());
            debugInfo.append(" Protocol : " + unManagedfileExport.getProtocol());
            debugInfo.append(" Security type : " + unManagedfileExport.getSecurityType());
            debugInfo.append(" Root user mapping : " + unManagedfileExport.getRootUserMapping());
            _logger.info(debugInfo.toString());
        }
    } catch (Exception ex) {
        _logger.warn("VNX file export retrieve processor failed for path {}, cause {}", mountPath, ex);
    }
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)

Example 2 with UnManagedFSExport

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

the class VNXFileCommunicationInterface method createUnManagedExportWithRootHosts.

private UnManagedFSExport createUnManagedExportWithRootHosts(List<String> rootHosts, String mountPath, String security, StoragePort storagePort, String anonUser, String protocol) {
    UnManagedFSExport unManagedfileExport = new UnManagedFSExport();
    setupUnManagedFSExportProperties(unManagedfileExport, mountPath, security, storagePort, anonUser, protocol);
    unManagedfileExport.setClients(rootHosts);
    unManagedfileExport.setPermissions(VNXFileConstants.ROOT);
    return unManagedfileExport;
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport)

Example 3 with UnManagedFSExport

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

the class VNXFileCommunicationInterface method createUnManagedExportWithRwHosts.

private UnManagedFSExport createUnManagedExportWithRwHosts(List<String> rwHosts, String mountPath, String security, StoragePort storagePort, String anonUser, String protocol) {
    UnManagedFSExport unManagedfileExport = new UnManagedFSExport();
    setupUnManagedFSExportProperties(unManagedfileExport, mountPath, security, storagePort, anonUser, protocol);
    unManagedfileExport.setClients(rwHosts);
    unManagedfileExport.setPermissions(VNXFileConstants.RW);
    return unManagedfileExport;
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport)

Example 4 with UnManagedFSExport

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport 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 5 with UnManagedFSExport

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

the class NetAppClusterModeCommIntf method createExportMap.

private void createExportMap(ExportsRuleInfo export, UnManagedFSExportMap tempUnManagedExpMap, String storagePort) {
    List<ExportsHostnameInfo> readonlyHosts = export.getSecurityRuleInfos().get(0).getReadOnly();
    List<ExportsHostnameInfo> readwriteHosts = export.getSecurityRuleInfos().get(0).getReadWrite();
    List<ExportsHostnameInfo> rootHosts = export.getSecurityRuleInfos().get(0).getRoot();
    UnManagedFSExport tempUnManagedFSROExport = createUnManagedExport(export, readonlyHosts, RO, storagePort);
    if (tempUnManagedFSROExport != null) {
        tempUnManagedExpMap.put(tempUnManagedFSROExport.getFileExportKey(), tempUnManagedFSROExport);
    }
    UnManagedFSExport tempUnManagedFSRWExport = createUnManagedExport(export, readwriteHosts, RW, storagePort);
    if (tempUnManagedFSRWExport != null) {
        tempUnManagedExpMap.put(tempUnManagedFSRWExport.getFileExportKey(), tempUnManagedFSRWExport);
    }
    UnManagedFSExport tempUnManagedFSROOTExport = createUnManagedExport(export, rootHosts, ROOT, storagePort);
    if (tempUnManagedFSROOTExport != null) {
        tempUnManagedExpMap.put(tempUnManagedFSROOTExport.getFileExportKey(), tempUnManagedFSROOTExport);
    }
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport) ExportsHostnameInfo(com.iwave.ext.netapp.model.ExportsHostnameInfo)

Aggregations

UnManagedFSExport (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport)12 ArrayList (java.util.ArrayList)5 ExportsHostnameInfo (com.iwave.ext.netapp.model.ExportsHostnameInfo)4 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 DDOptionInfo (com.emc.storageos.datadomain.restapi.DDOptionInfo)1 DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)1 DDExportList (com.emc.storageos.datadomain.restapi.model.DDExportList)1 DDMTreeList (com.emc.storageos.datadomain.restapi.model.DDMTreeList)1 DDNetworkList (com.emc.storageos.datadomain.restapi.model.DDNetworkList)1 DDShareList (com.emc.storageos.datadomain.restapi.model.DDShareList)1 DDSystemList (com.emc.storageos.datadomain.restapi.model.DDSystemList)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)1 FileExport (com.emc.storageos.db.client.model.FileExport)1 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 IsilonExport (com.emc.storageos.isilon.restapi.IsilonExport)1