use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class HP3PARCGHelper method createConsistencyGroupSnapshot.
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup consistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities, DriverTask task, Registry driverRegistry) {
_log.info("3PARDriver: createConsistencyGroupSnapshot for storage system id {}, display name {} , native id {} - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
String VVsetSnapshotName = consistencyGroup.getDisplayName();
VolumeDetailsCommandResult volResult = null;
try {
Boolean readOnly = true;
int noOfSnaps = snapshots.size();
// get Vipr generated Snapshot name
for (VolumeSnapshot snap : snapshots) {
// native id = null ,
_log.info("3PARDriver: createConsistencyGroupSnapshot for volume native id {}, snap shot name generated is {} ", snap.getParentId(), snap.getDisplayName());
if (snap.getAccessStatus() != AccessStatus.READ_ONLY) {
readOnly = false;
}
String generatedSnapshotName = snap.getDisplayName();
if (noOfSnaps > 1) {
VVsetSnapshotName = generatedSnapshotName.substring(0, generatedSnapshotName.lastIndexOf("-")) + "-";
} else {
VVsetSnapshotName = generatedSnapshotName;
}
_log.info("3PARDriver: createConsistencyGroupSnapshot VVsetSnapshotName {} ", VVsetSnapshotName);
break;
}
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
// Create vvset snapshot
hp3parApi.createVVsetVirtualCopy(consistencyGroup.getNativeId(), VVsetSnapshotName, readOnly);
int volumeNumber = 0;
int snapVolumeCount = snapshots.size();
while (volumeNumber < snapVolumeCount) {
String snapshotCreated = VVsetSnapshotName + volumeNumber;
_log.info("3PARDriver: createConsistencyGroupSnapshot snapshotCreated {}, volumeNumber {} , snapVolumeCount {} ", snapshotCreated, volumeNumber, snapVolumeCount);
volResult = hp3parApi.getVolumeDetails(VVsetSnapshotName + volumeNumber);
if (volResult != null) {
String baseVolume = volResult.getCopyOf();
if (baseVolume != null) {
for (VolumeSnapshot snap : snapshots) {
String parentName = snap.getParentId();
if (parentName.equals(baseVolume)) {
_log.info("createConsistencyGroupSnapshot Snapshot system native id {}, Parent id {}, base volume {}, " + "access status {}, display name {}, native Name {}, DeviceLabel {}, wwn {} - Before ", snap.getStorageSystemId(), snap.getParentId(), baseVolume, snap.getAccessStatus(), snap.getDisplayName(), snap.getNativeId(), snap.getDeviceLabel(), snap.getWwn());
snap.setWwn(volResult.getWwn());
snap.setNativeId(volResult.getName());
snap.setDeviceLabel(volResult.getName());
// snap.setAccessStatus(volResult.getAccessStatus());
snap.setDisplayName(volResult.getName());
_log.info("createConsistencyGroupSnapshot Snapshot system native id {}, Parent Volume {}, access status {}, display name {}," + " native Name {}, DeviceLabel {}, wwn {} - After", snap.getStorageSystemId(), snap.getParentId(), snap.getAccessStatus(), snap.getDisplayName(), snap.getNativeId(), snap.getDeviceLabel(), snap.getWwn());
}
}
} else {
_log.info("3PARDriver: createConsistencyGroupSnapshot baseVolume is null");
}
}
volumeNumber++;
}
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createConsistencyGroupSnapshot for storage system native id {}, CG display Name {}, CG native id {} - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to create vv set snap name %s and its native id %s whose storage system id is %s; Error: %s.\n", VVsetSnapshotName, consistencyGroup.getNativeId(), consistencyGroup.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 StorageDriverSimulator method createVolumeSnapshot.
@Override
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities capabilities) {
String snapTimestamp = Long.toString(System.currentTimeMillis());
for (VolumeSnapshot snapshot : snapshots) {
snapshot.setNativeId("snap-" + snapshot.getParentId() + UUID.randomUUID().toString());
snapshot.setConsistencyGroup(snapTimestamp);
snapshot.setAllocatedCapacity(1000L);
snapshot.setProvisionedCapacity(2000L);
}
String taskType = "create-volume-snapshot";
String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
DriverTask task = new DriverSimulatorTask(taskId);
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("StorageDriver: createVolumeSnapshot information for storage system {}, snapshots nativeIds {} - end", snapshots.get(0).getStorageSystemId(), snapshots.toString());
return task;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class RestoreFromSnapshotSimulatorOperation method getSuccessMessage.
@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
List<VolumeSnapshot> snapshots;
if ((args != null) && (args.length > 0)) {
snapshots = (List<VolumeSnapshot>) args[0];
} else {
// Must be asynchronous, so updated snapshots are in the task.
RestoreFromSnapshotDriverTask restoreSnapshotTask = (RestoreFromSnapshotDriverTask) _task;
snapshots = restoreSnapshotTask.getSnapshots();
}
return String.format("StorageDriver: restoreSnapshot for storage system %s, snapshots nativeId %s, snap group %s - end", snapshots.get(0).getStorageSystemId(), snapshots.toString(), snapshots.get(0).getConsistencyGroup());
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class HP3PARIngestHelper method getVolumeSnapshots.
/**
* Identifying snapshots of the given parent base volume. NOTE: Intermediate
* virtual copies of 3PAR generated from other snapshots/clone are shown as
* snapshots of base volume itself
*/
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume volume, Registry registry) {
_log.info("3PARDriver: getVolumeSnapshots Running ");
List<VolumeSnapshot> snapshots = new ArrayList<>();
try {
Map<String, List<String>> vvolAssociations = registry.getDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, volume.getStorageSystemId() + "____VVOL_ASSOCIATIONS");
_log.info("vvolAssociations is {}", vvolAssociations.toString());
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(volume.getStorageSystemId(), registry);
ArrayList<String> listOfChildVols = null;
listOfChildVols = (ArrayList<String>) vvolAssociations.get(volume.getNativeId());
_log.info("listOfChildVols.size() is {}", listOfChildVols.size());
for (String childName : listOfChildVols) {
// VolumeDetailsCommandResult is the data structure used for representation of
// the HP3PAR virtual volume
// VolumeSnapshot is the CoprHD southbound freamework's
// datastructure
VolumeSnapshot driverSnapshot = new VolumeSnapshot();
VolumeDetailsCommandResult resultSnap = hp3parApi.getVolumeDetails(childName);
if (resultSnap.getCopyType() == copyType.VIRTUAL_COPY.getValue()) {
driverSnapshot.setParentId(volume.getNativeId());
driverSnapshot.setNativeId(resultSnap.getName());
driverSnapshot.setDeviceLabel(resultSnap.getName());
driverSnapshot.setStorageSystemId(volume.getStorageSystemId());
driverSnapshot.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
if (volume.getConsistencyGroup() != null) {
driverSnapshot.setConsistencyGroup(volume.getConsistencyGroup());
}
driverSnapshot.setWwn(resultSnap.getWwn());
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = resultSnap.getUserSpace().getReservedMiB();
allocatedCapacity += resultSnap.getSnapshotSpace().getReservedMiB();
allocatedCapacity += resultSnap.getAdminSpace().getReservedMiB();
driverSnapshot.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
driverSnapshot.setProvisionedCapacity(resultSnap.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
snapshots.add(driverSnapshot);
}
}
_log.info("3PARDriver: getVolumeSnapshots Leaving");
return snapshots;
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get snapshot of volume with storage system %s and volume native id %s; Error: %s.\n", volume.getStorageSystemId(), volume.getNativeId(), e.getMessage());
_log.error(msg);
e.printStackTrace();
}
_log.info("3PARDriver: getVolumeSnapshots Leaving");
return null;
}
use of com.emc.storageos.storagedriver.model.VolumeSnapshot in project coprhd-controller by CoprHD.
the class HP3PARSnapshotHelper method createVolumeSnapshot.
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities capabilities, DriverTask task, Registry driverRegistry) {
for (VolumeSnapshot snap : snapshots) {
try {
// native id = null ,
_log.info("3PARDriver: createVolumeSnapshot for storage system native id {}, snapshot name {}, parent id {}- start", snap.getNativeId(), snap.getDisplayName(), snap.getParentId());
Boolean readOnly = true;
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(snap.getStorageSystemId(), driverRegistry);
VolumeDetailsCommandResult volResult = null;
if (snap.getAccessStatus() != AccessStatus.READ_ONLY) {
readOnly = false;
}
// Create volume snapshot
hp3parApi.createVirtualCopy(snap.getParentId(), snap.getDisplayName(), readOnly);
volResult = hp3parApi.getVolumeDetails(snap.getDisplayName());
// Actual size of the volume in array
snap.setProvisionedCapacity(volResult.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
snap.setWwn(volResult.getWwn());
// required for volume
snap.setNativeId(snap.getDisplayName());
// delete
snap.setDeviceLabel(snap.getDisplayName());
snap.setAccessStatus(snap.getAccessStatus());
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createVolumeSnapshot for storage system native id {}, snapshot name {}, parent id {} - end", snap.getStorageSystemId(), snap.getDisplayName(), snap.getParentId());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to create volume snap name %s for parent base volume id %s whose storage system native id is %s; Error: %s.\n", snap.getDisplayName(), snap.getParentId(), snap.getStorageSystemId(), e.getMessage());
_log.error(msg);
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
e.printStackTrace();
}
}
return task;
}
Aggregations