Search in sources :

Example 1 with ExportsHostnameInfo

use of com.iwave.ext.netapp.model.ExportsHostnameInfo 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)

Example 2 with ExportsHostnameInfo

use of com.iwave.ext.netapp.model.ExportsHostnameInfo 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 3 with ExportsHostnameInfo

use of com.iwave.ext.netapp.model.ExportsHostnameInfo 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)

Example 4 with ExportsHostnameInfo

use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method createUnManagedExport.

private UnManagedFSExport createUnManagedExport(ExportsRuleInfo export, List<ExportsHostnameInfo> typeHosts, String permission, String port) {
    List<String> clientList = new ArrayList<String>();
    UnManagedFSExport tempUnManagedFSExport = null;
    if ((null != typeHosts) && !typeHosts.isEmpty()) {
        for (ExportsHostnameInfo client : typeHosts) {
            if ((null != client.getName() && !(clientList.contains(client.getName())))) {
                if (!clientList.contains(client.getName())) {
                    clientList.add(client.getName());
                }
            } else if ((null != client.getAllHosts()) && (client.getAllHosts())) {
                // All hosts means empty clientList in ViPR.
                clientList.clear();
                _logger.info("Settng ClientList to empty as the export is meant to be accsible to all hosts");
            }
        }
        String anon = export.getSecurityRuleInfos().get(0).getAnon();
        if ((null != anon) && (anon.equals(ROOT_UID))) {
            anon = ROOT_USER_ACCESS;
        } else {
            anon = DEFAULT_ANONMOUS_ACCESS;
        }
        tempUnManagedFSExport = new UnManagedFSExport(clientList, port, port + ":" + export.getPathname(), export.getSecurityRuleInfos().get(0).getSecFlavor(), permission, anon, NFS, port, export.getPathname(), export.getPathname());
    }
    return tempUnManagedFSExport;
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport) ArrayList(java.util.ArrayList) ExportsHostnameInfo(com.iwave.ext.netapp.model.ExportsHostnameInfo)

Example 5 with ExportsHostnameInfo

use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.

the class FlexFileShare method extractExportsHostnameInfos.

private List<ExportsHostnameInfo> extractExportsHostnameInfos(NaElement elem) {
    List<ExportsHostnameInfo> exportsHostnameInfos = Lists.newArrayList();
    if (elem != null && elem.getChildren() != null) {
        for (NaElement exportsHostname : (List<NaElement>) elem.getChildren()) {
            ExportsHostnameInfo exportsHostnameInfo = new ExportsHostnameInfo();
            String allHosts = exportsHostname.getChildContent("all-hosts");
            if (StringUtils.isNotBlank(allHosts)) {
                exportsHostnameInfo.setAllHosts(Boolean.parseBoolean(allHosts));
            }
            exportsHostnameInfo.setName(exportsHostname.getChildContent("name"));
            String negate = exportsHostname.getChildContent("negate");
            if (StringUtils.isNotBlank(negate)) {
                exportsHostnameInfo.setNegate(Boolean.parseBoolean(negate));
            }
            exportsHostnameInfos.add(exportsHostnameInfo);
        }
    }
    return exportsHostnameInfos;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) NaElement(netapp.manage.NaElement) ExportsHostnameInfo(com.iwave.ext.netapp.model.ExportsHostnameInfo)

Aggregations

ExportsHostnameInfo (com.iwave.ext.netapp.model.ExportsHostnameInfo)11 ArrayList (java.util.ArrayList)8 SecurityRuleInfo (com.iwave.ext.netapp.model.SecurityRuleInfo)5 UnManagedFSExport (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport)4 List (java.util.List)4 NaElement (netapp.manage.NaElement)4 ExportsRuleInfo (com.iwave.ext.netapp.model.ExportsRuleInfo)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)2 NaAPIFailedException (netapp.manage.NaAPIFailedException)2 ExportSecurityType (com.emc.storageos.model.file.FileExportUpdateParams.ExportSecurityType)1 Test (org.junit.Test)1