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