use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method checkStorageTierExistsInDB.
/**
* Check if Storage Tier exists in DB.
*
* @param tierNativeGuid
* @param _dbClient
* @return StorageTier
* @throws IOException
*/
private StorageTier checkStorageTierExistsInDB(String tierNativeGuid) {
StorageTier tier = null;
URIQueryResultList tierQueryResult = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid), tierQueryResult);
if (tierQueryResult.iterator().hasNext()) {
tier = _dbClient.queryObject(StorageTier.class, tierQueryResult.iterator().next());
}
return tier;
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface method discoverStorageTier.
private HashMap<String, List<StorageTier>> discoverStorageTier(StorageSystem system, VNXeApiClient client) throws VNXeException {
HashMap<String, List<StorageTier>> storageTiers = new HashMap<String, List<StorageTier>>();
List<StorageTier> newTiers = new ArrayList<StorageTier>();
List<StorageTier> existingTiers = new ArrayList<StorageTier>();
List<VNXeStorageTier> tiers = client.getStorageTiers();
String systemNativeGuid = NativeGUIDGenerator.generateNativeGuid(system);
for (VNXeStorageTier tier : tiers) {
String nativeId = tier.getId();
StorageTier tierObj = null;
String tierNativeGuid = NativeGUIDGenerator.generateStorageTierNativeGuidForVmaxTier(systemNativeGuid, nativeId);
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid), results);
if (results.iterator().hasNext()) {
_logger.info("Getting the storage tier.");
StorageTier tmpTier = _dbClient.queryObject(StorageTier.class, results.iterator().next());
_logger.info(String.format("Actual StorageDevice %s : storage tier : %s", system.getId(), tmpTier.getNativeGuid()));
tierObj = tmpTier;
}
boolean isNewTier = false;
if (null == tierObj) {
tierObj = new StorageTier();
tierObj.setId(URIUtil.createId(StorageTier.class));
tierObj.setNativeGuid(tierNativeGuid);
isNewTier = true;
}
tierObj.setLabel(tier.getName());
tierObj.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(tier.getSizeTotal()));
if (isNewTier) {
newTiers.add(tierObj);
} else {
existingTiers.add(tierObj);
}
}
storageTiers.put(NEW, newTiers);
storageTiers.put(EXISTING, existingTiers);
return storageTiers;
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class AbstractFASTPolicyProcessor method addTiersToPool.
/**
* Create Storage Tiers for VNX, if not present already
* Add Tier Uris to Storage Pool Object for both vmax and vnx
*
* @param storagePoolpath
* @param it
* @param dbClient
* @param keyMap
* @throws IOException
*/
protected void addTiersToPool(CIMObjectPath storagePoolpath, Iterator<CIMInstance> it, DbClient dbClient, Map<String, Object> keyMap) throws IOException {
Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
Map<String, String> tierUtilizationPercentageMap = new HashMap<String, String>();
CIMInstance tierInstance = null;
List<StorageTier> _tierList = new ArrayList<StorageTier>();
Set<String> tierUris = new HashSet<String>();
while (it.hasNext()) {
try {
tierInstance = it.next();
String tierUtilizationPercentage = tierInstance.getPropertyValue(Constants.PERCENTAGE).toString();
String driveTechnologyIdentifier = tierInstance.getPropertyValue(Constants.TECHNOLOGY).toString();
String driveTechnology = StorageTier.SupportedTiers.getTier(driveTechnologyIdentifier);
if (null == driveTechnology) {
_logger.info("Unsupported Drive Type :" + driveTechnologyIdentifier);
} else {
tierUtilizationPercentageMap.put(driveTechnology, tierUtilizationPercentage);
}
String tierNativeGuid = getTierNativeGuidFromTierInstance(tierInstance);
StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, dbClient);
if (null == tierObject) {
tierObject = createStorageTier(tierInstance, tierObject, tierNativeGuid, null, _tierList, null, driveTechnology);
dbClient.createObject(tierObject);
}
tierUris.add(tierObject.getId().toString());
} catch (Exception e) {
_logger.error("Determing Drive Type, Tier Info failed for {} : ", tierInstance.getObjectPath(), e);
}
}
URI poolURI = getStoragePoolURI(storagePoolpath, dbClient);
StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
if (null != pool) {
pool.addTierUtilizationPercentage(tierUtilizationPercentageMap);
// If the modified list already has this pool, skip the check.
if (!poolsToMatchWithVpool.containsKey(pool.getId()) && ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getTiers(), tierUris)) {
poolsToMatchWithVpool.put(pool.getId(), pool);
}
pool.addTiers(tierUris);
dbClient.persistObject(pool);
}
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class AbstractFASTPolicyProcessor method createStorageTier.
/**
* create Storage Tier
*
* @param tierInstance
* @param tierObject
* @param tierNativeGuid
* @param vmaxFastPolicyUri
* @param tierList
* @return
*/
protected StorageTier createStorageTier(CIMInstance tierInstance, StorageTier tierObject, String tierNativeGuid, URI vmaxFastPolicyUri, List<StorageTier> newTierList, List<StorageTier> updateTierList, String driveTechnology) {
boolean isNewTier = false;
if (null == tierObject) {
tierObject = new StorageTier();
tierObject.setId(URIUtil.createId(StorageTier.class));
tierObject.setNativeGuid(tierNativeGuid);
isNewTier = true;
}
tierObject.setPercentage(getCIMPropertyValue(tierInstance, Constants.PERCENTAGE));
tierObject.setLabel(getCIMPropertyValue(tierInstance, Constants.ELEMENTNAME));
tierObject.setDiskDriveTechnology(driveTechnology);
String totalCapacity = getCIMPropertyValue(tierInstance, Constants.TOTAL_CAPACITY);
tierObject.setTotalCapacity(ControllerUtils.convertBytesToKBytes(totalCapacity));
if (isNewTier) {
newTierList.add(tierObject);
} else {
updateTierList.add(tierObject);
}
return tierObject;
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class AbstractFASTPolicyProcessor method checkStorageTierExistsInDB.
/**
* Check if Storage Tier exists in DB.
*
* @param tierNativeGuid
* @param _dbClient
* @return StorageTier
* @throws IOException
*/
protected StorageTier checkStorageTierExistsInDB(String tierNativeGuid, DbClient _dbClient) throws IOException {
StorageTier tier = null;
// use NativeGuid to lookup Tiers in DB
@SuppressWarnings("deprecation") List<URI> storageTierUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid));
if (!storageTierUris.isEmpty()) {
tier = _dbClient.queryObject(StorageTier.class, storageTierUris.get(0));
}
return tier;
}
Aggregations