Search in sources :

Example 1 with DDExportClient

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

the class DataDomainFileStorageDevice method doAddDeleteClients.

private void doAddDeleteClients(DataDomainClient ddClient, String storagePoolId, String exportId, List<ExportRule> rulesToModify, boolean delete) throws DataDomainApiException {
    if ((rulesToModify != null) && (!rulesToModify.isEmpty())) {
        // Build list of endpoints for rules being modified (added or deleted)
        List<DDExportClient> ddExportClients = new ArrayList<>();
        for (ExportRule ruleToModify : rulesToModify) {
            List<DDExportClient> ddExpClients = ddBuildExportClientList(ruleToModify);
            if (ddExpClients != null) {
                ddExportClients.addAll(ddExpClients);
            }
        }
        // Build list of clients to be modified on the array
        List<DDExportClientModify> modifyClients = new ArrayList<>();
        for (DDExportClient ddExportClient : ddExportClients) {
            DDExportClientModify modifyClient = new DDExportClientModify(ddExportClient.getName(), ddExportClient.getOptions(), delete);
            modifyClients.add(modifyClient);
        }
        // Modify clients on the array
        if (!modifyClients.isEmpty()) {
            DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, exportId, modifyClients);
            if (ddExportInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
                DDExportInfoDetail exportDetail = ddClient.getExport(storagePoolId, exportId);
                if (delete) {
                    throw DataDomainApiException.exceptions.failedToDeleteExportClients(exportDetail.getPath());
                } else {
                    throw DataDomainApiException.exceptions.failedToAddExportClients(exportDetail.getPath());
                }
            }
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 2 with DDExportClient

use of com.emc.storageos.datadomain.restapi.model.DDExportClient 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 3 with DDExportClient

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

Example 4 with DDExportClient

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

the class DataDomainFileStorageDevice method ddSetNewExportProperties.

private void ddSetNewExportProperties(FileExport fileExport, List<DDExportClient> ddExportClients, DDExportInfo ddExportInfo) {
    fileExport.setNativeId(ddExportInfo.getId());
    fileExport.setMountPath(ddExportInfo.getPath());
    List<String> clients = new ArrayList<>();
    for (DDExportClient ddExportClient : ddExportClients) {
        clients.add(ddExportClient.getName());
    }
    // Note: We store the fileExport permissions as available in the original
    // FileExport object. Only Clients, Protocol and Security Types are updated.
    fileExport.setClients(clients);
    fileExport.setProtocol(DataDomainApiConstants.NFS_PROTOCOL);
    String securityType = fileExport.getSecurityType();
    if (securityType == null) {
        fileExport.setSecurityType(DataDomainApiConstants.DEFAULT_SECURITY);
    }
}
Also used : DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) ArrayList(java.util.ArrayList)

Example 5 with DDExportClient

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

the class DataDomainFileStorageDevice method ddBuildExportClientList.

private List<DDExportClient> ddBuildExportClientList(ExportRule exportRule) {
    List<DDExportClient> ddExportClients = new ArrayList<>();
    Set<String> roHosts = exportRule.getReadOnlyHosts();
    Set<String> rwHosts = exportRule.getReadWriteHosts();
    Set<String> rootHosts = exportRule.getRootHosts();
    // Set options common to all permission types
    StringBuilder commonOptions = new StringBuilder(ddSetExportOptions(exportRule));
    _log.info("ddBuildExportClientList commonOptions {} for exportRule {}", commonOptions, exportRule.toString());
    // Read only exports
    if (roHosts != null) {
        for (String host : roHosts) {
            StringBuilder roOptions = new StringBuilder(commonOptions);
            roOptions.append(DataDomainApiConstants.PERMISSION_RO);
            ddExportClients.add(new DDExportClient(host, roOptions.toString()));
        }
    }
    // Read write exports
    if (rwHosts != null) {
        for (String host : rwHosts) {
            StringBuilder rwOptions = new StringBuilder(commonOptions);
            rwOptions.append(DataDomainApiConstants.PERMISSION_RW);
            ddExportClients.add(new DDExportClient(host, rwOptions.toString()));
        }
    }
    // Root exports
    if (rootHosts != null) {
        for (String host : rootHosts) {
            StringBuilder rootOptions = new StringBuilder(commonOptions);
            rootOptions.append(DataDomainApiConstants.PERMISSION_RW);
            ddExportClients.add(new DDExportClient(host, rootOptions.toString()));
        }
    }
    for (DDExportClient ddClient : ddExportClients) {
        _log.info("DDExportClient : {}", ddClient.toString());
    }
    return (ddExportClients);
}
Also used : DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) ArrayList(java.util.ArrayList)

Aggregations

DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)7 ArrayList (java.util.ArrayList)6 DDOptionInfo (com.emc.storageos.datadomain.restapi.DDOptionInfo)2 DDExportInfo (com.emc.storageos.datadomain.restapi.model.DDExportInfo)2 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)2 HashMap (java.util.HashMap)2 DDExportClientModify (com.emc.storageos.datadomain.restapi.model.DDExportClientModify)1 DDExportInfoDetail (com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail)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 DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)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 FileExport (com.emc.storageos.db.client.model.FileExport)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