use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method deleteVolumeSnapshot.
private void deleteVolumeSnapshot(StorageSystem storageSystem, URI snapshot, TaskCompleter taskCompleter) {
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
if (blockSnapshot != null && !blockSnapshot.getInactive() && // state against the BlockSnapshot object can be set.
!Strings.isNullOrEmpty(blockSnapshot.getNativeId())) {
_log.info("Deleting snapshot of a volume. Snapshot: {}", snapshot);
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
VolumeSnapshot driverSnapshot = new VolumeSnapshot();
driverSnapshot.setStorageSystemId(storageSystem.getNativeId());
driverSnapshot.setNativeId(blockSnapshot.getNativeId());
driverSnapshot.setParentId(parent.getNativeId());
driverSnapshot.setConsistencyGroup(blockSnapshot.getReplicationGroupInstance());
// call driver
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = driver.deleteVolumeSnapshot(driverSnapshot);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
// update snapshots
blockSnapshot.setInactive(true);
dbClient.updateObject(blockSnapshot);
String msg = String.format("deleteVolumeSnapshot -- Deleted snapshot: %s .", task.getMessage());
_log.info(msg);
taskCompleter.ready(dbClient);
} else {
String errorMsg = String.format("doDeleteSnapshot -- Failed to delete snapshot: %s .", task.getMessage());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.deleteSnapshotFailed("doDeleteSnapshot", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} else if (blockSnapshot != null) {
blockSnapshot.setInactive(true);
dbClient.updateObject(blockSnapshot);
String msg = String.format("deleteVolumeSnapshot -- Deleted snapshot: %s .", blockSnapshot.getId());
_log.info(msg);
taskCompleter.ready(dbClient);
}
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method createVolumeSnapshots.
private void createVolumeSnapshots(StorageSystem storageSystem, List<BlockSnapshot> snapshots, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) {
_log.info("Creating snapshots for volumes.....");
List<VolumeSnapshot> driverSnapshots = new ArrayList<>();
Map<VolumeSnapshot, BlockSnapshot> driverSnapshotToSnapshotMap = new HashMap<>();
// Prepare driver snapshots
String storageSystemNativeId = storageSystem.getNativeId();
for (BlockSnapshot snapshot : snapshots) {
Volume parent = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
VolumeSnapshot driverSnapshot = new VolumeSnapshot();
driverSnapshot.setParentId(parent.getNativeId());
driverSnapshot.setStorageSystemId(storageSystemNativeId);
driverSnapshot.setDisplayName(snapshot.getLabel());
if (readOnly) {
driverSnapshot.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
} else {
driverSnapshot.setAccessStatus(StorageObject.AccessStatus.READ_WRITE);
}
driverSnapshotToSnapshotMap.put(driverSnapshot, snapshot);
driverSnapshots.add(driverSnapshot);
}
// call driver
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = driver.createVolumeSnapshot(Collections.unmodifiableList(driverSnapshots), null);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
// update snapshots
for (VolumeSnapshot driverSnapshot : driverSnapshotToSnapshotMap.keySet()) {
BlockSnapshot snapshot = driverSnapshotToSnapshotMap.get(driverSnapshot);
snapshot.setNativeId(driverSnapshot.getNativeId());
snapshot.setDeviceLabel(driverSnapshot.getDeviceLabel());
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storageSystem, snapshot));
snapshot.setIsSyncActive(true);
snapshot.setReplicationGroupInstance(driverSnapshot.getConsistencyGroup());
if (driverSnapshot.getProvisionedCapacity() > 0) {
snapshot.setProvisionedCapacity(driverSnapshot.getProvisionedCapacity());
}
if (driverSnapshot.getAllocatedCapacity() > 0) {
snapshot.setAllocatedCapacity(driverSnapshot.getAllocatedCapacity());
}
}
dbClient.updateObject(driverSnapshotToSnapshotMap.values());
String msg = String.format("createVolumeSnapshots -- Created snapshots: %s .", task.getMessage());
_log.info(msg);
taskCompleter.ready(dbClient);
} else {
for (BlockSnapshot snapshot : snapshots) {
snapshot.setInactive(true);
}
dbClient.updateObject(snapshots);
String errorMsg = String.format("doCreateSnapshot -- Failed to create snapshots: %s .", task.getMessage());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createSnapshotsFailed("doCreateSnapshot", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class DellSCStorageDriver method deleteConsistencyGroupSnapshot.
/**
* Delete a consistency group snapshot set.
*
* @param snapshots The snapshots to delete.
* @return The delete task.
*/
@Override
public DriverTask deleteConsistencyGroupSnapshot(List<VolumeSnapshot> snapshots) {
LOG.info("Deleting consistency group snapshot");
DellSCDriverTask task = new DellSCDriverTask("deleteConsistencyGroupSnapshot");
StringBuilder errBuffer = new StringBuilder();
int deletedCount = 0;
for (VolumeSnapshot snapshot : snapshots) {
DriverTask subTask = snapshotHelper.deleteVolumeSnapshot(snapshot);
if (subTask.getStatus() == TaskStatus.FAILED) {
errBuffer.append(String.format("%s%n", subTask.getMessage()));
} else {
deletedCount++;
}
}
task.setMessage(errBuffer.toString());
if (deletedCount == snapshots.size()) {
task.setStatus(TaskStatus.READY);
} else if (deletedCount == 0) {
task.setStatus(TaskStatus.FAILED);
} else {
task.setStatus(TaskStatus.PARTIALLY_FAILED);
}
return task;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class DellSCConsistencyGroups method populateCgSnapshotInfo.
/**
* Populates VolumeSnapshot info from CG created replays.
*
* @param snapshots The expected VolumeSnapshot objects.
* @param replays The created replays.
* @return True if successful, false if errors encountered.
*/
private boolean populateCgSnapshotInfo(List<VolumeSnapshot> snapshots, ScReplay[] replays) {
boolean complete = true;
for (VolumeSnapshot snapshot : snapshots) {
boolean found = false;
for (ScReplay replay : replays) {
if (replay.instanceId.startsWith(snapshot.getParentId())) {
// Found match, populate the info
util.getVolumeSnapshotFromReplay(replay, snapshot);
found = true;
break;
}
}
if (!found) {
complete = false;
LOG.warn("Unable to find snapshot for {}", snapshot.getDisplayName());
}
}
return complete;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class DellSCDiscovery method getVolumeSnapshots.
/**
* Gets all snapshots for a volume.
*
* @param storageVolume The volume.
* @return The snapshots.
*/
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume storageVolume) {
LOG.info("Getting snapshots for {}", storageVolume.getNativeId());
List<VolumeSnapshot> result = new ArrayList<>();
try {
StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
ScReplay[] replays = api.getVolumeSnapshots(storageVolume.getNativeId());
for (ScReplay replay : replays) {
VolumeSnapshot snap = util.getVolumeSnapshotFromReplay(replay, null);
result.add(snap);
}
} catch (DellSCDriverException e) {
String msg = String.format("Error getting volume info: %s", e);
LOG.warn(msg);
}
return result;
}
Aggregations