Search in sources :

Example 11 with StoragePool

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

the class ManagedCapacityImpl method getManagedCapacity.

public static ManagedResourcesCapacity getManagedCapacity(DbClient dbClient) throws InterruptedException {
    ManagedResourcesCapacity resourcesCapacity = new ManagedResourcesCapacity();
    ManagedResourcesCapacity.ManagedResourceCapacity manCap;
    CustomQueryUtility.AggregatedValue aggr = null;
    if (Thread.currentThread().interrupted()) {
        throw new InterruptedException();
    }
    manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
    manCap.setType(ManagedResourcesCapacity.CapacityResourceType.VOLUME);
    aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, Volume.class, "allocatedCapacity");
    manCap.setNumResources(aggr.getCount());
    manCap.setResourceCapacity(aggr.getValue());
    resourcesCapacity.getResourceCapacityList().add(manCap);
    if (Thread.currentThread().interrupted()) {
        throw new InterruptedException();
    }
    manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
    manCap.setType(ManagedResourcesCapacity.CapacityResourceType.FILESHARE);
    aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, FileShare.class, "usedCapacity");
    manCap.setNumResources(aggr.getCount());
    manCap.setResourceCapacity(aggr.getValue());
    resourcesCapacity.getResourceCapacityList().add(manCap);
    if (Thread.currentThread().interrupted()) {
        throw new InterruptedException();
    }
    manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
    manCap.setType(ManagedResourcesCapacity.CapacityResourceType.POOL);
    aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, StoragePool.class, "freeCapacity");
    manCap.setNumResources(aggr.getCount());
    double capacity = aggr.getValue();
    // We must consider storage systems with sharedStorageCapacity == true (e.g. Ceph),
    // because each their pool reports total storage free capacity.
    // We get all such systems and subtract its pool size multiplied by (pools count - 1) from total capacity.
    // Get all StoragePools where storageDevice is a StorageSystem where sharedStorageCapacity is true
    Joiner j = new Joiner(dbClient).join(StorageSystem.class, "ss").match("sharedStorageCapacity", true).join("ss", StoragePool.class, "sp", "storageDevice").go();
    Map<StorageSystem, Collection<URI>> ssToPoolMap = j.pushList("ss").pushUris("sp").map();
    // From the joiner, get the StorageSystems (which is a small amount of objects) and the SPs (which is large, so get URIs and use query)
    for (Entry<StorageSystem, Collection<URI>> ssToPoolEntry : ssToPoolMap.entrySet()) {
        Collection<URI> poolURIs = ssToPoolEntry.getValue();
        int extraPoolCount = poolURIs.size() - 1;
        if (extraPoolCount <= 0) {
            // Do nothing if none of the only pool belongs to Storage System
            continue;
        }
        StoragePool pool = dbClient.queryObject(StoragePool.class, poolURIs.iterator().next());
        capacity -= extraPoolCount * pool.getFreeCapacity();
    }
    manCap.setResourceCapacity(capacity * KB);
    resourcesCapacity.getResourceCapacityList().add(manCap);
    if (Thread.currentThread().interrupted()) {
        throw new InterruptedException();
    }
    manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
    manCap.setType(ManagedResourcesCapacity.CapacityResourceType.BUCKET);
    aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, Bucket.class, "hardQuota");
    manCap.setNumResources(aggr.getCount());
    manCap.setResourceCapacity(aggr.getValue());
    resourcesCapacity.getResourceCapacityList().add(manCap);
    if (Thread.currentThread().interrupted()) {
        throw new InterruptedException();
    }
    return resourcesCapacity;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Joiner(com.emc.storageos.db.joiner.Joiner) ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourcesCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity) CustomQueryUtility(com.emc.storageos.db.client.util.CustomQueryUtility) FileShare(com.emc.storageos.db.client.model.FileShare) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Volume(com.emc.storageos.db.client.model.Volume) Bucket(com.emc.storageos.db.client.model.Bucket) Collection(java.util.Collection) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with StoragePool

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

the class ObjectDeviceController method createBucket.

@Override
public void createBucket(URI storage, URI uriPool, URI bkt, String label, String namespace, Integer retention, Long hardQuota, Long softQuota, String owner, String task) throws ControllerException {
    _log.info("ObjectDeviceController:createBucket Bucket URI : {} ", bkt);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    Bucket bucketObj = _dbClient.queryObject(Bucket.class, bkt);
    StoragePool stPool = _dbClient.queryObject(StoragePool.class, uriPool);
    ObjectDeviceInputOutput args = new ObjectDeviceInputOutput();
    args.setName(label);
    args.setNamespace(namespace);
    // recommended storage pool
    args.setDevStoragePool(stPool.getNativeId());
    args.setRetentionPeriod(retention);
    args.setBlkSizeHQ(hardQuota);
    args.setNotSizeSQ(softQuota);
    args.setOwner(owner);
    _log.info("ObjectDeviceController:createBucket URI and Type: " + storage.toString() + "   " + storageObj.getSystemType());
    BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateBucket(storageObj, bucketObj, args, task);
    if (result.getCommandPending()) {
        return;
    }
    bucketObj.getOpStatus().updateTaskStatus(task, result.toOperation());
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Bucket(com.emc.storageos.db.client.model.Bucket) ObjectDeviceInputOutput(com.emc.storageos.volumecontroller.ObjectDeviceInputOutput) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 13 with StoragePool

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

the class StoragePoolAssociationHelper method updateSystemVarrays.

/**
 * When the ports-varray associations change, for vplex system, update the system-varray association.
 * For other storage systems, update the pools-varrays associations.
 *
 * @param systemUri the system where the varray association has changed
 * @param dbClient an instance of dbClient
 */
private static void updateSystemVarrays(URI systemUri, DbClient dbClient) {
    StorageSystem system = dbClient.queryObject(StorageSystem.class, systemUri);
    if (!system.getInactive()) {
        _log.info("Updating the virtual arrays for storage system {}", system.getNativeGuid());
        if (ConnectivityUtil.isAVPlex(system)) {
            StringSet varrays = getSystemConnectedVarrays(systemUri, PortType.frontend.name(), dbClient);
            _log.info("vplex system {} varrays will be set to {}", system.getNativeGuid(), varrays);
            if (system.getVirtualArrays() == null) {
                system.setVirtualArrays(varrays);
            } else {
                system.getVirtualArrays().replace(varrays);
            }
            dbClient.updateAndReindexObject(system);
            _log.info("Updated vplex system {} varrays to {}", system.getNativeGuid(), varrays);
        } else {
            StringSet varrays = getSystemConnectedVarrays(systemUri, null, dbClient);
            _log.info("The pools of storage system {} varrays will be set to {}", system.getNativeGuid(), varrays);
            List<StoragePool> pools = getSystemPools(systemUri, dbClient);
            for (StoragePool pool : pools) {
                pool.replaceConnectedVirtualArray(varrays);
                _log.info("Updated storage pool {} varrays to {}", pool.getNativeGuid(), varrays);
            }
            dbClient.updateAndReindexObject(pools);
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 14 with StoragePool

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

the class StoragePoolAssociationHelper method setStoragePoolVarrays.

/**
 * When a pool is newly discovered, set its varray associations.
 *
 * @param systemUri the pool's system
 * @param storagePools the pool to be updated
 * @param dbClient an instance of db client
 */
public static void setStoragePoolVarrays(URI systemUri, List<StoragePool> storagePools, DbClient dbClient) {
    StringSet varrayURIs = getSystemConnectedVarrays(systemUri, null, dbClient);
    for (StoragePool storagePool : storagePools) {
        if (storagePool.getStorageDevice().equals(systemUri)) {
            storagePool.replaceConnectedVirtualArray(varrayURIs);
        } else {
            _log.error("Pool {} does not belong to storage system {} and will not be updated", storagePool.getNativeGuid(), systemUri);
        }
    }
    dbClient.updateAndReindexObject(storagePools);
    // now ensure any RP systems are getting their varray connections updated
    ConnectivityUtil.updateRpSystemsConnectivity(java.util.Collections.singletonList(systemUri), dbClient);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 15 with StoragePool

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

the class StoragePoolAssociationHelper method getSystemPools.

private static List<StoragePool> getSystemPools(URI systemUri, DbClient dbClient) {
    List<StoragePool> pools = new ArrayList<StoragePool>();
    URIQueryResultList storagePoolsURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(systemUri, StoragePool.class, "storageDevice"), storagePoolsURIs);
    Iterator<URI> storagePortURIsIter = storagePoolsURIs.iterator();
    while (storagePortURIsIter.hasNext()) {
        URI storagePoolURI = storagePortURIsIter.next();
        StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
        if (storagePool != null && !storagePool.getInactive()) {
            pools.add(storagePool);
        } else {
            _log.error("Can't find storage pool {} in the database " + "or the pool is marked for deletion", storagePoolURI);
        }
    }
    return pools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30