use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method getUnManagedFileQuotaDirectory.
private UnManagedFileQuotaDirectory getUnManagedFileQuotaDirectory(String fsNativeGuid, IsilonSmartQuota quota, StorageSystem storageSystem) {
String qdNativeId = quota.getPath();
_log.debug("Converting IsilonSmartQuota {} for fileSystem {}", quota.getPath(), fsNativeGuid);
int softLimit = 0;
int softGrace = 0;
int notificationLimit = 0;
String nativeGuid = null;
UnManagedFileQuotaDirectory umfsQd = new UnManagedFileQuotaDirectory();
StringMap extensionsMap = new StringMap();
String[] tempDirNames = qdNativeId.split("/");
umfsQd.setParentFSNativeGuid(fsNativeGuid);
umfsQd.setLabel(tempDirNames[tempDirNames.length - 1]);
try {
nativeGuid = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), qdNativeId, "");
} catch (IOException e) {
_log.error("Exception while generating NativeGuid for UnManagedQuotaDirectory", e);
}
umfsQd.setNativeGuid(nativeGuid);
umfsQd.setNativeId(qdNativeId);
long capacity = 0;
if (quota.getThresholds() != null && quota.getThresholds().getHard() != null) {
capacity = quota.getThresholds().getHard();
}
umfsQd.setSize(capacity);
if (null != quota.getThresholds().getSoft() && capacity != 0) {
softLimit = new Long(quota.getThresholds().getSoft() * 100 / capacity).intValue();
}
if (null != quota.getThresholds().getSoftGrace() && capacity != 0) {
softGrace = new Long(quota.getThresholds().getSoftGrace() / (24 * 60 * 60)).intValue();
}
if (null != quota.getThresholds().getAdvisory() && capacity != 0) {
notificationLimit = new Long(quota.getThresholds().getAdvisory() * 100 / capacity).intValue();
}
if (null != quota.getId()) {
extensionsMap.put(QUOTA, quota.getId());
}
umfsQd.setSoftLimit(softLimit);
umfsQd.setSoftGrace(softGrace);
umfsQd.setNotificationLimit(notificationLimit);
umfsQd.setExtensions(extensionsMap);
return umfsQd;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method checkUnManagedQuotaDirectoryExistsInDB.
private UnManagedFileQuotaDirectory checkUnManagedQuotaDirectoryExistsInDB(String nativeGuid) throws IOException {
UnManagedFileQuotaDirectory umfsQd = null;
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedFileQuotaDirectoryInfoNativeGUIdConstraint(nativeGuid), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
URI unManagedFSQDUri = iter.next();
umfsQd = _dbClient.queryObject(UnManagedFileQuotaDirectory.class, unManagedFSQDUri);
return umfsQd;
}
return umfsQd;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface method checkUnManagedQuotaDirectoryExistsInDB.
private UnManagedFileQuotaDirectory checkUnManagedQuotaDirectoryExistsInDB(String nativeGuid) throws IOException {
UnManagedFileQuotaDirectory umfsQd = null;
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedFileQuotaDirectoryInfoNativeGUIdConstraint(nativeGuid), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
URI unManagedFSQDUri = iter.next();
umfsQd = _dbClient.queryObject(UnManagedFileQuotaDirectory.class, unManagedFSQDUri);
return umfsQd;
}
return umfsQd;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverUmanagedFileQuotaDirectory.
private void discoverUmanagedFileQuotaDirectory(AccessProfile profile, StringSet umfsIds) throws Exception {
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
try {
Map<String, Object> reqAttributeMap = getRequestParamsMap(storageSystem);
reqAttributeMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
_discExecutor.setKeyMap(reqAttributeMap);
// Retrieve all the qtree info.
List<TreeQuota> qtrees = getAllQuotaTrees(storageSystem);
if (null != qtrees && !qtrees.isEmpty()) {
List<UnManagedFileQuotaDirectory> unManagedFileQuotaDirectories = new ArrayList<>();
List<UnManagedFileQuotaDirectory> existingUnManagedFileQuotaDirectories = new ArrayList<>();
for (TreeQuota quotaTree : qtrees) {
String fsNativeId;
// Process the QD's only of unmanaged file systems.
if (!umfsIds.contains(quotaTree.getFileSystem())) {
continue;
}
String qdName = "";
if (quotaTree.getPath() != null) {
// Ignore / from QD path
qdName = quotaTree.getPath().substring(1);
}
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quotaTree.getFileSystem() + "");
String nativeGUID = NativeGUIDGenerator.generateNativeGuidForQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), qdName, quotaTree.getFileSystem() + "");
String nativeUnmanagedGUID = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), qdName, quotaTree.getFileSystem() + "");
if (checkStorageQuotaDirectoryExistsInDB(nativeGUID)) {
continue;
}
UnManagedFileQuotaDirectory tempUnManagedFileQuotaDirectory = checkUnManagedQuotaDirectoryExistsInDB(nativeUnmanagedGUID);
boolean unManagedFileQuotaDirectoryExists = tempUnManagedFileQuotaDirectory == null ? false : true;
UnManagedFileQuotaDirectory unManagedFileQuotaDirectory;
if (!unManagedFileQuotaDirectoryExists) {
unManagedFileQuotaDirectory = new UnManagedFileQuotaDirectory();
unManagedFileQuotaDirectory.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
} else {
unManagedFileQuotaDirectory = tempUnManagedFileQuotaDirectory;
}
unManagedFileQuotaDirectory.setLabel(qdName);
unManagedFileQuotaDirectory.setNativeGuid(nativeUnmanagedGUID);
unManagedFileQuotaDirectory.setParentFSNativeGuid(fsNativeGuid);
unManagedFileQuotaDirectory.setOpLock(false);
if (quotaTree.getLimits() != null) {
/*
* response is in MB, so Byte = 1024 * 1024 * response
*/
unManagedFileQuotaDirectory.setSize(Long.valueOf(quotaTree.getLimits().getSpaceHardLimit()) * BYTESCONV * BYTESCONV);
}
if (!unManagedFileQuotaDirectoryExists) {
// Set ID only for new UnManagedQuota Directory
unManagedFileQuotaDirectories.add(unManagedFileQuotaDirectory);
} else {
existingUnManagedFileQuotaDirectories.add(unManagedFileQuotaDirectory);
}
}
if (!unManagedFileQuotaDirectories.isEmpty()) {
_partitionManager.insertInBatches(unManagedFileQuotaDirectories, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILEQUOTADIR);
}
if (!existingUnManagedFileQuotaDirectories.isEmpty()) {
_partitionManager.updateAndReIndexInBatches(existingUnManagedFileQuotaDirectories, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILEQUOTADIR);
}
}
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
}
_logger.error("discovery of UMFS Quota Directory failed. Storage system: " + storageSystemId);
throw e;
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory 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);
}
}
}
}
Aggregations