Search in sources :

Example 1 with DDOptionInfo

use of com.emc.storageos.datadomain.restapi.DDOptionInfo 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)

Example 2 with DDOptionInfo

use of com.emc.storageos.datadomain.restapi.DDOptionInfo in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method createExportMap.

private void createExportMap(DDExportInfoDetail export, UnManagedFileSystem unManagedFS, List<StoragePort> ports) {
    Map<String, List<String>> endPointMap = new HashMap<String, List<String>>();
    for (DDExportClient client : export.getClients()) {
        List<String> clients = endPointMap.get(client.getOptions());
        if (clients == null) {
            clients = new ArrayList<String>();
            endPointMap.put(client.getOptions(), clients);
        }
        clients.add(client.getName());
    }
    UnManagedFSExportMap exportMap = unManagedFS.getFsUnManagedExportMap();
    if (exportMap == null) {
        exportMap = new UnManagedFSExportMap();
        unManagedFS.setFsUnManagedExportMap(exportMap);
    }
    Set<String> options = endPointMap.keySet();
    for (String option : options) {
        UnManagedFSExport fExport = new UnManagedFSExport();
        fExport.setNativeId(export.getId());
        fExport.setMountPath(export.getPath());
        fExport.setMountPoint(export.getPath());
        fExport.setPath(export.getPath());
        fExport.setClients(endPointMap.get(option));
        DDOptionInfo optionInfo = DDOptionInfo.parseOptions(option);
        fExport.setPermissions(optionInfo.permission);
        fExport.setProtocol(NFS);
        fExport.setRootUserMapping(optionInfo.rootMapping);
        fExport.setSecurityType(optionInfo.security);
        // need to find the port which was used to create this export.
        // Right now DD API does not contain any info on that.
        Collections.shuffle(ports);
        fExport.setStoragePort(ports.get(0).getId().toString());
        fExport.setStoragePortName(ports.get(0).getPortName());
        String exportKey = fExport.getFileExportKey();
        exportMap.put(exportKey, fExport);
    }
}
Also used : UnManagedFSExport(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport) HashMap(java.util.HashMap) DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDOptionInfo(com.emc.storageos.datadomain.restapi.DDOptionInfo) DDMTreeList(com.emc.storageos.datadomain.restapi.model.DDMTreeList) DDNetworkList(com.emc.storageos.datadomain.restapi.model.DDNetworkList) List(java.util.List) DDExportList(com.emc.storageos.datadomain.restapi.model.DDExportList) DDSystemList(com.emc.storageos.datadomain.restapi.model.DDSystemList) ArrayList(java.util.ArrayList) DDShareList(com.emc.storageos.datadomain.restapi.model.DDShareList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)

Aggregations

DDOptionInfo (com.emc.storageos.datadomain.restapi.DDOptionInfo)2 DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)2 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 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 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedFSExport (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExport)1 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)1 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)1 List (java.util.List)1 Map (java.util.Map)1