use of com.emc.storageos.isilon.restapi.IsilonExport in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method extraExportRuleFromArray.
/**
* Get the export rule which are present in arry but not in CoprHD Database.
*
* @param storage
* @param args
* @return map with security flavor and export rule
*/
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// map to store the export rule grouped by sec flavor
Map<String, ExportRule> exportRuleMap = new HashMap<>();
List<IsilonExport> exportsList = new ArrayList<IsilonExport>();
Set<String> arrayReadOnlyHost = new HashSet<>();
Set<String> arrayReadWriteHost = new HashSet<>();
Set<String> arrayRootHost = new HashSet<>();
Set<String> dbReadOnlyHost = new HashSet<>();
Set<String> dbReadWriteHost = new HashSet<>();
Set<String> dbRootHost = new HashSet<>();
// get all export rule from CoprHD data base
List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
// get the all the export from the storage system.
IsilonApi isi = getIsilonDevice(storage);
for (ExportRule exportRule : existingDBExportRules) {
if (exportRule.getReadOnlyHosts() != null) {
dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
dbRootHost.addAll(exportRule.getRootHosts());
}
String isilonExportId = exportRule.getDeviceExportId();
if (isilonExportId != null) {
IsilonExport isilonExport = null;
String zoneName = getZoneName(args.getvNAS());
if (zoneName != null) {
isilonExport = isi.getExport(isilonExportId, zoneName);
} else {
isilonExport = isi.getExport(isilonExportId);
}
exportsList.add(isilonExport);
arrayReadOnlyHost.addAll(isilonExport.getReadOnlyClients());
arrayReadWriteHost.addAll(isilonExport.getReadWriteClients());
arrayRootHost.addAll(isilonExport.getRootClients());
}
// find out the change between array and CoprHD database.
Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
// if change found update the exportRuleMap
if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
ExportRule extraRuleFromArray = new ExportRule();
extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
extraRuleFromArray.setAnon(exportRule.getAnon());
extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
extraRuleFromArray.setExportPath(exportRule.getExportPath());
extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
extraRuleFromArray.setRootHosts(arrayExtraRootHost);
exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
}
}
return exportRuleMap;
}
use of com.emc.storageos.isilon.restapi.IsilonExport in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method cloneExport.
private IsilonExport cloneExport(IsilonExport exp) {
IsilonExport newExport = new IsilonExport();
newExport.addPath(exp.getPaths().get(0));
newExport.addRootClients(exp.getRootClients());
newExport.addReadWriteClients(exp.getReadWriteClients());
newExport.addReadOnlyClients(exp.getReadOnlyClients());
if (exp.getReadOnly()) {
newExport.setReadOnly();
} else {
newExport.resetReadOnly();
}
if (exp.getAllDirs()) {
newExport.setAllDirs();
} else {
newExport.resetAllDirs();
}
newExport.addClients(exp.getClients());
if (exp.getComment() != null) {
newExport.setComment(exp.getComment());
}
newExport.setSecurityFlavors(exp.getSecurityFlavors());
if (exp.getMap_all().getUser() != null && !exp.getMap_all().getUser().isEmpty()) {
newExport.setMapAll(exp.getMap_all().getUser());
}
if (exp.getMap_root().getUser() != null && !exp.getMap_root().getUser().isEmpty()) {
newExport.setMapRoot(exp.getMap_root().getUser());
}
return newExport;
}
use of com.emc.storageos.isilon.restapi.IsilonExport in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method getUnManagedFSExportRules.
/**
* Generate Export Map for UnManagedFileSystem
* Ignore exports with multiple exports for the same path
* Ignore exports that have multiple security flavors
* Ignore exports with multiple paths
* Ignore exports not found on the array
* Ignore exports which have the same internal export key ( <sec, perm, root-mapping>)
*
* @param umfs
* @param isilonExportIds
* @param storagePort
* @param fsPath
* @param isilonApi
* @return boolean
*/
private List<UnManagedFileExportRule> getUnManagedFSExportRules(UnManagedFileSystem umfs, StoragePort storagePort, HashSet<Integer> isilonExportIds, String fsPath, String zoneName, IsilonApi isilonApi) {
List<UnManagedFileExportRule> expRules = new ArrayList<UnManagedFileExportRule>();
ArrayList<IsilonExport> isilonExports = new ArrayList<IsilonExport>();
if (isilonExportIds != null && isilonExportIds.size() > 1) {
_log.info("Ignoring file system {}, Multiple export rulues found {} ", fsPath, isilonExportIds.size());
}
for (Integer expId : isilonExportIds) {
IsilonExport exp = getIsilonExport(isilonApi, expId, zoneName);
if (exp == null) {
_log.info("Ignoring file system {}, export {} not found", fsPath, expId);
} else if (exp.getSecurityFlavors().size() > 1) {
_log.info("Ignoring file system {}, multiple security flavors {} found", fsPath, exp.getSecurityFlavors().toString());
} else if (exp.getPaths().size() > 1) {
_log.info("Ignoring file system {}, multiple paths {} found", fsPath, exp.getPaths().toString());
} else {
isilonExports.add(exp);
}
}
for (IsilonExport exp : isilonExports) {
String securityFlavor = exp.getSecurityFlavors().get(0);
// Isilon Maps sys to unix and we do this conversion during export from ViPR
if (securityFlavor.equalsIgnoreCase(UNIXSECURITY)) {
securityFlavor = SYSSECURITY;
}
String path = exp.getPaths().get(0);
// Get User
String rootUserMapping = "";
String mapAllUserMapping = "";
if (exp.getMap_root() != null && exp.getMap_root().getUser() != null) {
rootUserMapping = exp.getMap_root().getUser();
} else if (exp.getMap_all() != null && exp.getMap_all().getUser() != null) {
mapAllUserMapping = exp.getMap_all().getUser();
}
String resolvedUser = (rootUserMapping != null && (!rootUserMapping.isEmpty())) ? rootUserMapping : mapAllUserMapping;
UnManagedFileExportRule expRule = new UnManagedFileExportRule();
expRule.setExportPath(path);
expRule.setSecFlavor(securityFlavor);
expRule.setAnon(resolvedUser);
expRule.setDeviceExportId(exp.getId().toString());
expRule.setFileSystemId(umfs.getId());
expRule.setMountPoint(storagePort.getPortNetworkId() + ":" + fsPath);
if (exp != null && exp.getReadOnlyClients() != null && !exp.getReadOnlyClients().isEmpty()) {
expRule.setReadOnlyHosts(new StringSet(exp.getReadOnlyClients()));
}
if (exp != null && exp.getReadWriteClients() != null && !exp.getReadWriteClients().isEmpty()) {
expRule.setReadWriteHosts(new StringSet(exp.getReadWriteClients()));
}
if (exp != null && exp.getRootClients() != null && !exp.getRootClients().isEmpty()) {
expRule.setRootHosts(new StringSet(exp.getRootClients()));
}
if (exp.getReadOnlyClients() != null && exp.getReadWriteClients() != null && exp.getRootClients() != null) {
// Check Clients size
if (exp.getReadOnlyClients().isEmpty() && exp.getReadWriteClients().isEmpty() && exp.getRootClients().isEmpty()) {
if (exp.getReadOnly()) {
// This is a read only export for all hosts
expRule.setReadOnlyHosts(new StringSet(exp.getClients()));
} else {
// Not read Only case
if (exp.getMap_all() != null && exp.getMap_all().getUser() != null && exp.getMap_all().getUser().equalsIgnoreCase(ROOT)) {
// All hosts with root permission
expRule.setRootHosts(new StringSet(exp.getClients()));
} else if (exp.getMap_all() != null) {
// All hosts with RW permission
expRule.setReadWriteHosts(new StringSet(exp.getClients()));
}
}
}
}
expRules.add(expRule);
}
return expRules;
}
Aggregations