Search in sources :

Example 96 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class CinderCommunicationInterface method checkPoolExistsInDB.

/**
 * Check if Pool exists in DB.
 *
 * @param poolInstance
 * @param _dbClient
 * @param profile
 * @return
 * @throws IOException
 */
protected StoragePool checkPoolExistsInDB(String nativeGuid) throws IOException {
    StoragePool pool = null;
    URIQueryResultList queryResult = new URIQueryResultList();
    // use NativeGuid to lookup Pools in DB
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(nativeGuid), queryResult);
    while (queryResult.iterator().hasNext()) {
        URI poolURI = queryResult.iterator().next();
        if (null != poolURI) {
            StoragePool poolInDB = _dbClient.queryObject(StoragePool.class, poolURI);
            if (!poolInDB.getInactive()) {
                pool = poolInDB;
                break;
            }
        }
    }
    return pool;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 97 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method getPoolFromDB.

private StoragePool getPoolFromDB(StorageSystem system) {
    String nativeGid = NativeGUIDGenerator.generateNativeGuid(system, system.getNativeGuid(), NativeGUIDGenerator.POOL);
    URIQueryResultList storagePoolList = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(nativeGid), storagePoolList);
    Iterator<URI> poolItr = storagePoolList.iterator();
    while (poolItr.hasNext()) {
        StoragePool pool = _dbClient.queryObject(StoragePool.class, poolItr.next());
        if (pool.getStorageDevice().equals(system.getId())) {
            return pool;
        }
    }
    return null;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 98 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class HDSCommunicationInterface method checkPoolExistsInDB.

/**
 * Check if Pool exists in DB.
 *
 * @param poolInstance
 * @param _dbClient
 * @param profile
 * @return
 * @throws IOException
 */
protected StoragePool checkPoolExistsInDB(String nativeGuid) throws IOException {
    StoragePool pool = null;
    // use NativeGuid to lookup Pools in DB
    List<StoragePool> poolInDB = CustomQueryUtility.getActiveStoragePoolByNativeGuid(_dbClient, nativeGuid);
    if (poolInDB != null && !poolInDB.isEmpty()) {
        pool = poolInDB.get(0);
    }
    return pool;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool)

Example 99 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class ScaleIOCloneOperations method createGroupClone.

@Override
public void createGroupClone(StorageSystem storage, List<URI> cloneList, Boolean createInactive, TaskCompleter taskCompleter) {
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
        List<Volume> clones = dbClient.queryObject(Volume.class, cloneList);
        Map<String, String> parent2snap = new HashMap<>();
        Set<URI> poolsToUpdate = new HashSet<>();
        for (Volume clone : clones) {
            Volume parent = dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
            parent2snap.put(parent.getNativeId(), clone.getLabel());
            poolsToUpdate.add(parent.getPool());
        }
        String systemId = scaleIOHandle.getSystemId();
        ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
        List<String> nativeIds = result.getVolumeIdList();
        Map<String, ScaleIOVolume> cloneNameMap = scaleIOHandle.getVolumeNameMap(nativeIds);
        Multimap<URI, String> poolToVolumesMap = ArrayListMultimap.create();
        for (Volume clone : clones) {
            String name = clone.getLabel();
            ScaleIOVolume sioVolume = cloneNameMap.get(name);
            ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, clone, systemId, sioVolume.getId(), storage);
            clone.setAllocatedCapacity(Long.parseLong(sioVolume.getSizeInKb()) * 1024L);
            clone.setProvisionedCapacity(clone.getAllocatedCapacity());
            clone.setCapacity(clone.getAllocatedCapacity());
            clone.setReplicationGroupInstance(result.getSnapshotGroupId());
            poolToVolumesMap.put(clone.getPool(), clone.getId().toString());
        }
        dbClient.updateObject(clones);
        List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
        for (StoragePool pool : pools) {
            pool.removeReservedCapacityForVolumes(poolToVolumesMap.get(pool.getId()));
            ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
        }
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupClone", e.getMessage());
        taskCompleter.error(dbClient, code);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ScaleIOSnapshotVolumeResponse(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) HashSet(java.util.HashSet)

Example 100 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class ScaleIOCloneOperations method createSingleClone.

@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceVolume, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storageSystem);
        Volume cloneObj = dbClient.queryObject(Volume.class, cloneVolume);
        BlockObject parent = BlockObject.fetch(dbClient, sourceVolume);
        String systemId = scaleIOHandle.getSystemId();
        // Note: ScaleIO snapshots can be treated as full copies, hence re-use of #snapshotVolume here.
        ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotVolume(parent.getNativeId(), cloneObj.getLabel(), systemId);
        String nativeId = result.getVolumeIdList().get(0);
        ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, cloneObj, systemId, nativeId, storageSystem);
        // Snapshots result does not provide capacity info, so we need to perform a queryVolume
        updateCloneFromQueryVolume(scaleIOHandle, cloneObj);
        dbClient.updateObject(cloneObj);
        StoragePool pool = dbClient.queryObject(StoragePool.class, cloneObj.getPool());
        pool.removeReservedCapacityForVolumes(Arrays.asList(cloneObj.getId().toString()));
        ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, cloneObj);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
        if (clone != null) {
            clone.setInactive(true);
            dbClient.updateObject(clone);
        }
        log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, code);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ScaleIOSnapshotVolumeResponse(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) BlockObject(com.emc.storageos.db.client.model.BlockObject)

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