Search in sources :

Example 11 with StorageTier

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

the class HDSCommunicationInterface method checkStorageTierExistsInDB.

/**
 * Check if Storage Tier exists in DB.
 *
 * @param tierNativeGuid
 * @param _dbClient
 * @return StorageTier
 * @throws IOException
 */
private StorageTier checkStorageTierExistsInDB(String tierNativeGuid) {
    StorageTier tier = null;
    URIQueryResultList tierQueryResult = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid), tierQueryResult);
    if (tierQueryResult.iterator().hasNext()) {
        tier = _dbClient.queryObject(StorageTier.class, tierQueryResult.iterator().next());
    }
    return tier;
}
Also used : StorageTier(com.emc.storageos.db.client.model.StorageTier) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 12 with StorageTier

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

the class VNXeCommunicationInterface method discoverStorageTier.

private HashMap<String, List<StorageTier>> discoverStorageTier(StorageSystem system, VNXeApiClient client) throws VNXeException {
    HashMap<String, List<StorageTier>> storageTiers = new HashMap<String, List<StorageTier>>();
    List<StorageTier> newTiers = new ArrayList<StorageTier>();
    List<StorageTier> existingTiers = new ArrayList<StorageTier>();
    List<VNXeStorageTier> tiers = client.getStorageTiers();
    String systemNativeGuid = NativeGUIDGenerator.generateNativeGuid(system);
    for (VNXeStorageTier tier : tiers) {
        String nativeId = tier.getId();
        StorageTier tierObj = null;
        String tierNativeGuid = NativeGUIDGenerator.generateStorageTierNativeGuidForVmaxTier(systemNativeGuid, nativeId);
        URIQueryResultList results = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid), results);
        if (results.iterator().hasNext()) {
            _logger.info("Getting the storage tier.");
            StorageTier tmpTier = _dbClient.queryObject(StorageTier.class, results.iterator().next());
            _logger.info(String.format("Actual StorageDevice %s : storage tier : %s", system.getId(), tmpTier.getNativeGuid()));
            tierObj = tmpTier;
        }
        boolean isNewTier = false;
        if (null == tierObj) {
            tierObj = new StorageTier();
            tierObj.setId(URIUtil.createId(StorageTier.class));
            tierObj.setNativeGuid(tierNativeGuid);
            isNewTier = true;
        }
        tierObj.setLabel(tier.getName());
        tierObj.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(tier.getSizeTotal()));
        if (isNewTier) {
            newTiers.add(tierObj);
        } else {
            existingTiers.add(tierObj);
        }
    }
    storageTiers.put(NEW, newTiers);
    storageTiers.put(EXISTING, existingTiers);
    return storageTiers;
}
Also used : HashMap(java.util.HashMap) VNXeStorageTier(com.emc.storageos.vnxe.models.VNXeStorageTier) StorageTier(com.emc.storageos.db.client.model.StorageTier) VNXeStorageTier(com.emc.storageos.vnxe.models.VNXeStorageTier) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 13 with StorageTier

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

the class AbstractFASTPolicyProcessor method addTiersToPool.

/**
 * Create Storage Tiers for VNX, if not present already
 * Add Tier Uris to Storage Pool Object for both vmax and vnx
 *
 * @param storagePoolpath
 * @param it
 * @param dbClient
 * @param keyMap
 * @throws IOException
 */
protected void addTiersToPool(CIMObjectPath storagePoolpath, Iterator<CIMInstance> it, DbClient dbClient, Map<String, Object> keyMap) throws IOException {
    Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
    Map<String, String> tierUtilizationPercentageMap = new HashMap<String, String>();
    CIMInstance tierInstance = null;
    List<StorageTier> _tierList = new ArrayList<StorageTier>();
    Set<String> tierUris = new HashSet<String>();
    while (it.hasNext()) {
        try {
            tierInstance = it.next();
            String tierUtilizationPercentage = tierInstance.getPropertyValue(Constants.PERCENTAGE).toString();
            String driveTechnologyIdentifier = tierInstance.getPropertyValue(Constants.TECHNOLOGY).toString();
            String driveTechnology = StorageTier.SupportedTiers.getTier(driveTechnologyIdentifier);
            if (null == driveTechnology) {
                _logger.info("Unsupported Drive Type :" + driveTechnologyIdentifier);
            } else {
                tierUtilizationPercentageMap.put(driveTechnology, tierUtilizationPercentage);
            }
            String tierNativeGuid = getTierNativeGuidFromTierInstance(tierInstance);
            StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, dbClient);
            if (null == tierObject) {
                tierObject = createStorageTier(tierInstance, tierObject, tierNativeGuid, null, _tierList, null, driveTechnology);
                dbClient.createObject(tierObject);
            }
            tierUris.add(tierObject.getId().toString());
        } catch (Exception e) {
            _logger.error("Determing Drive Type, Tier Info failed for {} : ", tierInstance.getObjectPath(), e);
        }
    }
    URI poolURI = getStoragePoolURI(storagePoolpath, dbClient);
    StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
    if (null != pool) {
        pool.addTierUtilizationPercentage(tierUtilizationPercentageMap);
        // If the modified list already has this pool, skip the check.
        if (!poolsToMatchWithVpool.containsKey(pool.getId()) && ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getTiers(), tierUris)) {
            poolsToMatchWithVpool.put(pool.getId(), pool);
        }
        pool.addTiers(tierUris);
        dbClient.persistObject(pool);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) StorageTier(com.emc.storageos.db.client.model.StorageTier) ArrayList(java.util.ArrayList) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 14 with StorageTier

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

the class AbstractFASTPolicyProcessor method createStorageTier.

/**
 * create Storage Tier
 *
 * @param tierInstance
 * @param tierObject
 * @param tierNativeGuid
 * @param vmaxFastPolicyUri
 * @param tierList
 * @return
 */
protected StorageTier createStorageTier(CIMInstance tierInstance, StorageTier tierObject, String tierNativeGuid, URI vmaxFastPolicyUri, List<StorageTier> newTierList, List<StorageTier> updateTierList, String driveTechnology) {
    boolean isNewTier = false;
    if (null == tierObject) {
        tierObject = new StorageTier();
        tierObject.setId(URIUtil.createId(StorageTier.class));
        tierObject.setNativeGuid(tierNativeGuid);
        isNewTier = true;
    }
    tierObject.setPercentage(getCIMPropertyValue(tierInstance, Constants.PERCENTAGE));
    tierObject.setLabel(getCIMPropertyValue(tierInstance, Constants.ELEMENTNAME));
    tierObject.setDiskDriveTechnology(driveTechnology);
    String totalCapacity = getCIMPropertyValue(tierInstance, Constants.TOTAL_CAPACITY);
    tierObject.setTotalCapacity(ControllerUtils.convertBytesToKBytes(totalCapacity));
    if (isNewTier) {
        newTierList.add(tierObject);
    } else {
        updateTierList.add(tierObject);
    }
    return tierObject;
}
Also used : StorageTier(com.emc.storageos.db.client.model.StorageTier)

Example 15 with StorageTier

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

the class AbstractFASTPolicyProcessor method checkStorageTierExistsInDB.

/**
 * Check if Storage Tier exists in DB.
 *
 * @param tierNativeGuid
 * @param _dbClient
 * @return StorageTier
 * @throws IOException
 */
protected StorageTier checkStorageTierExistsInDB(String tierNativeGuid, DbClient _dbClient) throws IOException {
    StorageTier tier = null;
    // use NativeGuid to lookup Tiers in DB
    @SuppressWarnings("deprecation") List<URI> storageTierUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierByIdConstraint(tierNativeGuid));
    if (!storageTierUris.isEmpty()) {
        tier = _dbClient.queryObject(StorageTier.class, storageTierUris.get(0));
    }
    return tier;
}
Also used : StorageTier(com.emc.storageos.db.client.model.StorageTier) URI(java.net.URI)

Aggregations

StorageTier (com.emc.storageos.db.client.model.StorageTier)17 URI (java.net.URI)7 ArrayList (java.util.ArrayList)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 MapStorageTier (com.emc.storageos.api.mapper.functions.MapStorageTier)3 AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)3 StorageTierList (com.emc.storageos.model.block.tier.StorageTierList)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 CIMInstance (javax.cim.CIMInstance)3 CIMObjectPath (javax.cim.CIMObjectPath)3 VNXeStorageTier (com.emc.storageos.vnxe.models.VNXeStorageTier)2 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 StringSet (com.emc.storageos.db.client.model.StringSet)1 StoragePoolTier (com.emc.storageos.hds.model.StoragePoolTier)1