Search in sources :

Example 1 with DDExportInfoDetail

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);
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) FileExport(com.emc.storageos.db.client.model.FileExport) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 2 with DDExportInfoDetail

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());
                }
            }
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 3 with DDExportInfoDetail

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);
            }
        }
    }
}
Also used : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) HashMap(java.util.HashMap) DDExportList(com.emc.storageos.datadomain.restapi.model.DDExportList) ArrayList(java.util.ArrayList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Example 4 with DDExportInfoDetail

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);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) HashMap(java.util.HashMap) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) DDExportList(com.emc.storageos.datadomain.restapi.model.DDExportList) StoragePort(com.emc.storageos.db.client.model.StoragePort) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException)

Example 5 with DDExportInfoDetail

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);
                }
            }
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) FileExport(com.emc.storageos.db.client.model.FileExport)

Aggregations

DDExportInfoDetail (com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail)5 DDExportInfo (com.emc.storageos.datadomain.restapi.model.DDExportInfo)4 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)2 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)2 DDExportClientModify (com.emc.storageos.datadomain.restapi.model.DDExportClientModify)2 DDExportList (com.emc.storageos.datadomain.restapi.model.DDExportList)2 DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)2 FileExport (com.emc.storageos.db.client.model.FileExport)2 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)1 ExportRule (com.emc.storageos.model.file.ExportRule)1 UnManagedExportVerificationUtility (com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility)1