Search in sources :

Example 1 with ManagedResourceCapacity

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

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

the class ManagedCapacityImpl method run.

public void run() {
    if (Thread.currentThread().isInterrupted()) {
        return;
    } else {
        try {
            List<ManagedResourceCapacity> capList = getManagedCapacity().getResourceCapacityList();
            for (ManagedResourceCapacity cap : capList) {
                CapacityPropertyListTypes type = mapCapacityType(cap.getType());
                PropertyListDataObject resource = map(cap, type.toString());
                List<URI> dataResourcesURI = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getConstraint(PropertyListDataObject.class, "resourceType", type.toString()));
                if (!dataResourcesURI.isEmpty()) {
                    resource.setId(dataResourcesURI.get(0));
                    resource.setCreationTime(Calendar.getInstance());
                    dbClient.updateAndReindexObject(resource);
                } else {
                    resource.setId(URIUtil.createId(PropertyListDataObject.class));
                    dbClient.createObject(resource);
                }
            }
        } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
        }
    }
}
Also used : PropertyListDataObject(com.emc.storageos.db.client.model.PropertyListDataObject) ManagedResourceCapacity(com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity) URI(java.net.URI)

Example 3 with ManagedResourceCapacity

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

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

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

ManagedResourceCapacity (com.emc.storageos.model.vpool.ManagedResourcesCapacity.ManagedResourceCapacity)5 ManagedResourcesCapacity (com.emc.storageos.model.vpool.ManagedResourcesCapacity)4 PropertyListDataObject (com.emc.storageos.db.client.model.PropertyListDataObject)2 URI (java.net.URI)2 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