use of com.emc.storageos.hds.model.StoragePoolTier in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method processStoragePoolTiersInfo.
private void processStoragePoolTiersInfo(StorageSystem system, Pool pool) {
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, pool.getObjectID(), NativeGUIDGenerator.POOL);
URIQueryResultList uriQueryResult = new URIQueryResultList();
Set<String> tiersSet = new HashSet<String>();
List<StorageTier> newTiers = new ArrayList<StorageTier>();
List<StorageTier> updateTiers = new ArrayList<StorageTier>();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), uriQueryResult);
StoragePool poolInDb = null;
if (uriQueryResult.iterator().hasNext()) {
poolInDb = _dbClient.queryObject(StoragePool.class, uriQueryResult.iterator().next());
if (null == poolInDb) {
return;
}
}
for (StoragePoolTier tier : pool.getTiers()) {
String tierNativeGuid = NativeGUIDGenerator.generateStorageTierNativeGuidForHDSTier(system, poolInDb.getNativeId(), tier.getTierID());
StorageTier storageTier = checkStorageTierExistsInDB(tierNativeGuid);
if (null == storageTier) {
storageTier = new StorageTier();
storageTier.setId(URIUtil.createId(StorageTier.class));
storageTier.setDiskDriveTechnology(tier.getDiskType());
storageTier.setLabel(tier.getObjectID());
storageTier.setNativeGuid(tierNativeGuid);
storageTier.setStorageDevice(system.getId());
storageTier.setTotalCapacity(Long.parseLong(tier.getCapacityInKB()));
newTiers.add(storageTier);
}
// @TODO check whether we are getting the right percentage.
storageTier.setPercentage(tier.getUsageRate());
tiersSet.add(storageTier.getId().toString());
updateTiers.add(storageTier);
}
_dbClient.createObject(newTiers);
_dbClient.persistObject(updateTiers);
poolInDb.addTiers(tiersSet);
_dbClient.persistObject(poolInDb);
}
Aggregations