use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class TierPercentageProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
while (it.hasNext()) {
try {
CIMInstance symmAssociatedPolicyInstance = it.next();
CIMObjectPath symmAssociatedPolicyPath = symmAssociatedPolicyInstance.getObjectPath();
CIMObjectPath tierPath = (CIMObjectPath) symmAssociatedPolicyPath.getKey(DEPENDENT).getValue();
String tierPercent = symmAssociatedPolicyInstance.getPropertyValue(MAX_PERCENT_ALLOCATED).toString();
String tierID = tierPath.getKey(Constants.INSTANCEID).getValue().toString();
String tierNativeGuid = getTierNativeGuidForVMax(tierID);
StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, _dbClient);
if (null != tierObject) {
tierObject.setPercentage(tierPercent);
_dbClient.persistObject(tierObject);
}
} catch (Exception e) {
_logger.error("Vmax Tier Percentage Discovery failed", e);
}
}
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class VMAXPolicyToTierProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
_updateTierList = new ArrayList<StorageTier>();
_newTierList = new ArrayList<StorageTier>();
// value will be set already always
Object[] arguments = (Object[]) _args.get(0);
Set<String> tierNativeGuidsfromProvider = new HashSet<String>();
CIMObjectPath vmaxFastPolicyRule = (CIMObjectPath) arguments[0];
String vmaxPolicyId = getFASTPolicyID(vmaxFastPolicyRule);
AutoTieringPolicy vmaxFastPolicy = getAutoTieringPolicyByNameFromDB(vmaxPolicyId, _dbClient);
// the relationship between Policy--->Pools
while (it.hasNext()) {
CIMInstance vmaxTierInstance = it.next();
CIMObjectPath tierPath = vmaxTierInstance.getObjectPath();
String tierID = tierPath.getKey(Constants.INSTANCEID).getValue().toString();
// For 8.x -+- becomes +, internal DB format uses + only; for 4.6 remains as it is
tierID = tierID.replaceAll(Constants.SMIS_80_STYLE, Constants.SMIS_PLUS_REGEX);
if (keyMap.containsKey(tierID)) {
List<CIMObjectPath> policyPaths = (List<CIMObjectPath>) keyMap.get(tierID);
policyPaths.add(vmaxFastPolicyRule);
} else {
addPath(keyMap, Constants.STORAGETIERS, tierPath);
List<CIMObjectPath> policyPaths = new ArrayList<CIMObjectPath>();
policyPaths.add(vmaxFastPolicyRule);
keyMap.put(tierID, policyPaths);
}
String tierNativeGuid = getTierNativeGuidForVMax(tierID);
tierNativeGuidsfromProvider.add(tierNativeGuid);
StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, _dbClient);
String driveTechnologyIdentifier = vmaxTierInstance.getPropertyValue(Constants.TECHNOLOGY).toString();
String driveType = StorageTier.SupportedTiers.getTier(driveTechnologyIdentifier);
createStorageTier(vmaxTierInstance, tierObject, tierNativeGuid, vmaxFastPolicy.getId(), _newTierList, _updateTierList, driveType);
}
_dbClient.createObject(_newTierList);
_dbClient.persistObject(_updateTierList);
performStorageTierBookKeeping(tierNativeGuidsfromProvider, vmaxFastPolicy.getId());
} catch (Exception e) {
_logger.error("Policy to Tier Processing failed :", e);
}
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class VMAXPolicyToTierProcessor method performStorageTierBookKeeping.
/**
* remove Tiers which had been deleted from Array
*
* @param tierNativeGuidsfromProvider
* @param id
* @throws IOException
*/
private void performStorageTierBookKeeping(Set<String> tierNativeGuidsfromProvider, URI id) throws IOException {
List<URI> tierUrisAssociatedWithPolicy = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierFASTPolicyConstraint(id.toString()));
_logger.info("Tiers {} associated with Policy {}", Joiner.on("\t").join(tierUrisAssociatedWithPolicy), id);
List<StorageTier> existingTierObjectsInDB = _dbClient.queryObject(StorageTier.class, tierUrisAssociatedWithPolicy);
for (StorageTier tier : existingTierObjectsInDB) {
if (!tierNativeGuidsfromProvider.contains(tier.getNativeGuid())) {
if (null != tier.getAutoTieringPolicies()) {
tier.getAutoTieringPolicies().clear();
}
_dbClient.updateAndReindexObject(tier);
}
}
}
use of com.emc.storageos.db.client.model.StorageTier in project coprhd-controller by CoprHD.
the class VMAXTiersToPoolProcessor method addFastPolicyToTier.
@SuppressWarnings("unchecked")
private void addFastPolicyToTier(List<CIMObjectPath> policyPaths, String tierID) throws IOException {
Set<String> policyUris = new StringSet();
// getting policy uris from DB
for (CIMObjectPath path : policyPaths) {
String policyID = getFASTPolicyID(path);
AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(policyID, _dbClient);
if (null != policy) {
policyUris.add(policy.getId().toString());
}
}
StorageTier tierObject = checkStorageTierExistsInDB(getTierNativeGuidForVMax(tierID), _dbClient);
if (null != tierObject) {
if (null == tierObject.getAutoTieringPolicies()) {
tierObject.setAutoTieringPolicies(new StringSet());
}
tierObject.getAutoTieringPolicies().replace(policyUris);
_dbClient.updateAndReindexObject(tierObject);
}
}
use of com.emc.storageos.db.client.model.StorageTier 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