Search in sources :

Example 11 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIOStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    int index = 1;
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
        String protectionDomainName = storage.getSerialNumber();
        Long volumeSize = capabilities.getSize() / ScaleIOHelper.BYTES_IN_GB;
        int count = volumes.size();
        Set<URI> poolsToUpdate = new HashSet<>();
        boolean thinlyProvisioned = capabilities.getThinProvisioning();
        Set<URI> consistencyGroups = new HashSet<>();
        Multimap<URI, String> poolToVolumesMap = ArrayListMultimap.create();
        String systemId = scaleIOHandle.getSystemId();
        for (; index <= count; index++) {
            Volume volume = volumes.get(index - 1);
            Long size = capabilities.getSize();
            String poolId = storagePool.getNativeId();
            ScaleIOVolume result = scaleIOHandle.addVolume(protectionDomainName, poolId, volume.getLabel(), size.toString(), thinlyProvisioned);
            ScaleIOHelper.updateVolumeWithAddVolumeInfo(dbClient, volume, systemId, volumeSize, result);
            poolsToUpdate.add(volume.getPool());
            if (!NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
                consistencyGroups.add(volume.getConsistencyGroup());
            }
            poolToVolumesMap.put(volume.getPool(), volume.getId().toString());
        }
        updateConsistencyGroupsWithStorageSystem(consistencyGroups, storage);
        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);
        }
        dbClient.persistObject(volumes);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error("Encountered an exception", e);
        for (int cleanup = index; cleanup <= volumes.size(); cleanup++) {
            volumes.get(cleanup - 1).setInactive(true);
        }
        dbClient.persistObject(volumes);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("addVolume", e.getMessage());
        taskCompleter.error(dbClient, code);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) Volume(com.emc.storageos.db.client.model.Volume) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) HashSet(java.util.HashSet)

Aggregations

ScaleIOVolume (com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume)11 ScaleIORestClient (com.emc.storageos.scaleio.api.restapi.ScaleIORestClient)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 ScaleIOException (com.emc.storageos.scaleio.ScaleIOException)3 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)3 URI (java.net.URI)3 HashMap (java.util.HashMap)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 Volume (com.emc.storageos.db.client.model.Volume)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ScaleIOCreateVolume (com.emc.storageos.scaleio.api.restapi.request.ScaleIOCreateVolume)2 ScaleIOVolumeList (com.emc.storageos.scaleio.api.restapi.request.ScaleIOVolumeList)2 HashSet (java.util.HashSet)2 ScaleIODataMapper (com.emc.storageos.api.mapper.ScaleIODataMapper)1 ScaleIOCollectDataParam (com.emc.storageos.model.collectdata.ScaleIOCollectDataParam)1 ScaleIODeviceDataRestRep (com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep)1 ScaleIOSDCDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep)1 ScaleIOSDSDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep)1 ScaleIOSystemDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep)1