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