use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class HP3PARSnapshotHelper method restoreSnapshot.
public DriverTask restoreSnapshot(List<VolumeSnapshot> snapshots, DriverTask task, Registry driverRegistry) {
// 3par system)
for (VolumeSnapshot snap : snapshots) {
try {
_log.info("3PARDriver: restoreSnapshot for storage system system id {}, snapshot name {} , native id {} , all = {} - start", snap.getStorageSystemId(), snap.getDisplayName(), snap.getNativeId(), snap.toString());
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(snap.getStorageSystemId(), driverRegistry);
// restore virtual copy
hp3parApi.restoreVirtualCopy(snap.getNativeId());
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("3PARDriver: restoreSnapshot for storage system id {}, snapshot display name {} - end", snap.getStorageSystemId(), snap.getDisplayName());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to restore snapshot display name %s with native id %s for storage system id %s; Error: %s.\n", snap.getDisplayName(), snap.getNativeId(), snap.getStorageSystemId(), e.getMessage());
_log.error(msg);
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
e.printStackTrace();
}
}
return task;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class DellSCUtil method getVolumeSnapshotFromReplay.
/**
* Gets a VolumeSnapshot object for a given replay.
*
* @param replay The Storage Center snapshot.
* @param snapshot The VolumeSnapshot object to populate or null.
* @return The VolumeSnapshot object.
*/
public VolumeSnapshot getVolumeSnapshotFromReplay(ScReplay replay, VolumeSnapshot snapshot) {
VolumeSnapshot snap = snapshot;
if (snap == null) {
snap = new VolumeSnapshot();
}
snap.setNativeId(replay.instanceId);
snap.setDeviceLabel(replay.instanceName);
snap.setDisplayName(replay.instanceName);
snap.setStorageSystemId(String.valueOf(replay.scSerialNumber));
snap.setWwn(replay.globalIndex);
snap.setParentId(replay.createVolume.instanceId);
snap.setAllocatedCapacity(SizeUtil.sizeStrToBytes(replay.size));
snap.setProvisionedCapacity(SizeUtil.sizeStrToBytes(replay.size));
return snap;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class DellSCSnapshots method createVolumeSnapshot.
/**
* Create volume snapshots.
*
* @param snapshots The list of snapshots to create.
* @param storageCapabilities The requested capabilities of the snapshots.
* @return The snapshot creation task.
*/
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities storageCapabilities) {
DellSCDriverTask task = new DellSCDriverTask("createVolumeSnapshot");
StringBuilder errBuffer = new StringBuilder();
int createCount = 0;
for (VolumeSnapshot snapshot : snapshots) {
try {
StorageCenterAPI api = connectionManager.getConnection(snapshot.getStorageSystemId());
// Make sure we can create a replay.
// Automated tests have an artificial workflow where they create a volume
// and try to create a snapshot without ever having data written to it. The
// SC array will not activate a volume until it is mapped, so if we try to
// create a snapshot right away it will fail. As a workaround, since we know
// this should only ever happen in a test scenario, we temporarily map/unmap
// it to get it to be activated.
api.checkAndInitVolume(snapshot.getParentId());
ScReplay replay = api.createReplay(snapshot.getParentId());
util.getVolumeSnapshotFromReplay(replay, snapshot);
createCount++;
} catch (DellSCDriverException | StorageCenterAPIException dex) {
String error = String.format("Error creating snapshot of volume %s: %s", snapshot.getParentId(), dex);
errBuffer.append(String.format("%s%n", error));
}
}
task.setMessage(errBuffer.toString());
if (createCount == snapshots.size()) {
task.setStatus(TaskStatus.READY);
} else if (createCount == 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 StorageDriverSimulator method getVolumeSnapshots.
@Override
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume volume) {
List<VolumeSnapshot> snapshots = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_SNAPS_FOR_VOLUME; i++) {
VolumeSnapshot snapshot = new VolumeSnapshot();
snapshot.setParentId(volume.getNativeId());
snapshot.setNativeId(volume.getNativeId() + "snap-" + i);
snapshot.setDeviceLabel(volume.getNativeId() + "snap-" + i);
snapshot.setStorageSystemId(volume.getStorageSystemId());
snapshot.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
if (SNAPS_IN_CG) {
snapshot.setConsistencyGroup(volume.getConsistencyGroup() + "snapSet-" + i);
}
snapshot.setAllocatedCapacity(1000L);
snapshot.setProvisionedCapacity(volume.getProvisionedCapacity());
snapshot.setWwn(String.format("%s%s", snapshot.getStorageSystemId(), snapshot.getNativeId()));
snapshots.add(snapshot);
if (GENERATE_EXPORT_DATA) {
// generate export data for this snap --- the same export data as for its parent volume
generateExportDataForVolumeReplica(volume, snapshot);
}
}
return snapshots;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method createConsistencyGroupSnapshot.
@Override
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup consistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities) {
String snapTimestamp = Long.toString(System.currentTimeMillis());
for (VolumeSnapshot snapshot : snapshots) {
snapshot.setNativeId("snap-" + snapshot.getParentId() + consistencyGroup.getDisplayName() + UUID.randomUUID().toString());
snapshot.setConsistencyGroup(snapTimestamp);
snapshot.setSnapSetId(snapTimestamp);
}
String taskType = "create-group-snapshot";
String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
DriverTask task = new DriverSimulatorTask(taskId);
task.setStatus(DriverTask.TaskStatus.READY);
task.setMessage("Created snapshots for consistency group " + snapshots.get(0).getConsistencyGroup());
_log.info("StorageDriver: createGroupSnapshot information for storage system {}, snapshots nativeIds {} - end", snapshots.get(0).getStorageSystemId(), snapshots.toString());
return task;
}
Aggregations