Search in sources :

Example 36 with UnManagedFileSystem

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem 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 37 with UnManagedFileSystem

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem 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 38 with UnManagedFileSystem

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedFileSystems.

public void discoverUnManagedFileSystems(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedFilesystems for system {}", accessProfile.getSystemId());
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
    unManagedFilesystemsInsert = new ArrayList<UnManagedFileSystem>();
    unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
    List<VNXeFileSystem> filesystems = apiClient.getAllFileSystems();
    if (filesystems != null && !filesystems.isEmpty()) {
        Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
        for (VNXeFileSystem fs : filesystems) {
            StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
            StoragePool pool = getStoragePoolOfUnManagedObject(fs.getPool().getId(), storageSystem, pools);
            if (null == pool) {
                log.error("Skipping unmanaged volume discovery as the file system {} storage pool doesn't exist in ViPR", fs.getId());
                continue;
            }
            if (checkStorageFileSystemExistsInDB(fsNativeGuid, dbClient)) {
                log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGuid);
                continue;
            }
            // Create UnManaged FS
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getId());
            UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(dbClient, fsUnManagedFsNativeGuid);
            unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs, dbClient);
            unManagedFilesystemsReturnedFromProvider.add(unManagedFs.getId());
        }
        if (!unManagedFilesystemsInsert.isEmpty()) {
            // Add UnManagedFileSystem
            partitionManager.insertInBatches(unManagedFilesystemsInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
        }
        if (!unManagedFilesystemsUpdate.isEmpty()) {
            // Update UnManagedFilesystem
            partitionManager.updateAndReIndexInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to
        // mark them inactive.
        performStorageUnManagedFSBookKeeping(storageSystem, dbClient, partitionManager);
    } else {
        log.info("There are no file systems found on the system: {}", storageSystem.getId());
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 39 with UnManagedFileSystem

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method checkUnManagedFileSystemExistsInDB.

/**
 * check Pre Existing Storage filesystem exists in DB
 *
 * @param nativeGuid
 * @return unManageFileSystem
 * @throws IOException
 */
protected UnManagedFileSystem checkUnManagedFileSystemExistsInDB(DbClient dbClient, String nativeGuid) throws IOException {
    UnManagedFileSystem filesystemInfo = null;
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemInfoNativeGUIdConstraint(nativeGuid), result);
    Iterator<URI> iter = result.iterator();
    while (iter.hasNext()) {
        URI unFileSystemtURI = iter.next();
        filesystemInfo = dbClient.queryObject(UnManagedFileSystem.class, unFileSystemtURI);
        return filesystemInfo;
    }
    return filesystemInfo;
}
Also used : URI(java.net.URI) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 40 with UnManagedFileSystem

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method createUnManagedFileSystem.

/**
 * create StorageFileSystem Info Object
 *
 * @param unManagedFileSystem
 * @param unManagedFileSystemNativeGuid
 * @param system
 * @param pool
 * @param storagePort
 * @param fileSystem
 * @return UnManagedFileSystem
 */
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, String unManagedFileSystemNativeGuid, StorageSystem system, StoragePool pool, StoragePort storagePort, VNXeFileSystem fileSystem, DbClient dbClient) {
    boolean created = false;
    if (null == unManagedFileSystem) {
        unManagedFileSystem = new UnManagedFileSystem();
        unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
        unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
        unManagedFileSystem.setStorageSystemUri(system.getId());
        unManagedFileSystem.setStoragePoolUri(pool.getId());
        unManagedFileSystem.setHasExports(false);
        unManagedFileSystem.setHasShares(false);
        created = true;
    }
    Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
    StringMap unManagedFileSystemCharacteristics = new StringMap();
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), Boolean.FALSE.toString());
    if (fileSystem.getIsThinEnabled()) {
        unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), Boolean.TRUE.toString());
    } else {
        unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), Boolean.FALSE.toString());
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.FALSE.toString());
    if (null != system) {
        StringSet systemTypes = new StringSet();
        systemTypes.add(system.getSystemType());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
    }
    if (null != pool) {
        StringSet pools = new StringSet();
        pools.add(pool.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
        StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, pool.getId(), unManagedFileSystemCharacteristics.get(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString()));
        log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
        if (null == matchedVPools || matchedVPools.isEmpty()) {
            // clear all existing supported vpools.
            unManagedFileSystem.getSupportedVpoolUris().clear();
        } else {
            // replace with new StringSet
            unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
            log.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
        }
    }
    if (null != storagePort) {
        StringSet storagePorts = new StringSet();
        storagePorts.add(storagePort.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
    // Set attributes of FileSystem
    StringSet fsPath = new StringSet();
    fsPath.add("/" + fileSystem.getName());
    StringSet fsMountPath = new StringSet();
    fsMountPath.add("/" + fileSystem.getName());
    StringSet fsName = new StringSet();
    fsName.add(fileSystem.getName());
    StringSet fsId = new StringSet();
    fsId.add(fileSystem.getId() + "");
    unManagedFileSystem.setLabel(fileSystem.getName());
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAME.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NATIVE_ID.toString(), fsId);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PATH.toString(), fsPath);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
    StringSet allocatedCapacity = new StringSet();
    String usedCapacity = String.valueOf(fileSystem.getSizeAllocated());
    allocatedCapacity.add(usedCapacity);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    StringSet provisionedCapacity = new StringSet();
    String capacity = String.valueOf(fileSystem.getSizeTotal());
    provisionedCapacity.add(capacity);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
    // Add fileSystemInformation and Characteristics.
    unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
    unManagedFileSystem.setFileSystemCharacterstics(unManagedFileSystemCharacteristics);
    if (created) {
        unManagedFilesystemsInsert.add(unManagedFileSystem);
    } else {
        unManagedFilesystemsUpdate.add(unManagedFileSystem);
    }
    return unManagedFileSystem;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Aggregations

UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)48 URI (java.net.URI)27 ArrayList (java.util.ArrayList)27 HashMap (java.util.HashMap)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)21 IOException (java.io.IOException)21 StoragePort (com.emc.storageos.db.client.model.StoragePort)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 StringMap (com.emc.storageos.db.client.model.StringMap)18 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 StringSet (com.emc.storageos.db.client.model.StringSet)14 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)12 HashSet (java.util.HashSet)12 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)11 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)10 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)10 Map (java.util.Map)10 StoragePool (com.emc.storageos.db.client.model.StoragePool)9