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;
}
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();
}
}
}
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);
}
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;
}
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;
}
Aggregations