use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VirtualPoolService method refreshMatchedPools.
/**
* Refresh the matching pools by running implicit pool matcher algorithm and
* find if there are any new matched pools exists in the environment.
* Returns the new matched pools to user.
*
* @param id the URN of a ViPR VirtualPool.
* @return : list of pools.
*/
protected StoragePoolList refreshMatchedPools(VirtualPool.Type type, URI id) {
ArgValidator.checkUri(id);
StoragePoolList poolList = new StoragePoolList();
VirtualPool vpool = queryResource(id);
ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
if (!vpool.getType().equals(type.name())) {
throw APIException.badRequests.providedVirtualPoolNotCorrectType();
}
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchVirtualPoolWithAllStoragePools(vpool, _dbClient, _coordinator, errorMessage);
_dbClient.updateAndReindexObject(vpool);
StringSet matchedPools = vpool.getMatchedStoragePools();
if (null != matchedPools && !matchedPools.isEmpty()) {
Iterator<String> vpoolItr = matchedPools.iterator();
while (vpoolItr.hasNext()) {
URI poolURI = URI.create(vpoolItr.next());
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolURI);
if (pool == null) {
continue;
}
poolList.getPools().add(toNamedRelatedResource(pool));
}
}
return poolList;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method handlePlacementFailure.
/**
* Set volumes to inactive state.
* Release reserved capacity for volumes in their storage pools.
* @param volumesList volumes to process.
*/
public void handlePlacementFailure(List<Volume> volumesList) {
Map<URI, StoragePool> uriToStoragePool = new HashMap<>();
Map<URI, List<String>> storagePoolUriToVolumes = new HashMap<>();
for (Volume volume : volumesList) {
volume.setInactive(true);
URI storagePoolUri = volume.getPool();
if (!(URIUtil.isNull(storagePoolUri) || URIUtil.isNull(volume.getId()))) {
List<String> poolVolumes = storagePoolUriToVolumes.get(storagePoolUri);
if (poolVolumes == null) {
poolVolumes = new ArrayList<>();
storagePoolUriToVolumes.put(storagePoolUri, poolVolumes);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolUri);
if (storagePool != null) {
uriToStoragePool.put(storagePoolUri, storagePool);
}
}
poolVolumes.add(volume.getId().toString());
}
}
_dbClient.updateObject(volumesList);
for (URI poolUri : uriToStoragePool.keySet()) {
StoragePool pool = uriToStoragePool.get(poolUri);
List<String> volumes = storagePoolUriToVolumes.get(poolUri);
pool.removeReservedCapacityForVolumes(volumes);
_dbClient.updateObject(pool);
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class BlockFullCopyUtils method queryFullCopySourceStoragePool.
/**
* Returns the vpool for the full copy source.
*
* @param fcSourceObj A reference to the Volume or BlockSnapshot instance.
* @param dbClient A reference to a database client.
*
* @return A reference to the vpool for the full copy source.
*/
public static StoragePool queryFullCopySourceStoragePool(BlockObject fcSourceObj, DbClient dbClient) {
URI fcSourceURI = fcSourceObj.getId();
URI poolURI = null;
if (URIUtil.isType(fcSourceURI, Volume.class)) {
poolURI = ((Volume) fcSourceObj).getPool();
} else if (URIUtil.isType(fcSourceURI, BlockSnapshot.class)) {
URI parentVolURI = ((BlockSnapshot) fcSourceObj).getParent().getURI();
Volume parentVolume = dbClient.queryObject(Volume.class, parentVolURI);
poolURI = parentVolume.getPool();
} else {
throw APIException.badRequests.invalidFullCopySource(fcSourceURI.toString());
}
StoragePool storagePool = null;
if (!NullColumnValueGetter.isNullURI(poolURI)) {
storagePool = dbClient.queryObject(StoragePool.class, poolURI);
}
return storagePool;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method validateFullCopyCreateRequest.
/**
* {@inheritDoc}
*/
@Override
public void validateFullCopyCreateRequest(List<BlockObject> fcSourceObjList, int count) {
if (!fcSourceObjList.isEmpty()) {
BlockObject fcsourceObj = fcSourceObjList.get(0);
URI fcSourceObjURI = fcsourceObj.getId();
if (URIUtil.isType(fcSourceObjURI, BlockSnapshot.class) && !BlockServiceUtils.isSnapshotFullCopySupported(fcSourceObjURI, _dbClient)) {
// Snapshot full copy is supported only for OpenStack, VNXBlock, VMAX and IBMXIV
throw APIException.badRequests.cantCreateFullCopyForVPlexSnapshot();
}
// Group clone for IBM XIV storage system type is not supported
if (null != fcsourceObj.getConsistencyGroup() && VPlexUtil.isIBMXIVBackend(fcsourceObj, _dbClient)) {
throw APIException.methodNotAllowed.notSupportedWithReason("Consistency Group Full Copy is not supported on backend IBM XIV storage systems");
}
// Call super first.
super.validateFullCopyCreateRequest(fcSourceObjList, count);
// all the volumes in vplex cg should be having association with back end cg/Volume Group.
if (VPlexUtil.isBackendVolumesNotHavingBackendCG(fcSourceObjList, _dbClient)) {
throw APIException.badRequests.fullcopyNotAllowedWhenBackendVolumeDoestHavingCG();
}
for (BlockObject fcSourceObj : fcSourceObjList) {
if (fcSourceObj instanceof Volume) {
Volume fcSourceVolume = (Volume) fcSourceObj;
// we don't support creation of a full copy.
if (VPlexUtil.isVolumeBuiltOnBlockSnapshot(_dbClient, fcSourceVolume)) {
throw APIException.badRequests.fullCopyNotAllowedVolumeIsExposedSnapshot(fcSourceVolume.getId().toString());
}
StorageSystem system = _dbClient.queryObject(StorageSystem.class, fcSourceObj.getStorageController());
if (DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType())) {
// If the volume is a VPLEX volume, then we need to be sure that
// storage pool of the source backend volume of the VPLEX volume,
// which is volume used to create the native full copy, supports
// full copy.
Volume srcBackendVolume = VPlexUtil.getVPLEXBackendVolume(fcSourceVolume, true, _dbClient, true);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, srcBackendVolume.getPool());
verifyFullCopySupportedForStoragePool(storagePool);
// volume will fail. As such, we prevent it.
if ((BlockFullCopyUtils.isVolumeFullCopy(fcSourceVolume, _dbClient)) && (!BlockFullCopyUtils.isFullCopyDetached(fcSourceVolume, _dbClient))) {
URI backendSystemURI = srcBackendVolume.getStorageController();
StorageSystem backendSystem = _dbClient.queryObject(StorageSystem.class, backendSystemURI);
if (DiscoveredDataObject.Type.vnxblock.name().equals(backendSystem.getSystemType())) {
throw APIException.badRequests.cantCreateFullCopyOfVPlexFullCopyUsingVNX();
}
}
}
}
}
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VmaxCapacityCalculator method calculateAllocatedCapacity.
/**
* {@inheritDoc}
*/
@Override
public Long calculateAllocatedCapacity(Long requestedCapacity, Volume volume, DbClient dbClient) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
if (requestedCapacity != null) {
long bytesPerCylinder = 0L;
if (storageSystem != null && storageSystem.checkIfVmax3()) {
bytesPerCylinder = (tracksPerCylinder * blocksPerTrackVMAX3 * bytesPerBlock);
} else {
bytesPerCylinder = (tracksPerCylinder * blocksPerTrack * bytesPerBlock);
VirtualPool vPool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
StoragePool storagePool = dbClient.queryObject(StoragePool.class, volume.getPool());
// Determine if we are provisioning meta volumes. Meta volume provisioning only applies to non-VMAX3.
MetaVolumeRecommendation metaRecommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, requestedCapacity, volume.getThinlyProvisioned(), vPool.getFastExpansion(), null);
if (metaRecommendation.isCreateMetaVolumes()) {
long metaCount = metaRecommendation.getMetaMemberCount();
long metaSize = metaRecommendation.getMetaMemberSize();
long metaCylinderCount = getCylinderCount(metaSize, bytesPerCylinder);
long allocatedSingleMetaCapacity = (metaCylinderCount * bytesPerCylinder);
// Return the total meta allocation size
long allocatedMetaCapacity = (metaCount * allocatedSingleMetaCapacity);
logger.info(String.format("Determined that volume %s is being provisioned as meta volumes. Allocated capacity per meta will be %d. Total volume allocation (%d metas) will be %d.", volume.getLabel(), allocatedSingleMetaCapacity, metaCount, allocatedMetaCapacity));
return allocatedMetaCapacity;
}
}
long cyls = getCylinderCount(requestedCapacity, bytesPerCylinder);
return (cyls * bytesPerCylinder);
}
return requestedCapacity;
}
Aggregations