Search in sources :

Example 1 with TieringPolicy

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;
            }
        }
    }
}
Also used : HitachiTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy.HitachiTieringPolicy) TieringPolicy(com.emc.storageos.hds.model.TieringPolicy) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HDSException(com.emc.storageos.hds.HDSException) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with TieringPolicy

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);
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) HitachiTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy.HitachiTieringPolicy) TieringPolicy(com.emc.storageos.hds.model.TieringPolicy) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) ArrayList(java.util.ArrayList)

Aggregations

AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)2 HitachiTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy.HitachiTieringPolicy)2 TieringPolicy (com.emc.storageos.hds.model.TieringPolicy)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 HDSException (com.emc.storageos.hds.HDSException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)1 HDSCollectionException (com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 WBEMException (javax.wbem.WBEMException)1