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