use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse 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);
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse 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);
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method createGroupSnapshots.
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
List<BlockSnapshot> blockSnapshots = dbClient.queryObject(BlockSnapshot.class, snapshotList);
Map<String, String> parent2snap = new HashMap<>();
Set<URI> poolsToUpdate = new HashSet<>();
for (BlockSnapshot blockSnapshot : blockSnapshots) {
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
parent2snap.put(parent.getNativeId(), blockSnapshot.getLabel());
poolsToUpdate.add(parent.getPool());
}
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
List<String> nativeIds = result.getVolumeIdList();
Map<String, String> snapNameIdMap = scaleIOHandle.getVolumes(nativeIds);
ScaleIOHelper.updateSnapshotsWithSnapshotMultiVolumeResult(dbClient, blockSnapshots, systemId, snapNameIdMap, result.getSnapshotGroupId(), storage);
dbClient.persistObject(blockSnapshots);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSnapshotVolumeResponse in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotVolume(parent.getNativeId(), blockSnapshot.getLabel(), systemId);
String nativeId = result.getVolumeIdList().get(0);
ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, blockSnapshot, systemId, nativeId, storage);
dbClient.persistObject(blockSnapshot);
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, blockSnapshot);
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
Aggregations