Search in sources :

Example 1 with StoragePoolTier

use of com.emc.storageos.hds.model.StoragePoolTier in project coprhd-controller by CoprHD.

the class HDSCommunicationInterface method processStoragePoolTiersInfo.

private void processStoragePoolTiersInfo(StorageSystem system, Pool pool) {
    String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, pool.getObjectID(), NativeGUIDGenerator.POOL);
    URIQueryResultList uriQueryResult = new URIQueryResultList();
    Set<String> tiersSet = new HashSet<String>();
    List<StorageTier> newTiers = new ArrayList<StorageTier>();
    List<StorageTier> updateTiers = new ArrayList<StorageTier>();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), uriQueryResult);
    StoragePool poolInDb = null;
    if (uriQueryResult.iterator().hasNext()) {
        poolInDb = _dbClient.queryObject(StoragePool.class, uriQueryResult.iterator().next());
        if (null == poolInDb) {
            return;
        }
    }
    for (StoragePoolTier tier : pool.getTiers()) {
        String tierNativeGuid = NativeGUIDGenerator.generateStorageTierNativeGuidForHDSTier(system, poolInDb.getNativeId(), tier.getTierID());
        StorageTier storageTier = checkStorageTierExistsInDB(tierNativeGuid);
        if (null == storageTier) {
            storageTier = new StorageTier();
            storageTier.setId(URIUtil.createId(StorageTier.class));
            storageTier.setDiskDriveTechnology(tier.getDiskType());
            storageTier.setLabel(tier.getObjectID());
            storageTier.setNativeGuid(tierNativeGuid);
            storageTier.setStorageDevice(system.getId());
            storageTier.setTotalCapacity(Long.parseLong(tier.getCapacityInKB()));
            newTiers.add(storageTier);
        }
        // @TODO check whether we are getting the right percentage.
        storageTier.setPercentage(tier.getUsageRate());
        tiersSet.add(storageTier.getId().toString());
        updateTiers.add(storageTier);
    }
    _dbClient.createObject(newTiers);
    _dbClient.persistObject(updateTiers);
    poolInDb.addTiers(tiersSet);
    _dbClient.persistObject(poolInDb);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StorageTier(com.emc.storageos.db.client.model.StorageTier) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StoragePoolTier(com.emc.storageos.hds.model.StoragePoolTier) HashSet(java.util.HashSet)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StorageTier (com.emc.storageos.db.client.model.StorageTier)1 StoragePoolTier (com.emc.storageos.hds.model.StoragePoolTier)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1