Search in sources :

Example 1 with DDMTreeInfoDetail

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method discoverMtrees.

private void discoverMtrees(DataDomainClient ddClient, StorageSystem storageSystem) {
    URIQueryResultList mtreeList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFileshareConstraint(storageSystem.getId()), mtreeList);
    Iterator<URI> mtreeItr = mtreeList.iterator();
    while (mtreeItr.hasNext()) {
        FileShare mtree = _dbClient.queryObject(FileShare.class, mtreeItr.next());
        if (!mtree.getInactive()) {
            try {
                DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storageSystem.getNativeGuid(), mtree.getNativeId());
                if (mtreeInfo.quotaConfig != null) {
                    // it should be always true.
                    // We do not inject resources without quota
                    mtree.setCapacity(mtreeInfo.quotaConfig.getHardLimit());
                }
                mtree.setUsedCapacity(mtreeInfo.logicalCapacity.getUsed());
            } catch (DataDomainResourceNotFoundException ex) {
                mtree.setCapacity(0L);
            } catch (DataDomainApiException dex) {
                mtree.setCapacity(0L);
            }
        }
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) DDMTreeInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with DDMTreeInfoDetail

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method discoverUnManagedFileSystems.

private void discoverUnManagedFileSystems(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
    String detailedStatusMessage = "Discovery of DataDomain Unmanaged FileSystem started";
    List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
    StoragePool pool = getPoolFromDB(storageSystem);
    StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
    DDMTreeInfoDetail mtree = null;
    try {
        DDMTreeList mtreeList = ddClient.getMTreeList(storageSystem.getNativeGuid());
        for (DDMTreeInfo mtreeInfo : mtreeList.mtree) {
            mtree = ddClient.getMTree(storageSystem.getNativeGuid(), mtreeInfo.getId());
            if (mtree == null || mtree.delStatus == DataDomainApiConstants.FILE_DELETED) {
                continue;
            }
            // Filtering mtrees that are not supporting either of NFS & CIFS
            if ((mtree.protocolName == null) || (mtree.protocolName.isEmpty())) {
                _log.info("Mtree: {} doesn't contain any protocol defined so ignoring it", mtree.name);
                continue;
            } else {
                if ((mtree.protocolName.contains(DataDomainApiConstants.NFS_PROTOCOL)) || (mtree.protocolName.contains(DataDomainApiConstants.CIFS_PROTOCOL))) {
                    _log.info("Mtree: {} contains supported protocol:{} so discovering it", mtree.name, mtree.protocolName.toArray());
                } else {
                    _log.info("Mtree: {} contains unsupported protocol:{} so ignoring it", mtree.name, mtree.protocolName.toArray());
                    continue;
                }
            }
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
            // If the filesystem already exists in db..just continue.
            // No Need to create an UnManaged Filesystems.
            URIQueryResultList result = new URIQueryResultList();
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNativeGUIdConstraint(fsNativeGuid), result);
            if (result.iterator().hasNext()) {
                continue;
            }
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
            UnManagedFileSystem unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
            boolean alreadyExist = unManagedFS == null ? false : true;
            unManagedFS = createUnManagedFileSystem(unManagedFS, fsUnManagedFsNativeGuid, mtree, storageSystem, pool, matchedVPools);
            if (alreadyExist) {
                existingUnManagedFileSystems.add(unManagedFS);
            } else {
                newUnManagedFileSystems.add(unManagedFS);
            }
            allDiscoveredUnManagedFileSystems.add(unManagedFS.getId());
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
        markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
        if (newUnManagedFileSystems != null && !newUnManagedFileSystems.isEmpty()) {
            // Add UnManagedFileSystem
            _dbClient.createObject(newUnManagedFileSystems);
            _log.info("{} {} Records inserted to DB", newUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
        }
        if (existingUnManagedFileSystems != null && !existingUnManagedFileSystems.isEmpty()) {
            _dbClient.updateAndReindexObject(existingUnManagedFileSystems);
            _log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for DataDomain system: %s", storageSystem.getId().toString());
    } catch (DataDomainApiException dde) {
        detailedStatusMessage = "DiscoverStorage failed" + dde.getMessage();
        _log.error("discoverStorage failed.  Storage system: " + storageSystem.getId().toString());
        throw dde;
    } catch (Exception e) {
        detailedStatusMessage = "DiscoverStorage failed" + e.getMessage();
        _log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
        throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) DDMTreeList(com.emc.storageos.datadomain.restapi.model.DDMTreeList) ArrayList(java.util.ArrayList) DDMTreeInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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) DDMTreeInfo(com.emc.storageos.datadomain.restapi.model.DDMTreeInfo) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) HashSet(java.util.HashSet)

Example 3 with DDMTreeInfoDetail

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("checking file system existence on array: ", args.getFsName());
    boolean isMtreeExists = true;
    try {
        DataDomainClient ddClient = getDataDomainClient(storage);
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storagePool.getNativeId(), args.getFs().getNativeId());
        if (mtreeInfo != null && (mtreeInfo.id.equals(args.getFsNativeId()))) {
            isMtreeExists = true;
        }
    } catch (DataDomainResourceNotFoundException e) {
        _log.info("Mtree not found.", e);
        isMtreeExists = false;
    }
    return isMtreeExists;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) DDMTreeInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI)

Aggregations

DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)3 DDMTreeInfoDetail (com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail)3 URI (java.net.URI)3 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)1 DDMTreeInfo (com.emc.storageos.datadomain.restapi.model.DDMTreeInfo)1 DDMTreeList (com.emc.storageos.datadomain.restapi.model.DDMTreeList)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)1 UnManagedSMBFileShare (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1