use of com.emc.storageos.vnxe.models.VNXePool in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDeviceTest method setPools.
public void setPools() {
VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
List<VNXePool> pools = apiclient.getPools();
VNXePool pool = pools.get(0);
List<String> proto = new ArrayList<String>();
proto.add("CIFS");
StringSet protocols = new StringSet(proto);
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, pool.getId(), NativeGUIDGenerator.POOL);
_pool.setId(URIUtil.createId(StoragePool.class));
_pool.setLabel(poolNativeGuid);
_pool.setNativeGuid(poolNativeGuid);
_pool.setProtocols(protocols);
_pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
_pool.setPoolServiceType(PoolServiceType.block_file.toString());
_pool.setStorageDevice(_device.getId());
_pool.setNativeId(pool.getId());
_pool.setPoolName(pool.getName());
_pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
_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());
_dbClient.updateObject(_pool);
}
use of com.emc.storageos.vnxe.models.VNXePool 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 driveTypes = new StringSet();
String diskTechnologyType = null;
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());
diskTechnologyType = diskgroupObj.getDiskTechnologyEnum().name();
mapDiskTypeAndAddToStringSet(diskTechnologyType, driveTypes);
}
}
}
}
}
// Get drive types from disks
List<Disk> disks = client.getDisksForPool(vnxePool.getId());
if (disks != null) {
for (Disk disk : disks) {
if (disk.getDiskTechnologyEnum() != null) {
diskTechnologyType = disk.getDiskTechnologyEnum().name();
mapDiskTypeAndAddToStringSet(diskTechnologyType, driveTypes);
}
}
}
pool.setSupportedDriveTypes(driveTypes);
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.VNXePool 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;
}
use of com.emc.storageos.vnxe.models.VNXePool in project coprhd-controller by CoprHD.
the class PoolListRequestTest method getTest.
@Test
public void getTest() {
PoolListRequest req = new PoolListRequest(_client);
List<VNXePool> list = req.get();
for (VNXePool pool : list) {
Integer raidLevel = pool.getRaidType();
System.out.print(pool.getRaidTypeEnum().name());
String name = pool.getName();
System.out.println(name);
System.out.println(raidLevel);
List<PoolTier> tiers = pool.getTiers();
for (PoolTier tier : tiers) {
long size = tier.getSizeTotal();
System.out.println("total size:");
System.out.println(size);
}
}
System.out.println(list.size());
}
use of com.emc.storageos.vnxe.models.VNXePool in project coprhd-controller by CoprHD.
the class ApiClientTest method getPools.
// @Test
public void getPools() {
List<VNXePool> pools = apiClient.getPools();
System.out.println(pools.size());
for (VNXePool pool : pools) {
String name = pool.getName();
System.out.println(name);
String status = pool.getStatus();
System.out.println(pool.getStatus());
}
}
Aggregations