Search in sources :

Example 11 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.

the class VmaxSLOBookkeepingProcessor method performPolicyBookKeeping.

/**
 * if the policy had been removed from the Array, the rediscovery cycle should set the fast Policy to inactive.
 *
 * @param dbClient [in] - Database client
 * @param policyNames [in] - List SLO nativeGUIDs
 * @param storageSystem [in] - StorageSystem object representing the array being discovered
 * @throws java.io.IOException
 */
private void performPolicyBookKeeping(DbClient dbClient, Set<String> policyNames, StorageSystem storageSystem) throws IOException {
    log.debug(String.format("SLO policyNames found by discovery for array %s:%n%s", storageSystem.getNativeGuid(), Joiner.on(',').join(policyNames)));
    List<AutoTieringPolicy> policiesToUpdate = new ArrayList<>();
    URIQueryResultList policiesInDB = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFASTPolicyConstraint(storageSystem.getId()), policiesInDB);
    for (URI policy : policiesInDB) {
        AutoTieringPolicy policyObject = dbClient.queryObject(AutoTieringPolicy.class, policy);
        // Process only SLO based AutoTieringPolicies here.
        if (policyObject == null || Strings.isNullOrEmpty(policyObject.getVmaxSLO())) {
            continue;
        }
        String policyName = policyObject.getPolicyName();
        if (!policyNames.contains(policyName)) {
            log.info(String.format("SLO %s no longer exists on array %s, marking associated AutoTieringPolicy %s inactive", policyName, storageSystem.getNativeGuid(), policy));
            policyObject.setPolicyEnabled(false);
            policyObject.getPools().clear();
            policyObject.setInactive(true);
            policiesToUpdate.add(policyObject);
        }
    }
    if (!policiesToUpdate.isEmpty()) {
        dbClient.updateAndReindexObject(policiesToUpdate);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 12 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.

the class ExternalDeviceCommunicationInterface method createOrUpdateAutoTierPolicies.

/**
 * Creates and/or updates the auto tiering policies in the controller database after
 * processing the discovered storage pools and the auto tiering policies that they support.
 *
 * @param system A reference to the storage system.
 * @param autoTieringPolicyPoolMap A map of the storage pools for each policy keyed by policy id.
 * @param autoTieringPolicyPropertiesMap A map of the auto tiering policy properties keyed by policy id.
 */
private void createOrUpdateAutoTierPolicies(com.emc.storageos.db.client.model.StorageSystem system, Map<String, List<com.emc.storageos.db.client.model.StoragePool>> autoTieringPolicyPoolMap, Map<String, Map<String, List<String>>> autoTieringPolicyPropertiesMap) {
    List<DataObject> objectsToCreate = new ArrayList<>();
    List<DataObject> objectsToUpdate = new ArrayList<>();
    for (Entry<String, List<com.emc.storageos.db.client.model.StoragePool>> policyEntry : autoTieringPolicyPoolMap.entrySet()) {
        String policyId = policyEntry.getKey();
        String nativeGuid = NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(system.getNativeGuid(), policyId, NativeGUIDGenerator.AUTO_TIERING_POLICY);
        AutoTieringPolicy autoTieringPolicy = checkAutoTieringPolicyExistsInDB(nativeGuid);
        if (autoTieringPolicy == null) {
            autoTieringPolicy = new AutoTieringPolicy();
            autoTieringPolicy.setId(URIUtil.createId(AutoTieringPolicy.class));
            autoTieringPolicy.setPolicyName(policyId);
            autoTieringPolicy.setStorageSystem(system.getId());
            autoTieringPolicy.setNativeGuid(nativeGuid);
            autoTieringPolicy.setLabel(policyId);
            autoTieringPolicy.setSystemType(system.getSystemType());
            autoTieringPolicy.setPolicyEnabled(Boolean.TRUE);
            Map<String, List<String>> policyProperties = autoTieringPolicyPropertiesMap.get(policyId);
            List<String> provTypeValueList = policyProperties.get(AutoTieringPolicyCapabilityDefinition.PROPERTY_NAME.PROVISIONING_TYPE.name());
            if (!provTypeValueList.isEmpty()) {
                autoTieringPolicy.setProvisioningType(provTypeValueList.get(0));
            }
            objectsToCreate.add(autoTieringPolicy);
            _log.info(String.format("Creating new auto tiering policy %s, supported by storage pools %s", policyId, policyEntry.getValue()));
        } else {
            objectsToUpdate.add(autoTieringPolicy);
            _log.info(String.format("Updating existing auto tiering policy %s, supported by storage pools %s", policyId, policyEntry.getValue()));
        }
        // Set the storage pools for this policy. Since the pools have enabled auto
        // tiering policies, also, make sure auto tiering is enabled on each pool.
        StringSet poolIds = new StringSet();
        for (com.emc.storageos.db.client.model.StoragePool pool : policyEntry.getValue()) {
            poolIds.add(pool.getId().toString());
            // Note that the pool in the db will be updated by the caller.
            pool.setAutoTieringEnabled(true);
        }
        autoTieringPolicy.setPools(poolIds);
        // sure the system has auto tiering enabled.
        if (!system.getAutoTieringEnabled()) {
            system.setAutoTieringEnabled(true);
            _dbClient.updateObject(system);
        }
    }
    // Now any auto tier policies in the database for the passed system that are
    // not represented by the passed policy map need to be marked disabled.
    disableRemovedAutoTieringPolicies(autoTieringPolicyPoolMap.keySet(), system.getId());
    // Lastly create and update objects in the database.
    _dbClient.createObject(objectsToCreate);
    _dbClient.updateObject(objectsToUpdate);
}
Also used : ArrayList(java.util.ArrayList) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 13 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.

the class ExternalDeviceCommunicationInterface method checkAutoTieringPolicyExistsInDB.

/**
 * Get the auto tiering policy in the database with the passed native GUID if it exists.
 * Otherwise, return null.
 *
 * @param nativeGuid The native GUI of the auto tiering policy.
 *
 * @return The auto tiering policy if it exists, null otherwise.
 */
private AutoTieringPolicy checkAutoTieringPolicyExistsInDB(String nativeGuid) {
    AutoTieringPolicy autoTieringPolicy = null;
    URIQueryResultList queryResult = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getAutoTieringPolicyByNativeGuidConstraint(nativeGuid), queryResult);
    if (queryResult.iterator().hasNext()) {
        autoTieringPolicy = _dbClient.queryObject(AutoTieringPolicy.class, queryResult.iterator().next());
    }
    return autoTieringPolicy;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 14 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.

the class ExternalDeviceCommunicationInterface method disableRemovedAutoTieringPolicies.

/**
 * Disable any auto tiering policies for the passed system that were not discovered
 * as represented by the passed policy ids.
 *
 * @param discoveredPolicyIds The ids of the discovered auto tiering policies
 * after processing all discovered storage pools.
 * @param systemURI The URI of the external storage system.
 */
private void disableRemovedAutoTieringPolicies(Set<String> discoveredPolicyIds, URI systemURI) {
    List<AutoTieringPolicy> disabledPolicies = new ArrayList<>();
    URIQueryResultList queryResults = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFASTPolicyConstraint(systemURI), queryResults);
    Iterator<URI> queryResultsIter = queryResults.iterator();
    while (queryResultsIter.hasNext()) {
        URI autoTieringPolicyURI = queryResultsIter.next();
        AutoTieringPolicy autoTieringPolicy = _dbClient.queryObject(AutoTieringPolicy.class, autoTieringPolicyURI);
        if ((autoTieringPolicy != null) && (!discoveredPolicyIds.contains(autoTieringPolicy.getPolicyName()))) {
            // Disable the policy and clear the supporting storage pools.
            autoTieringPolicy.setPolicyEnabled(false);
            autoTieringPolicy.setPools(new StringSet());
            autoTieringPolicy.setInactive(true);
            disabledPolicies.add(autoTieringPolicy);
        }
    }
    _dbClient.updateObject(disabledPolicies);
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 15 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.

the class FASTPolicyProcessor 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;
        _newFastPolicies = new ArrayList<AutoTieringPolicy>();
        _updateFastPolicies = new ArrayList<AutoTieringPolicy>();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        URI storageSystemURI = profile.getSystemId();
        Set<String> policyNames = new HashSet<String>();
        boolean vnxStartHighThenAutoTierPolicyCreated = false;
        while (it.hasNext()) {
            CIMInstance policyObjectInstance = it.next();
            CIMObjectPath policyObjectPath = policyObjectInstance.getObjectPath();
            String systemName = policyObjectPath.getKey(Constants.SYSTEMNAME).getValue().toString();
            if (!systemName.contains((String) keyMap.get(Constants._serialID))) {
                continue;
            }
            String[] array = systemName.split(Constants.PATH_DELIMITER_REGEX);
            String policyID = getFASTPolicyID(policyObjectPath);
            // Trim the policyID from "-+-" to "+" if necessary
            Boolean usingSMIS80 = (Boolean) keyMap.get(Constants.USING_SMIS80_DELIMITERS);
            if ((null != usingSMIS80) && (true == usingSMIS80)) {
                policyID = policyID.replaceAll(Constants.SMIS_80_STYLE, Constants.SMIS_PLUS_REGEX);
            }
            AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(policyID, _dbClient);
            String policyRuleName = policyObjectPath.getKey(Constants.POLICYRULENAME).getValue().toString();
            policyNames.add(policyRuleName);
            String policyEnabled = policyObjectInstance.getPropertyValue(Constants.ENABLED).toString();
            String provisioningType = AutoTieringPolicy.ProvisioningType.getType(policyObjectInstance.getPropertyValue(Constants.PROVISIONING_TYPE).toString());
            /**
             * Only user Defined Policies are considered for VMAX
             * For VNX, only default policies are present, there is no concept of userDefined
             */
            if (!Constants.SYMMETRIX.equalsIgnoreCase(array[0]) && !Constants.CLARIION.equalsIgnoreCase(array[0])) {
                _logger.info("Unsupported FAST Policy :{}", policyID);
                return;
            }
            String fastPolicyServiceConstant = getFASTPolicyServiceConstant(array[0], policyRuleName);
            if (null != fastPolicyServiceConstant) {
                createFASTPolicy(policyID, policy, policyRuleName, storageSystemURI, policyEnabled, provisioningType);
                addPath(keyMap, fastPolicyServiceConstant, policyObjectPath);
                keyMap.put(policyRuleName, policyObjectPath);
                if (fastPolicyServiceConstant.equals(Constants.VMAXFASTPOLICIES)) {
                    addDeviceGroupNamesToSetUsedInVerifyingExistence(policyRuleName, keyMap, provisioningType);
                    addDeviceGroupNamesToSetUsedInVerifyingFASTPolicyRelationShipExistence(policyRuleName, keyMap, provisioningType);
                } else if (fastPolicyServiceConstant.equals(Constants.VNXFASTPOLICIES) && !vnxStartHighThenAutoTierPolicyCreated) {
                    /**
                     * NOTE: start_high_then_auto_tier policy will not be discovered, thus must
                     * create it for VNX in ViPR if not created already.
                     */
                    String startHighThenAutoTierPolicyName = Constants.START_HIGH_THEN_AUTO_TIER_POLICY_NAME;
                    policyNames.add(startHighThenAutoTierPolicyName);
                    String startHighThenAutTierPolicyId = getFASTPolicyID(systemName, startHighThenAutoTierPolicyName);
                    AutoTieringPolicy startHighThenAutTierPolicy = getAutoTieringPolicyByNameFromDB(startHighThenAutTierPolicyId, _dbClient);
                    createFASTPolicy(startHighThenAutTierPolicyId, startHighThenAutTierPolicy, startHighThenAutoTierPolicyName, storageSystemURI, "1", AutoTieringPolicy.ProvisioningType.All.name());
                    vnxStartHighThenAutoTierPolicyCreated = true;
                }
            }
        }
        _dbClient.createObject(_newFastPolicies);
        _dbClient.persistObject(_updateFastPolicies);
        performPolicyBookKeeping(policyNames, storageSystemURI);
    } catch (Exception e) {
        _logger.error("FAST Policy Processing failed", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Aggregations

AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)37 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 URI (java.net.URI)18 ArrayList (java.util.ArrayList)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 HashSet (java.util.HashSet)6 List (java.util.List)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 HashMap (java.util.HashMap)4 CIMObjectPath (javax.cim.CIMObjectPath)4 StorageTier (com.emc.storageos.db.client.model.StorageTier)3 AutoTierPolicyList (com.emc.storageos.model.block.tier.AutoTierPolicyList)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 Volume (com.emc.storageos.db.client.model.Volume)2 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 CIMInstance (javax.cim.CIMInstance)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1