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;
}
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;
}
Aggregations