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;
}
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);
}
}
Aggregations