use of com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddModifyExports.
private void ddModifyExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> modifyFileExports) {
for (FileExport fileExport : modifyFileExports) {
fileExport.setNativeId(exportMap.get(fileExport.getFileExportKey()).getNativeId());
List<DDExportClientModify> ddExportClients = ddBuildModifyExportClientList(exportMap, fileExport);
DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, fileExport.getNativeId());
if (ddExport.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExport.getId());
throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(ddExport.getPath());
} else {
DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, fileExport.getNativeId(), ddExportClients);
FileExport existingExport = exportMap.get(fileExport.getFileExportKey());
ddSetExistingExportProperties(existingExport, fileExport, ddExportInfo);
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail 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.DDExportInfoDetail 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.DDExportInfoDetail 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);
}
}
use of com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddDeleteExports.
private void ddDeleteExports(DataDomainClient ddClient, String storagePoolId, FSExportMap currentExports, List<FileExport> exportsToDelete) {
if ((currentExports != null && (exportsToDelete != null) && (!exportsToDelete.isEmpty()))) {
for (FileExport fileExport : exportsToDelete) {
String key = fileExport.getFileExportKey();
String ddExportId = null;
FileExport fExport = currentExports.get(key);
if (fExport != null) {
ddExportId = fExport.getNativeId();
}
if (ddExportId != null) {
DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, ddExportId);
if (ddExport.getPathStatus() == DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportId);
}
}
}
}
}
Aggregations