Search in sources :

Example 1 with ManagedResourcesCapacity

use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.

the class ManagedCapacityImpl method getManagedCapacity.

public ManagedResourcesCapacity getManagedCapacity() throws InterruptedException {
    log.info("Getting provisioning managed capacity");
    double total = 0;
    StringBuilder logMessage = new StringBuilder("");
    logMessage.append('\n');
    logMessage.append("------------------------------------------------------------------------\n");
    logMessage.append("|                 |                |                                   |\n");
    logMessage.append("|  RESOURCE       | MANAGED_QTY    |  TOTAL CAPACITY                   |\n");
    logMessage.append("|                 |                |                                   |\n");
    logMessage.append("------------------------------------------------------------------------\n");
    ManagedResourcesCapacity resources = getManagedCapacity(dbClient);
    List<ManagedResourceCapacity> capacities = resources.getResourceCapacityList();
    for (ManagedResourcesCapacity.ManagedResourceCapacity cap : capacities) {
        total += cap.getResourceCapacity();
        logMessage.append("|                 |                |                                   |\n");
        logMessage.append(String.format("|  %13s  |   %10d   |  %30s   |%n", cap.getType(), cap.getNumResources(), Double.toString(cap.getResourceCapacity())));
        logMessage.append("|                 |                |                                   |\n");
    }
    logMessage.append("|                 |                |                                   |\n");
    logMessage.append("------------------------------------------------------------------------\n");
    logMessage.append("|                 |                |                                   |\n");
    logMessage.append(String.format("|   TOTAL         |                |  %30s   |%n", Double.toString(total)));
    logMessage.append("|                 |                |                                   |\n");
    logMessage.append("------------------------------------------------------------------------\n");
    logMessage.append('\n');
    log.info(logMessage.toString());
    return resources;
}
Also used : ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourcesCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity)

Example 2 with ManagedResourcesCapacity

use of com.emc.storageos.model.vpool.ManagedResourcesCapacity 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 3 with ManagedResourcesCapacity

use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.

the class HealthMonitorService method getStorageStats.

/**
 * Get the current capacity for object, file and block storage.
 *
 * @brief Show storage capacity
 * @prereq none
 * @return Storage stats for controller (file & block) and object.
 */
@GET
@Path("/storage")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public StorageStats getStorageStats() {
    _log.info("Getting storage stats");
    StorageStats.ControllerStorageStats controllerStats = null;
    if (_licenseManager.isProductLicensed(LicenseType.CONTROLLER)) {
        ManagedResourcesCapacity resourceCapacities = _licenseManager.getControllerCapacity();
        controllerStats = new StorageStats.ControllerStorageStats();
        for (ManagedResourceCapacity cap : resourceCapacities.getResourceCapacityList()) {
            switch(cap.getType()) {
                case VOLUME:
                    controllerStats.setBlockCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
                    break;
                case FILESHARE:
                    controllerStats.setFileCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
                    break;
                case POOL:
                    controllerStats.setFreeManagedCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
                    break;
                case BUCKET:
                    controllerStats.setObjectCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
                    break;
            }
        }
    }
    return new StorageStats(controllerStats);
}
Also used : StorageStats(com.emc.vipr.model.sys.healthmonitor.StorageStats) ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourcesCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with ManagedResourcesCapacity

use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.

the class LicenseManagerImpl method getTotalControllerCapacity.

/**
 * Gets controller total managed capacity.
 * sum of volume managed + file managed + free managed storage pool
 * This is mainly used to check capacity against licensed capacity amount.
 */
private double getTotalControllerCapacity() throws InternalServerErrorException {
    _log.info("Getting controller total capacity");
    ManagedResourcesCapacity resourceCapacities = getControllerCapacity();
    double total = 0;
    for (ManagedResourceCapacity cap : resourceCapacities.getResourceCapacityList()) {
        _log.debug("{} capacity is {}", cap.getType(), cap.getResourceCapacity());
        total += cap.getResourceCapacity();
    }
    _log.info("Controller total capacity is {}", total);
    return total;
}
Also used : ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourcesCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity)

Example 5 with ManagedResourcesCapacity

use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.

the class CapacityService method getCapacityDataResource.

private ManagedResourcesCapacity getCapacityDataResource() throws Exception {
    ManagedResourcesCapacity capacities = new ManagedResourcesCapacity();
    for (CapacityResourceType capType : CapacityResourceType.values()) {
        ManagedCapacityImpl.CapacityPropertyListTypes resourceType = ManagedCapacityImpl.mapCapacityType(capType);
        List<URI> dataResourcesURI = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getConstraint(PropertyListDataObject.class, "resourceType", resourceType.toString()));
        if (dataResourcesURI.isEmpty()) {
            _log.warn("Failed to find capacity of type {} in the database, recompute", resourceType);
            throw new Exception("Failed to find capacity in the database");
        }
        PropertyListDataObject resource = _dbClient.queryObject(PropertyListDataObject.class, dataResourcesURI.get(0));
        ManagedResourceCapacity mCap = map(resource, ManagedResourceCapacity.class);
        capacities.getResourceCapacityList().add(mCap);
    }
    return capacities;
}
Also used : PropertyListDataObject(com.emc.storageos.db.client.model.PropertyListDataObject) CapacityResourceType(com.emc.storageos.model.vpool.ManagedResourcesCapacity.CapacityResourceType) ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) ManagedResourcesCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity) ManagedCapacityImpl(com.emc.storageos.volumecontroller.impl.ManagedCapacityImpl) URI(java.net.URI) IOException(java.io.IOException)

Aggregations

ManagedResourcesCapacity (com.emc.storageos.model.vpool.ManagedResourcesCapacity)5 ManagedResourceCapacity (com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity)5 URI (java.net.URI)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Bucket (com.emc.storageos.db.client.model.Bucket)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 PropertyListDataObject (com.emc.storageos.db.client.model.PropertyListDataObject)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 CustomQueryUtility (com.emc.storageos.db.client.util.CustomQueryUtility)1 Joiner (com.emc.storageos.db.joiner.Joiner)1 CapacityResourceType (com.emc.storageos.model.vpool.ManagedResourcesCapacity.CapacityResourceType)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ManagedCapacityImpl (com.emc.storageos.volumecontroller.impl.ManagedCapacityImpl)1 StorageStats (com.emc.vipr.model.sys.healthmonitor.StorageStats)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1