Search in sources :

Example 1 with DiskGroup

use of com.emc.storageos.vnxe.models.DiskGroup in project coprhd-controller by CoprHD.

the class VNXUnityCommunicationInterface method discoverStoragePools.

/**
 * Returns the list of storage pools for the specified VNX Unity storage
 * system.
 *
 * @param system
 *            storage system information.
 * @param client
 *            VNX Unity service client
 * @param supportedProtocols
 *            calculated supportedProtocols for the array
 * @return Map of New and Existing known storage pools.
 * @throws VNXeException
 */
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, VNXeApiClient client, StringSet supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws VNXeException {
    Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> existingPools = new ArrayList<StoragePool>();
    _logger.info("Start storage pool discovery for storage system {}", system.getId());
    try {
        List<VNXePool> pools = client.getPools();
        for (VNXePool vnxePool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxePool.getId(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            boolean isModified = false;
            Iterator<URI> it = results.iterator();
            if (it.hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, it.next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                    _logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setPoolServiceType(PoolServiceType.block_file.toString());
                pool.setStorageDevice(system.getId());
                pool.setNativeId(vnxePool.getId());
                pool.setPoolName(vnxePool.getName());
                pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                pool.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
                // Supported resource type indicates what type of file
                // systems are supported.
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                pool.setPoolClassName(StoragePool.PoolClassNames.VNXe_Pool.name());
                pool.setPoolServiceType(StoragePool.PoolServiceType.block_file.name());
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                // update pool attributes
                _logger.info("updating the pool: {}", poolNativeGuid);
                if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), supportedProtocols)) {
                    isModified = true;
                }
                existingPools.add(pool);
            }
            Health poolHealth = vnxePool.getHealth();
            if (poolHealth != null) {
                int value = poolHealth.getValue();
                if (value == Health.HealthEnum.OK.getValue() || value == Health.HealthEnum.OK_BUT.getValue()) {
                    pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
                } else {
                    pool.setOperationalStatus(StoragePool.PoolOperationalStatus.NOTREADY.name());
                }
            }
            pool.setProtocols(supportedProtocols);
            StringSet raidLevels = new StringSet();
            RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
            if (raid != null) {
                raidLevels.add(vnxePool.getRaidTypeEnum().name());
                pool.setSupportedRaidLevels(raidLevels);
            }
            pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
            List<PoolTier> poolTiers = vnxePool.getTiers();
            StringSet diskTypes = new StringSet();
            if (poolTiers != null) {
                for (PoolTier poolTier : poolTiers) {
                    List<RaidGroup> raidGroups = poolTier.getRaidGroups();
                    if (raidGroups != null) {
                        for (RaidGroup raidGroup : raidGroups) {
                            VNXeBase diskGroup = raidGroup.getDiskGroup();
                            if (diskGroup != null) {
                                DiskGroup diskgroupObj = client.getDiskGroup(diskGroup.getId());
                                diskTypes.add(diskgroupObj.getDiskTechnologyEnum().name());
                            }
                        }
                    }
                }
            }
            // Get drive types from disks
            List<Disk> disks = client.getDisksForPool(vnxePool.getId());
            if (disks != null) {
                for (Disk disk : disks) {
                    if (disk.getDiskTechnologyEnum() != null) {
                        diskTypes.add(disk.getDiskTechnologyEnum().name());
                    }
                }
            }
            pool.setSupportedDriveTypes(diskTypes);
            double size = vnxePool.getSizeTotal();
            if (size > 0) {
                // Convert to kb
                pool.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(size));
            }
            long free = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeFree());
            if (free > 0) {
                pool.setFreeCapacity(free);
                pool.setMaximumThinVolumeSize(free);
                pool.setMaximumThickVolumeSize(free);
            }
            long subscribed = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeSubscribed());
            pool.setSubscribedCapacity(subscribed);
            if (isModified || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
                poolsToMatchWithVpool.add(pool);
            }
            pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (VNXeException e) {
        _logger.error("Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
        throw e;
    }
    for (StoragePool newPool : newPools) {
        _logger.info("New Storage Pool : " + newPool);
        _logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
    }
    for (StoragePool pool : existingPools) {
        _logger.info("Old Storage Pool : " + pool);
        _logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
    }
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    _logger.info("Number of pools found {} : ", storagePools.size());
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RaidTypeEnum(com.emc.storageos.vnxe.models.RaidTypeEnum) PoolTier(com.emc.storageos.vnxe.models.PoolTier) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) RaidGroup(com.emc.storageos.vnxe.models.RaidGroup) Disk(com.emc.storageos.vnxe.models.Disk) Health(com.emc.storageos.vnxe.models.Health) DiskGroup(com.emc.storageos.vnxe.models.DiskGroup) VNXePool(com.emc.storageos.vnxe.models.VNXePool) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 2 with DiskGroup

use of com.emc.storageos.vnxe.models.DiskGroup in project coprhd-controller by CoprHD.

the class VNXeCommunicationInterface method discoverStoragePools.

/**
 * Returns the list of storage pools for the specified VNXe storage system.
 *
 * @param system
 *            storage system information.
 * @param client
 *            VNXe service client
 * @param supportedProtocols
 *            calculated supportedProtocols for the array
 * @return Map of New and Existing known storage pools.
 * @throws VNXeException
 */
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, VNXeApiClient client, StringSet supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws VNXeException {
    Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> existingPools = new ArrayList<StoragePool>();
    _logger.info("Start storage pool discovery for storage system {}", system.getId());
    try {
        List<VNXePool> pools = client.getPools();
        for (VNXePool vnxePool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxePool.getId(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            boolean isModified = false;
            if (results.iterator().hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                    _logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setOperationalStatus(vnxePool.getStatus());
                pool.setPoolServiceType(PoolServiceType.block_file.toString());
                pool.setStorageDevice(system.getId());
                pool.setProtocols(supportedProtocols);
                pool.setNativeId(vnxePool.getId());
                pool.setPoolName(vnxePool.getName());
                pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                StringSet raidLevels = new StringSet();
                RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
                if (raid != null) {
                    raidLevels.add(vnxePool.getRaidTypeEnum().name());
                    pool.setSupportedRaidLevels(raidLevels);
                }
                // Supported resource type indicates what type of file
                // systems are supported.
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                pool.setPoolClassName(StoragePool.PoolClassNames.VNXe_Pool.name());
                pool.setPoolServiceType(StoragePool.PoolServiceType.block_file.name());
                pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                // update pool attributes
                _logger.info("updating the pool: {}", poolNativeGuid);
                pool.setOperationalStatus(vnxePool.getStatus());
                if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), supportedProtocols)) {
                    isModified = true;
                }
                pool.setProtocols(supportedProtocols);
                StringSet raidLevels = new StringSet();
                RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
                if (raid != null) {
                    raidLevels.add(vnxePool.getRaidTypeEnum().name());
                    pool.setSupportedRaidLevels(raidLevels);
                }
                pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
                existingPools.add(pool);
            }
            List<PoolTier> poolTiers = vnxePool.getTiers();
            StringSet diskTypes = new StringSet();
            for (PoolTier poolTier : poolTiers) {
                List<RaidGroup> raidGroups = poolTier.getRaidGroups();
                for (RaidGroup raidGroup : raidGroups) {
                    VNXeBase diskGroup = raidGroup.getDiskGroup();
                    if (diskGroup != null) {
                        DiskGroup diskgroupObj = client.getDiskGroup(diskGroup.getId());
                        diskTypes.add(diskgroupObj.getDiskTechnologyEnum().name());
                    }
                }
            }
            pool.setSupportedDriveTypes(diskTypes);
            double size = vnxePool.getSizeTotal();
            if (size > 0) {
                // convert to kb
                pool.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(size));
            }
            long free = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeFree());
            if (free > 0) {
                pool.setFreeCapacity(free);
                pool.setMaximumThinVolumeSize(free);
                pool.setMaximumThickVolumeSize(free);
            }
            long subscribed = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeSubscribed());
            pool.setSubscribedCapacity(subscribed);
            if (isModified || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
                poolsToMatchWithVpool.add(pool);
            }
            pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (VNXeException e) {
        _logger.error("Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
        throw e;
    }
    for (StoragePool newPool : newPools) {
        _logger.info("New Storage Pool : " + newPool);
        _logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
    }
    for (StoragePool pool : existingPools) {
        _logger.info("Old Storage Pool : " + pool);
        _logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
    }
    // return storagePools;
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    _logger.info("Number of pools found {} : ", storagePools.size());
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RaidTypeEnum(com.emc.storageos.vnxe.models.RaidTypeEnum) DiskGroup(com.emc.storageos.vnxe.models.DiskGroup) VNXePool(com.emc.storageos.vnxe.models.VNXePool) PoolTier(com.emc.storageos.vnxe.models.PoolTier) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeException(com.emc.storageos.vnxe.VNXeException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) RaidGroup(com.emc.storageos.vnxe.models.RaidGroup)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 VNXeException (com.emc.storageos.vnxe.VNXeException)2 DiskGroup (com.emc.storageos.vnxe.models.DiskGroup)2 PoolTier (com.emc.storageos.vnxe.models.PoolTier)2 RaidGroup (com.emc.storageos.vnxe.models.RaidGroup)2 RaidTypeEnum (com.emc.storageos.vnxe.models.RaidTypeEnum)2 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)2 VNXePool (com.emc.storageos.vnxe.models.VNXePool)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Disk (com.emc.storageos.vnxe.models.Disk)1 Health (com.emc.storageos.vnxe.models.Health)1 URI (java.net.URI)1