use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.
the class FASTPolicyProcessor method createFASTPolicy.
/**
* create FAST Policy Object
* s
*
* @param policyName
* @param policy
* @throws IOException
*/
private void createFASTPolicy(String policyID, AutoTieringPolicy policy, String policyRuleName, URI storageSystemURI, String policyEnabled, String provisioningType) throws IOException {
boolean newPolicy = false;
if (null == policy) {
newPolicy = true;
policy = new AutoTieringPolicy();
policy.setId(URIUtil.createId(AutoTieringPolicy.class));
policy.setStorageSystem(storageSystemURI);
policy.setNativeGuid(policyID);
policy.setSystemType(getDeviceType(storageSystemURI));
}
policy.setLabel(policyRuleName);
policy.setPolicyName(policyRuleName);
policy.setPolicyEnabled(policyEnabled.equalsIgnoreCase("1"));
policy.setProvisioningType(provisioningType);
if (newPolicy) {
_newFastPolicies.add(policy);
} else {
_updateFastPolicies.add(policy);
}
}
use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.
the class PersistFASTPolicyProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
List<AutoTieringPolicy> fastPolicies = new ArrayList<AutoTieringPolicy>();
@SuppressWarnings("unchecked") Map<String, Set<String>> mapping = (Map<String, Set<String>>) keyMap.get(Constants.POLICY_TO_POOLS_MAPPING);
for (String key : mapping.keySet()) {
AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(key, _dbClient);
Set<String> pools = mapping.get(key);
policy.addPools(pools);
fastPolicies.add(policy);
}
_dbClient.persistObject(fastPolicies);
} catch (Exception e) {
_logger.error("Adding Pools to POlicy Objects and Persisting failed :", e);
}
}
use of com.emc.storageos.db.client.model.AutoTieringPolicy 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.AutoTieringPolicy 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.AutoTieringPolicy in project coprhd-controller by CoprHD.
the class StorageScheduler method getAutoTierPolicy.
/**
* Get the AutoTierPolicy URI for a given StoragePool and auto tier policy name.
*
* @param pool
* -- Storage Pool URI
* @param policyName
* -- Policy name
* @param dbClient
* @return URI of AutoTierPolicy, null if not found
*/
public static URI getAutoTierPolicy(URI pool, String policyName, DbClient dbClient) {
if (pool == null || policyName == null || dbClient == null) {
return null;
}
URIQueryResultList result = new URIQueryResultList();
// check if pool fast policy name is not
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFASTPolicyByNameConstraint(policyName), result);
Iterator<URI> iterator = result.iterator();
while (iterator.hasNext()) {
AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, iterator.next());
if (null == policy.getStorageSystem()) {
continue;
}
// pool's storage system
// Note that the pool can be null when the function is called while
// preparing a VPLEX volume, which does not have a storage pool.
StoragePool poolObj = dbClient.queryObject(StoragePool.class, pool);
if ((poolObj != null) && (policy.getStorageSystem().toString().equalsIgnoreCase(poolObj.getStorageDevice().toString()))) {
return policy.getId();
}
}
return null;
}
Aggregations