use of com.emc.storageos.isilon.restapi.IsilonAccessZone in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method populateDbMetricsAz.
/**
* process dbmetrics for total count and capacity
*
* @param azName
* @param isilonApi
* @param dbMetrics
*/
private void populateDbMetricsAz(final IsilonAccessZone accessZone, IsilonApi isilonApi, StringMap dbMetrics) {
long totalProvCap = 0L;
long totalFsCount = 0L;
String resumeToken = null;
String zoneName = accessZone.getName();
String baseDirPath = accessZone.getPath() + "/";
// filesystems count & used Capacity
IsilonList<IsilonSmartQuota> quotas = null;
do {
quotas = isilonApi.listQuotas(resumeToken, baseDirPath);
if (quotas != null && !quotas.getList().isEmpty()) {
for (IsilonSmartQuota quota : quotas.getList()) {
totalProvCap = totalProvCap + quota.getUsagePhysical();
totalFsCount++;
}
}
resumeToken = quotas.getToken();
} while (resumeToken != null);
// create a list of access zone for which base dir is not same as system access zone.
// we get all snapshot list at once. baseDirPaths list is used to
// find snaphot belong to which access zone.
List<String> baseDirPaths = null;
if (accessZone.isSystem() == true) {
List<IsilonAccessZone> isilonAccessZoneList = isilonApi.getAccessZones(resumeToken);
baseDirPaths = new ArrayList<String>();
for (IsilonAccessZone isiAccessZone : isilonAccessZoneList) {
if (!baseDirPath.equals(IFS_ROOT + "/")) {
baseDirPaths.add(isiAccessZone.getPath() + "/");
}
}
}
// snapshots count & snap capacity
resumeToken = null;
IsilonList<IsilonSnapshot> snapshots = null;
do {
snapshots = isilonApi.listSnapshots(resumeToken);
if (snapshots != null && !snapshots.getList().isEmpty()) {
if (!baseDirPath.equals(IFS_ROOT + "/")) {
// if it is not system access zone then compare
// with fs path with base dir path
_log.info("access zone base directory path {}", baseDirPath);
for (IsilonSnapshot isilonSnap : snapshots.getList()) {
if (isilonSnap.getPath().startsWith(baseDirPath)) {
totalProvCap = totalProvCap + Long.valueOf(isilonSnap.getSize());
totalFsCount++;
}
}
} else {
// process the snapshots for system access zone
boolean snapSystem = true;
for (IsilonSnapshot isilonSnap : snapshots.getList()) {
snapSystem = true;
// first check fs path with user defined AZ's paths
if (baseDirPaths != null && !baseDirPaths.isEmpty()) {
for (String basePath : baseDirPaths) {
if (isilonSnap.getPath().startsWith(basePath)) {
snapSystem = false;
break;
}
}
}
// it then it is belongs to access zone with basedir same as system access zone.
if (snapSystem) {
totalProvCap = totalProvCap + Long.valueOf(isilonSnap.getSize());
totalFsCount++;
_log.info("Access zone base directory path: {}", accessZone.getPath());
}
}
}
resumeToken = snapshots.getToken();
}
} while (resumeToken != null);
if (totalProvCap > 0) {
totalProvCap = (totalProvCap / KB_IN_BYTES);
}
_log.info("Total fs Count {} for access zone : {}", String.valueOf(totalFsCount), accessZone.getName());
_log.info("Total fs Capacity {} for access zone : {}", String.valueOf(totalProvCap), accessZone.getName());
// get total exports
int nfsExportsCount = 0;
int cifsSharesCount = 0;
resumeToken = null;
IsilonList<IsilonExport> isilonNfsExports = null;
do {
isilonNfsExports = isilonApi.listExports(resumeToken, zoneName);
if (isilonNfsExports != null) {
nfsExportsCount = nfsExportsCount + isilonNfsExports.size();
resumeToken = isilonNfsExports.getToken();
}
} while (resumeToken != null);
_log.info("Total NFS exports {} for access zone : {}", String.valueOf(nfsExportsCount), accessZone.getName());
// get cifs exports for given access zone
resumeToken = null;
IsilonList<IsilonSMBShare> isilonCifsExports = null;
do {
isilonCifsExports = isilonApi.listShares(resumeToken, zoneName);
if (isilonCifsExports != null) {
cifsSharesCount = cifsSharesCount + isilonCifsExports.size();
resumeToken = isilonCifsExports.getToken();
}
} while (resumeToken != null);
_log.info("Total CIFS sharess {} for access zone : {}", String.valueOf(cifsSharesCount), accessZone.getName());
if (dbMetrics == null) {
dbMetrics = new StringMap();
}
// set total nfs and cifs exports for give AZ
dbMetrics.put(MetricsKeys.totalNfsExports.name(), String.valueOf(nfsExportsCount));
dbMetrics.put(MetricsKeys.totalCifsShares.name(), String.valueOf(cifsSharesCount));
// set total fs objects and their sum of capacity for give AZ
dbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalFsCount));
dbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalProvCap));
Long maxExports = MetricsKeys.getLong(MetricsKeys.maxNFSExports, dbMetrics) + MetricsKeys.getLong(MetricsKeys.maxCifsShares, dbMetrics);
Long maxStorObjs = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, dbMetrics);
Long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, dbMetrics);
Long totalExports = Long.valueOf(nfsExportsCount + cifsSharesCount);
// setting overLoad factor (true or false)
String overLoaded = FALSE;
if (totalExports >= maxExports || totalProvCap >= maxCapacity || totalFsCount >= maxStorObjs) {
overLoaded = TRUE;
}
double percentageLoadExports = 0.0;
// percentage calculator
if (totalExports > 0.0) {
percentageLoadExports = ((double) (totalExports) / maxExports) * 100;
}
double percentageLoadStorObj = ((double) (totalProvCap) / maxCapacity) * 100;
double percentageLoad = (percentageLoadExports + percentageLoadStorObj) / 2;
dbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
dbMetrics.put(MetricsKeys.overLoaded.name(), overLoaded);
return;
}
use of com.emc.storageos.isilon.restapi.IsilonAccessZone in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method validateAndGetNASServer.
/**
* This function will get the list of access zones present in the system,
* validate the access zones and return only the valid access zones,
* so that UMFS discovery would process only objects of required access zones!!
*
* @param storageSystem
* @param accessZones
* @return
*/
private Map<String, NASServer> validateAndGetNASServer(final StorageSystem storageSystem, List<IsilonAccessZone> accessZones) {
NASServer nasServer = null;
List<IsilonAccessZone> InvalidAccessZones = new ArrayList<IsilonAccessZone>();
Map<String, NASServer> accessZonesMap = new HashMap<String, NASServer>();
if (accessZones != null && !accessZones.isEmpty()) {
for (IsilonAccessZone isilonAccessZone : accessZones) {
if (isilonAccessZone.isSystem() == false) {
nasServer = findvNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (nasServer != null && !nasServer.getInactive() && DiscoveredDataObject.DiscoveryStatus.VISIBLE.name().equals(nasServer.getDiscoveryStatus())) {
accessZonesMap.put(isilonAccessZone.getPath() + "/", nasServer);
} else {
InvalidAccessZones.add(isilonAccessZone);
_log.info("Nas server {} is not valid, hence filesystem's will not be ingested", isilonAccessZone.getName());
}
} else {
nasServer = findPhysicalNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (nasServer != null && !nasServer.getInactive()) {
accessZonesMap.put(isilonAccessZone.getPath() + "/", nasServer);
} else {
InvalidAccessZones.add(isilonAccessZone);
_log.info("Nas server {} is not valid, hence filesystem's will not be ingested", isilonAccessZone.getName());
}
}
}
// Remove the invalid nas servers, so that we do not discover any object of it!!!
if (!InvalidAccessZones.isEmpty()) {
accessZones.removeAll(InvalidAccessZones);
}
}
return accessZonesMap;
}
use of com.emc.storageos.isilon.restapi.IsilonAccessZone in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverUmanagedFileSystems.
private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<>();
List<UnManagedFileQuotaDirectory> newUnManagedFileQuotaDir = new ArrayList<>();
List<UnManagedFileQuotaDirectory> existingUnManagedFileQuotaDir = new ArrayList<>();
List<UnManagedCifsShareACL> newUnManagedCifsShareACLList = new ArrayList<>();
List<UnManagedCifsShareACL> oldUnManagedCifsShareACLList = new ArrayList<>();
List<UnManagedNFSShareACL> newUnManagedNfsShareACLList = new ArrayList<>();
List<UnManagedNFSShareACL> oldUnManagedNfsShareACLList = new ArrayList<>();
List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<>();
List<UnManagedFileExportRule> oldUnManagedExportRules = new ArrayList<>();
_log.debug("Access Profile Details : IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<>();
String detailedStatusMessage = "Discovery of Isilon Unmanaged FileSystem started";
long unmanagedFsCount = 0;
try {
IsilonApi isilonApi = getIsilonDevice(storageSystem);
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
ArrayList<StoragePool> pools = new ArrayList<>();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
if (storagePool != null && !storagePool.getInactive()) {
pools.add(storagePool);
}
}
StoragePool storagePool = null;
if (pools != null && !pools.isEmpty()) {
storagePool = pools.get(0);
}
StoragePort storagePort = getStoragePortPool(storageSystem);
int totalIsilonFSDiscovered = 0;
// get the associated storage port for vnas Server
List<IsilonAccessZone> isilonAccessZones = isilonApi.getAccessZones(null);
Map<String, NASServer> nasServers = validateAndGetNASServer(storageSystem, isilonAccessZones);
// update the path from controller configuration
updateDiscoveryPathForUnManagedFS(nasServers, storageSystem);
// NFSv4 enabled on storage system!!!
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
List<FileShare> discoveredFS = new ArrayList<>();
String resumeToken = null;
for (String umfsDiscoverPath : _discPathsForUnManaged) {
IsilonAccessZone isilonAccessZone = getAccessZoneCorresDiscoveryPath(isilonAccessZones, umfsDiscoverPath);
String isilonAccessZoneName;
if (isilonAccessZone == null) {
// System access zone
isilonAccessZoneName = null;
} else {
isilonAccessZoneName = isilonAccessZone.getName();
}
// Get All SMB for this path access zone
HashMap<String, HashSet<String>> zoneSMBShares = discoverAccessZoneSMBShares(storageSystem, isilonAccessZoneName);
// Get all NFS Export for this path access zone
HashMap<String, HashSet<Integer>> zoneNFSExports = discoverAccessZoneExports(storageSystem, isilonAccessZoneName);
do {
HashMap<String, Object> discoverdFileDetails = discoverAllFileSystem(storageSystem, resumeToken, umfsDiscoverPath);
IsilonApi.IsilonList<FileShare> discoveredIsilonFS = (IsilonApi.IsilonList<FileShare>) discoverdFileDetails.get(UMFS_DETAILS);
ArrayList<UnManagedFileQuotaDirectory> discoveredUmfsQd = (ArrayList<UnManagedFileQuotaDirectory>) discoverdFileDetails.get(UMFSQD_DETAILS);
HashMap<String, HashSet<String>> umfsfileQuotaMap = (HashMap<String, HashSet<String>>) discoverdFileDetails.get(UMFS_QD_MAP);
resumeToken = discoveredIsilonFS.getToken();
discoveredFS = discoveredIsilonFS.getList();
totalIsilonFSDiscovered += discoveredFS.size();
for (FileShare fs : discoveredFS) {
if (!checkStorageFileSystemExistsInDB(fs.getNativeGuid())) {
// Create UnManaged FS
String fsPathName = fs.getPath();
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fs.getNativeGuid());
if (unManagedFs != null) {
existingUnManagedFileSystems.add(unManagedFs);
}
// get the matched vNAS Server
NASServer nasServer = getMatchedNASServer(nasServers, fsPathName);
if (nasServer != null) {
// Get valid storage port from the NAS server!!!
_log.info("fs path {} and nas server details {}", fs.getPath(), nasServer.toString());
storagePort = getStoragePortFromNasServer(nasServer);
if (storagePort == null) {
_log.info("No valid storage port found for nas server {}", nasServer.toString());
continue;
}
} else {
_log.info("fs path {} and vnas server not found", fs.getPath());
// Skip further ingestion steps on this file share & move to next file share
continue;
}
unManagedFs = createUnManagedFileSystem(unManagedFs, fs.getNativeGuid(), storageSystem, storagePool, nasServer, fs);
unManagedFs.setHasNFSAcl(false);
newUnManagedFileSystems.add(unManagedFs);
/**
* Set and create the NFS ACLs only if the system is enabled with NFSv4!!!
*/
HashMap<String, HashSet<Integer>> exportWithIdMap = getExportsIncludingSubDir(fs.getPath(), zoneNFSExports, umfsfileQuotaMap);
if (isNfsV4Enabled) {
Set<String> fsExportPaths = exportWithIdMap.keySet();
setUnmanagedNfsShareACL(unManagedFs, storageSystem, isilonApi, fsExportPaths, newUnManagedNfsShareACLList, oldUnManagedNfsShareACLList);
}
/**
* Set and Create Export Rules and export Map
*/
if (!exportWithIdMap.keySet().isEmpty()) {
setUnManagedFSExportMap(unManagedFs, exportWithIdMap, storagePort, fs.getPath(), nasServer.getNasName(), isilonApi, storageSystem, newUnManagedExportRules, oldUnManagedExportRules);
_log.info("Number of exports discovered for file system {} is {}", unManagedFs.getId(), newUnManagedExportRules.size());
if (!newUnManagedExportRules.isEmpty()) {
unManagedFs.setHasExports(true);
_log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), newUnManagedExportRules.size());
}
}
/**
* Create and set CIFS ACLS and SMB Share MAP
*/
HashSet<String> shareIDs = getSharesIncludingSubDir(fs.getPath(), zoneSMBShares, umfsfileQuotaMap);
setUnmanagedCifsShareACL(unManagedFs, shareIDs, newUnManagedCifsShareACLList, storagePort, fs.getName(), nasServer.getNasName(), storageSystem, isilonApi, oldUnManagedCifsShareACLList);
_log.info("Number of shares ACLs discovered for file system {} is {}", unManagedFs.getId(), newUnManagedCifsShareACLList.size());
if (unManagedFs.getHasExports() || unManagedFs.getHasShares()) {
_log.info("FS {} is having exports/shares", fs.getPath());
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
} else {
_log.info("FS {} does not have export or share", fs.getPath());
}
/**
* Persist 200 objects and clear them to avoid memory issue
*/
// save bunch of export rules in db
validateSizeLimitAndPersist(newUnManagedExportRules, oldUnManagedExportRules, Constants.DEFAULT_PARTITION_SIZE * 2);
// save bunch of ACLs in db
validateSizeLimitAndPersist(newUnManagedCifsShareACLList, oldUnManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
// save bunch of NFS ACLs in db
validateSizeLimitAndPersist(newUnManagedNfsShareACLList, newUnManagedNfsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
// save bunch of file system in db
validateListSizeLimitAndPersist(newUnManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
}
}
for (UnManagedFileQuotaDirectory umfsQd : discoveredUmfsQd) {
if (!checkStorageQuotaDirectoryExistsInDB(umfsQd.getNativeGuid())) {
String fsUnManagedQdNativeGuid = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), umfsQd.getNativeId(), "");
UnManagedFileQuotaDirectory unManagedFileQd = checkUnManagedFileSystemQuotaDirectoryExistsInDB(fsUnManagedQdNativeGuid);
boolean umfsQdExists = (unManagedFileQd == null) ? false : true;
if (umfsQdExists) {
umfsQd.setId(unManagedFileQd.getId());
existingUnManagedFileQuotaDir.add(umfsQd);
} else if (null != umfsQd) {
umfsQd.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
newUnManagedFileQuotaDir.add(umfsQd);
}
}
}
// save bunch of QDs in db
validateSizeLimitAndPersist(newUnManagedFileQuotaDir, existingUnManagedFileQuotaDir, Constants.DEFAULT_PARTITION_SIZE * 2);
} while (resumeToken != null);
}
// Saving bunch of Unmanaged objects!!!
if (!newUnManagedExportRules.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.createObject(newUnManagedExportRules);
newUnManagedExportRules.clear();
}
if (!oldUnManagedExportRules.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.updateObject(newUnManagedExportRules);
oldUnManagedExportRules.clear();
}
// save ACLs in db
if (!newUnManagedCifsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedCifsShareACL(s) {}", newUnManagedCifsShareACLList.size());
_dbClient.createObject(newUnManagedCifsShareACLList);
newUnManagedCifsShareACLList.clear();
}
// save old acls
if (!oldUnManagedCifsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", oldUnManagedCifsShareACLList.size());
_dbClient.updateObject(oldUnManagedCifsShareACLList);
oldUnManagedCifsShareACLList.clear();
}
// save NFS ACLs in db
if (!newUnManagedNfsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedNfsShareACL(s) {}", newUnManagedNfsShareACLList.size());
_dbClient.createObject(newUnManagedNfsShareACLList);
newUnManagedNfsShareACLList.clear();
}
// save old acls
if (!oldUnManagedNfsShareACLList.isEmpty()) {
_log.info("Saving Number of NFS UnManagedFileExportRule(s) {}", oldUnManagedNfsShareACLList.size());
_dbClient.updateObject(oldUnManagedNfsShareACLList);
oldUnManagedNfsShareACLList.clear();
}
// save new QDs to DB
if (!newUnManagedFileQuotaDir.isEmpty()) {
_log.info("New unmanaged Isilon file systems QuotaDirecotry count: {}", newUnManagedFileQuotaDir.size());
_dbClient.createObject(newUnManagedFileQuotaDir);
}
// save old QDs
if (!existingUnManagedFileQuotaDir.isEmpty()) {
_log.info("Update unmanaged Isilon file systems QuotaDirectory count: {}", existingUnManagedFileQuotaDir.size());
_dbClient.updateObject(existingUnManagedFileQuotaDir);
}
// save new FS
if (!newUnManagedFileSystems.isEmpty()) {
_dbClient.createObject(newUnManagedFileSystems);
}
// save old FS
if (!existingUnManagedFileSystems.isEmpty()) {
_dbClient.updateObject(existingUnManagedFileSystems);
}
_log.info("Discovered {} Isilon file systems.", totalIsilonFSDiscovered);
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Isilon: %s; new unmanaged file systems count: %s", storageSystemId.toString(), unmanagedFsCount);
_log.info(detailedStatusMessage);
} catch (IsilonException ex) {
detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), ex.getLocalizedMessage());
_log.error(detailedStatusMessage, ex);
throw ex;
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_log.error(detailedStatusMessage, e);
throw new IsilonCollectionException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.isilon.restapi.IsilonAccessZone in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAllFileSystem.
private HashMap<String, Object> discoverAllFileSystem(StorageSystem storageSystem, String resumetoken, String umfsDiscoverPath) {
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverAllFileSystem for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
List<IsilonAccessZone> accessZones = isilonApi.getAccessZones(null);
List<String> tempAccessZonePath = new ArrayList<>();
for (IsilonAccessZone accessZone : accessZones) {
if (!accessZone.isSystem()) {
tempAccessZonePath.add(accessZone.getPath() + "/");
}
}
HashSet<String> fsPathSet = new HashSet<>();
HashSet<String> fsQuotaPathSet = new HashSet<>();
HashMap<String, IsilonSmartQuota> tempQuotaMap = new HashMap<>();
IsilonApi.IsilonList<FileShare> isilonFSList = new IsilonApi.IsilonList<>();
int accessZoneDiscPathLength = computeCustomConfigPathLengths(umfsDiscoverPath);
IsilonApi.IsilonList<IsilonSmartQuota> quotas = isilonApi.listQuotas(resumetoken, umfsDiscoverPath);
isilonFSList.setToken(quotas.getToken());
for (IsilonSmartQuota quota : quotas.getList()) {
if (quota.getType().compareTo("directory") != 0) {
_log.debug("ignore quota path {} with quota id {}:", quota.getPath(), quota.getId() + " and quota type" + quota.getType());
continue;
}
if ("/ifs/".equals(umfsDiscoverPath) && isQuotaUnderAccessZonePath(quota.getPath(), tempAccessZonePath)) {
continue;
}
String fsNativeId = quota.getPath();
if (isUnderUnmanagedDiscoveryPath(fsNativeId)) {
int fsPathType = isQuotaOrFile(fsNativeId, accessZoneDiscPathLength);
if (fsPathType == PATH_IS_FILE) {
tempQuotaMap.put(quota.getPath(), quota);
fsPathSet.add(fsNativeId);
}
if (fsPathType == PATH_IS_QUOTA) {
tempQuotaMap.put(quota.getPath(), quota);
fsQuotaPathSet.add(fsNativeId);
}
}
}
/*
* Associate Quota directories with correct File paths
*/
HashMap<String, Set<String>> fileQuotas = new HashMap<>();
for (String filePath : fsPathSet) {
HashSet<String> qdPaths = new HashSet<>();
for (String qdPath : fsQuotaPathSet) {
if (qdPath.startsWith(filePath + "/")) {
qdPaths.add(qdPath);
}
}
if (!qdPaths.isEmpty()) {
fsQuotaPathSet.removeAll(qdPaths);
fileQuotas.put(filePath, qdPaths);
}
}
HashMap<String, FileShare> fsWithQuotaMap = new HashMap<>();
HashMap<String, UnManagedFileQuotaDirectory> qdMap = new HashMap<>();
for (String fsNativeId : fsPathSet) {
IsilonSmartQuota fileFsQuota = tempQuotaMap.get(fsNativeId);
FileShare fs = extractFileShare(fsNativeId, fileFsQuota, storageSystem);
_log.debug("quota id {} with capacity {}", fsNativeId + ":QUOTA:" + fileFsQuota.getId(), fs.getCapacity() + " used capacity " + fs.getUsedCapacity());
fsWithQuotaMap.put(fsNativeId, fs);
Set<String> fsQuotaIds = fileQuotas.get(fsNativeId);
if (null != fsQuotaIds) {
for (String quotaNativeId : fsQuotaIds) {
IsilonSmartQuota qdQuota = tempQuotaMap.get(quotaNativeId);
if (null != qdQuota) {
UnManagedFileQuotaDirectory qd = getUnManagedFileQuotaDirectory(fs.getNativeGuid(), qdQuota, storageSystem);
qdMap.put(quotaNativeId, qd);
}
}
}
}
List<FileShare> discoveredFS = new ArrayList<>();
discoveredFS.addAll(fsWithQuotaMap.values());
isilonFSList.addList(discoveredFS);
List<UnManagedFileQuotaDirectory> discoverdQuotaDirectory = new ArrayList<>();
discoverdQuotaDirectory.addAll(qdMap.values());
HashMap<String, Object> discoveredFileDetails = new HashMap<>();
discoveredFileDetails.put(UMFS_DETAILS, isilonFSList);
discoveredFileDetails.put(UMFSQD_DETAILS, discoverdQuotaDirectory);
discoveredFileDetails.put(UMFS_QD_MAP, fileQuotas);
return discoveredFileDetails;
} catch (IsilonException ie) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, ie);
throw ie;
} catch (Exception e) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllFileSystem failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonAccessZone in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAccessZones.
/**
* discover the access zone and add to vipr db
*
* @param storageSystem
*/
private void discoverAccessZones(StorageSystem storageSystem) {
URI storageSystemId = storageSystem.getId();
VirtualNAS virtualNAS = null;
PhysicalNAS physicalNAS = null;
List<VirtualNAS> newvNASList = new ArrayList<VirtualNAS>();
List<VirtualNAS> existingvNASList = new ArrayList<VirtualNAS>();
List<PhysicalNAS> newPhysicalNASList = new ArrayList<PhysicalNAS>();
List<PhysicalNAS> existingPhysicalNASList = new ArrayList<PhysicalNAS>();
List<VirtualNAS> discoveredVNASList = new ArrayList<VirtualNAS>();
// Discover storage ports
try {
_log.info("discoverAccessZones for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
// Make restapi call to get access zones
List<IsilonAccessZone> accessZoneList = isilonApi.getAccessZones(null);
if (accessZoneList == null || accessZoneList.isEmpty()) {
// No access zones defined. Throw an exception and fail the discovery
IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. No Zones defined");
throw ice;
}
// Find the smart connect zones
List<IsilonNetworkPool> isilonNetworkPoolsSysAZ = new ArrayList<>();
// get the system access zone and use it later
List<IsilonNetworkPool> isilonNetworkPoolList = discoverNetworkPools(storageSystem);
for (IsilonNetworkPool isilonNetworkPool : isilonNetworkPoolList) {
if (isilonNetworkPool.getAccess_zone().equalsIgnoreCase(SYSTEM_ACCESS_ZONE_NAME)) {
isilonNetworkPoolsSysAZ.add(isilonNetworkPool);
}
}
// set the protocol based storagesystem version
// by default all version support CIFS and version above 7.2 NFS also
StringSet protocols = new StringSet();
protocols.add(CIFS);
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
protocols.add(NFS);
if (isNfsV4Enabled) {
protocols.add(NFSv4);
}
}
List<IsilonNetworkPool> isilonNetworkPools = null;
// process the access zones list
for (IsilonAccessZone isilonAccessZone : accessZoneList) {
// add protocol to NAS servers
// is it a System access zone?
isilonNetworkPools = null;
if (isilonAccessZone.isSystem() == false) {
_log.info("Process the user defined access zone {} ", isilonAccessZone.toString());
isilonNetworkPools = new ArrayList<IsilonNetworkPool>();
// get the smart connect zone information
for (IsilonNetworkPool eachNetworkPool : isilonNetworkPoolList) {
if (eachNetworkPool.getAccess_zone().equalsIgnoreCase(isilonAccessZone.getName())) {
isilonNetworkPools.add(eachNetworkPool);
}
}
// find virtualNAS in db
virtualNAS = findvNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (virtualNAS == null) {
if (isilonNetworkPools != null && !isilonNetworkPools.isEmpty()) {
virtualNAS = createVirtualNas(storageSystem, isilonAccessZone);
newvNASList.add(virtualNAS);
}
} else {
copyUpdatedPropertiesInVNAS(storageSystem, isilonAccessZone, virtualNAS);
existingvNASList.add(virtualNAS);
}
// Set authentication providers
setCifsServerMapForNASServer(isilonAccessZone, virtualNAS);
// set protocol support
if (virtualNAS != null) {
virtualNAS.setProtocols(protocols);
}
// set the smart connect
setStoragePortsForNASServer(isilonNetworkPools, storageSystem, virtualNAS);
} else {
_log.info("Process the System access zone {} ", isilonAccessZone.toString());
// set protocols
StringSet protocolSet = new StringSet();
protocolSet.add(CIFS);
protocolSet.add(NFS);
if (isNfsV4Enabled) {
protocolSet.add(NFSv4);
}
physicalNAS = findPhysicalNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (physicalNAS == null) {
physicalNAS = createPhysicalNas(storageSystem, isilonAccessZone);
physicalNAS.setProtocols(protocolSet);
// add system access zone
newPhysicalNASList.add(physicalNAS);
} else {
setMaxDbMetricsAz(storageSystem, physicalNAS.getMetrics());
existingPhysicalNASList.add(physicalNAS);
}
// Set authentication providers
setCifsServerMapForNASServer(isilonAccessZone, physicalNAS);
// set the smart connect zone
setStoragePortsForNASServer(isilonNetworkPoolsSysAZ, storageSystem, physicalNAS);
}
}
// Persist the vNAS servers and
if (newvNASList != null && !newvNASList.isEmpty()) {
// add the parent system access zone to user defined access zones
if (physicalNAS != null) {
for (VirtualNAS vNas : newvNASList) {
// set the parent uri or system access zone uri to vNAS
vNas.setParentNasUri(physicalNAS.getId());
}
}
_log.info("New Virtual NAS servers size {}", newvNASList.size());
_dbClient.createObject(newvNASList);
discoveredVNASList.addAll(newvNASList);
}
if (existingvNASList != null && !existingvNASList.isEmpty()) {
_log.info("Modified Virtual NAS servers size {}", existingvNASList.size());
_dbClient.updateObject(existingvNASList);
discoveredVNASList.addAll(existingvNASList);
}
// Persist the NAS servers!!!
if (existingPhysicalNASList != null && !existingPhysicalNASList.isEmpty()) {
_log.info("Modified Physical NAS servers size {}", existingPhysicalNASList.size());
_dbClient.updateObject(existingPhysicalNASList);
}
if (newPhysicalNASList != null && !newPhysicalNASList.isEmpty()) {
_log.info("New Physical NAS servers size {}", newPhysicalNASList.size());
_dbClient.createObject(newPhysicalNASList);
}
DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNASList, _dbClient, storageSystemId);
} catch (Exception e) {
_log.error("discoverAccessZones failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. Storage system: " + storageSystemId);
throw ice;
}
}
Aggregations