Search in sources :

Example 61 with StoragePool

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;
}
Also used : StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 62 with StoragePool

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);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)

Example 63 with StoragePool

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;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI)

Example 64 with 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();
                        }
                    }
                }
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 65 with StoragePool

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;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30