use of com.emc.storageos.hds.model.TieringPolicy in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method parseDiscoveryTieringPolicyResponse.
/**
* Parse & process the TieringPolicies of a given system.
*
* @param array
* @param accessProfile
* @throws Exception
*/
private void parseDiscoveryTieringPolicyResponse(StorageArray array, AccessProfile accessProfile) throws Exception {
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.hds.toString(), array.getObjectID());
URIQueryResultList queryResult = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageSystemByNativeGuidConstraint(nativeGuid), queryResult);
if (queryResult.iterator().hasNext()) {
URI systemURI = queryResult.iterator().next();
if (null != systemURI) {
try {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
if (null == system) {
return;
}
List<TieringPolicy> tpList = array.getTieringPolicyList();
if (null != tpList && !tpList.isEmpty()) {
processDiscoveredTieringPolicies(system, tpList);
} else {
_logger.info("No tieringPolicies defined for the system: {}", systemURI);
}
} catch (Exception ex) {
_logger.error("Exception occurred during discovery of Tiering Policies.", ex);
throw ex;
}
}
}
}
use of com.emc.storageos.hds.model.TieringPolicy in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method processDiscoveredTieringPolicies.
/**
* Process the tieringpolicies received for a given system.
*
* @param system
* @param tpList
*/
private void processDiscoveredTieringPolicies(StorageSystem system, List<TieringPolicy> tpList) {
List<AutoTieringPolicy> newPolicies = new ArrayList<AutoTieringPolicy>();
List<AutoTieringPolicy> allPolicies = new ArrayList<AutoTieringPolicy>();
List<AutoTieringPolicy> updatePolicies = new ArrayList<AutoTieringPolicy>();
for (TieringPolicy tpFromResponse : tpList) {
// Ignore all custom tiering policies.
if (Integer.parseInt(tpFromResponse.getPolicyID()) > 5) {
_logger.debug("Ignoring custom policy {} on system {} ", tpFromResponse.getPolicyID(), system.getNativeGuid());
continue;
}
String nativeGuid = NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(system.getNativeGuid(), getTieringPolicyLabel(tpFromResponse.getPolicyID()), NativeGUIDGenerator.AUTO_TIERING_POLICY);
AutoTieringPolicy tieringPolicy = checkTieringPolicyExistsInDB(nativeGuid);
boolean isNew = false;
if (null == tieringPolicy) {
isNew = true;
tieringPolicy = new AutoTieringPolicy();
tieringPolicy.setId(URIUtil.createId(AutoTieringPolicy.class));
tieringPolicy.setPolicyName(getTieringPolicyLabel(tpFromResponse.getPolicyID()));
tieringPolicy.setStorageSystem(system.getId());
tieringPolicy.setNativeGuid(nativeGuid);
tieringPolicy.setLabel(getTieringPolicyLabel(tpFromResponse.getPolicyID()));
tieringPolicy.setSystemType(Type.hds.name());
newPolicies.add(tieringPolicy);
}
// Hitachi is not providing any API to check whether a policy is enabled or not.
// Hence enabling by default for all policies.
tieringPolicy.setPolicyEnabled(Boolean.TRUE);
tieringPolicy.setProvisioningType(ProvisioningType.ThinlyProvisioned.name());
if (!isNew) {
updatePolicies.add(tieringPolicy);
}
}
_dbClient.createObject(newPolicies);
_dbClient.persistObject(updatePolicies);
allPolicies.addAll(newPolicies);
allPolicies.addAll(updatePolicies);
}
Aggregations