use of com.emc.storageos.datadomain.restapi.model.DDExportList in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedNewExports.
private void discoverUnManagedNewExports(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
String detailedStatusMessage = "Discovery of Data Domain Unmanaged Exports started";
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
// Used to cache UMFS once retrieved from DB
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
// Used to Save the rules to DB
List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<UnManagedFileExportRule>();
try {
// Get exports on the array and loop through each export.
DDExportList exportList = ddClient.getExports(storageSystem.getNativeGuid());
// Verification Utility
UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
for (DDExportInfo exp : exportList.getExports()) {
DDExportInfoDetail export = ddClient.getExport(storageSystem.getNativeGuid(), exp.getId());
if (export.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), export.getMtreeID());
// Get UMFS from cache if possible, otherwise try to retrieve from DB
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
// Used for rules validation
List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
if (unManagedFS != null) {
// Add UMFS to cache
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
// Build ViPR export rules from the export retrieved from the array
List<UnManagedFileExportRule> exportRules = applyAllSecurityRules(export, unManagedFS.getId());
_log.info("Number of exports discovered for file system {} is {}", unManagedFS.getId(), exportRules.size());
for (UnManagedFileExportRule dbExportRule : exportRules) {
_log.info("Un Managed File Export Rule : {}", dbExportRule);
String fsExportRulenativeId = dbExportRule.getFsExportIndex();
_log.info("Native Id using to build Native Guid {}", fsExportRulenativeId);
String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, fsExportRulenativeId);
_log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
dbExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
dbExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
// Build all export rules list.
unManagedExportRules.add(dbExportRule);
}
// apply as per API SVC Validations.
if (!unManagedExportRules.isEmpty()) {
boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
if (isAllRulesValid) {
_log.info("Validating rules success for export {}", export.getPath());
for (UnManagedFileExportRule exportRule : unManagedExportRules) {
UnManagedFileExportRule existingRule = checkUnManagedFsExportRuleExistsInDB(_dbClient, exportRule.getNativeGuid());
if (existingRule == null) {
newUnManagedExportRules.add(exportRule);
} else {
// Remove the existing rule.
existingRule.setInactive(true);
_dbClient.persistObject(existingRule);
newUnManagedExportRules.add(exportRule);
}
}
unManagedFS.setHasExports(true);
unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_dbClient.persistObject(unManagedFS);
_log.info("File System {} has Exports and their size is {}", unManagedFS.getId(), newUnManagedExportRules.size());
} else {
_log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", export.getPath());
// Don't consider the file system with invalid exports!!!
unManagedFS.setInactive(true);
}
}
// Adding this additional logic to avoid OOM
if (newUnManagedExportRules.size() == MAX_UMFS_RECORD_SIZE) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.persistObject(newUnManagedExportRules);
newUnManagedExportRules.clear();
}
} else {
_log.info("FileSystem " + fsUnManagedFsNativeGuid + " is not present in ViPR DB. Hence ignoring " + export + " export");
}
}
if (!newUnManagedExportRules.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(newUnManagedExportRules);
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(existingUnManagedFileSystems.values());
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeded
detailedStatusMessage = String.format("Discovery completed successfully for Data Domain: %s", storageSystem.getId().toString());
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
} catch (DataDomainApiException dde) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId());
} catch (Exception e) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId(), e);
} finally {
if (storageSystem != null) {
try {
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDExportList in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedExports.
private void discoverUnManagedExports(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
try {
List<StoragePort> ports = getPortFromDB(storageSystem);
// Get exports on the array and loop through each export.
DDExportList exportList = ddClient.getExports(storageSystem.getNativeGuid());
for (DDExportInfo exp : exportList.getExports()) {
DDExportInfoDetail export = ddClient.getExport(storageSystem.getNativeGuid(), exp.getId());
if (export.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), export.getMtreeID());
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
if (unManagedFS != null) {
createExportMap(export, unManagedFS, ports);
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
// Adding this additional logic to avoid OOM
if (existingUnManagedFileSystems.size() == MAX_UMFS_RECORD_SIZE) {
_dbClient.persistObject(new ArrayList<UnManagedFileSystem>(existingUnManagedFileSystems.values()));
existingUnManagedFileSystems.clear();
}
} else {
_log.info("FileSystem " + fsUnManagedFsNativeGuid + " is not present in ViPR DB. Hence ignoring " + export + " export");
}
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(new ArrayList<UnManagedFileSystem>(existingUnManagedFileSystems.values()));
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setLastDiscoveryStatusMessage("");
_dbClient.persistObject(storageSystem);
} catch (DataDomainApiException dde) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString());
throw dde;
} catch (Exception e) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
}
}
Aggregations