use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class CreateGroupCloneSimulatorOperation method updateGroupCloneInfo.
/**
* Update the clone information after successfully being created.
*
* @param consistencyGroup A reference to the consistency group.
* @param clones A list of the clones to be updated.
*/
public void updateGroupCloneInfo(VolumeConsistencyGroup consistencyGroup, List<VolumeClone> clones) {
String cloneTimestamp = Long.toString(System.currentTimeMillis());
for (VolumeClone clone : clones) {
clone.setNativeId("clone-" + clone.getParentId() + clone.getDisplayName());
clone.setWwn(String.format("%s%s", clone.getStorageSystemId(), clone.getNativeId()));
clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
clone.setProvisionedCapacity(clone.getRequestedCapacity());
clone.setAllocatedCapacity(clone.getRequestedCapacity());
clone.setDeviceLabel(clone.getNativeId());
clone.setConsistencyGroup(consistencyGroup.getNativeId() + "_clone-" + cloneTimestamp);
}
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class HP3PARCGHelper method createConsistencyGroupClone.
/**
* Creating physical copy for VVset or CG clone Rest API expects created
* VVset with its corresponding volumes types for clone destination So,
* There are many ways for implementation
*
* 1. Customer will provide the VVSet name which already exist in Array
* with its corresponding similar volumes for cloning
*
* 2. Customer will not provide any existing and matching VV set with
* corresponding volumes for CG clone
*
* 3. Customer will provide VVset name which is created but volumes are not
* matching for clone creation.
*
* Create new VV Set / CG . Create new volumes similar to parent VVSet
* volumes Use this newly created VV set for CG clone
*
* option 2 is implemented, need to handle negative / error cases of option
* 3
*/
public DriverTask createConsistencyGroupClone(VolumeConsistencyGroup consistencyGroup, List<VolumeClone> clones, List<CapabilityInstance> capabilities, DriverTask task, Registry driverRegistry) {
_log.info("3PARDriver: createConsistencyGroupClone for storage system id {}, Base CG name {} , Base CG native id {} - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
String VVsetNameForClone = consistencyGroup.getDisplayName();
VolumeDetailsCommandResult volResult = null;
HashMap<String, VolumeClone> clonesMap = new HashMap<String, VolumeClone>();
try {
Boolean saveSnapshot = true;
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
// get Vipr generated clone name
for (VolumeClone clone : clones) {
// native id = null ,
_log.info("3PARDriver: createConsistencyGroupClone generated clone parent id {}, display name {} ", clone.getParentId(), clone.getDisplayName());
String generatedCloneName = clone.getDisplayName();
VVsetNameForClone = generatedCloneName.substring(0, generatedCloneName.lastIndexOf("-"));
_log.info("3PARDriver: createConsistencyGroupClone CG name {} to be used in cloning ", VVsetNameForClone);
clonesMap.put(clone.getParentId(), clone);
}
_log.info("3PARDriver: createConsistencyGroupClone clonesMap {}", clonesMap.toString());
// Create vvset clone
VVSetVolumeClone[] result = hp3parApi.createVVsetPhysicalCopy(consistencyGroup.getNativeId(), VVsetNameForClone, clones, saveSnapshot);
_log.info("3PARDriver: createConsistencyGroupClone outPut of CG clone result {} ", result.toString());
for (VVSetVolumeClone cloneCreated : result) {
VolumeClone clone = clonesMap.get(cloneCreated.getParent());
_log.info("createConsistencyGroupClone cloneCreated {} and local clone obj nativeid = {} , parent id = {}", cloneCreated.getValues(), clone.getNativeId(), clone.getParentId());
volResult = hp3parApi.getVolumeDetails(cloneCreated.getChild());
_log.info("createConsistencyGroupClone cloneCreated All values {} ", volResult.getAllValues());
clone.setWwn(volResult.getWwn());
clone.setNativeId(volResult.getId());
clone.setDeviceLabel(volResult.getName());
// snap.setAccessStatus(volResult.getAccessStatus());
clone.setDisplayName(volResult.getName());
clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
clone.setProvisionedCapacity(clone.getRequestedCapacity());
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = volResult.getUserSpace().getReservedMiB();
allocatedCapacity += volResult.getSnapshotSpace().getReservedMiB();
allocatedCapacity += volResult.getAdminSpace().getReservedMiB();
clone.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
}
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createConsistencyGroupClone 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: createConsistencyGroupClone Unable to create vv set snap name %s and its native id %s whose storage system id is %s; Error: %s.\n", VVsetNameForClone, 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.VolumeClone in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doDetachClone.
@Override
public void doDetachClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = null;
Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
_log.info("Detaching volume clone on storage system {}, clone: {} .", storageSystem.getNativeId(), clone.toString());
try {
BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
VolumeClone driverClone = new VolumeClone();
driverClone.setStorageSystemId(storageSystem.getNativeId());
driverClone.setNativeId(clone.getNativeId());
driverClone.setParentId(sourceVolume.getNativeId());
driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
// Call driver
task = driver.detachVolumeClone(Collections.unmodifiableList(Collections.singletonList(driverClone)));
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(clone, dbClient);
clone.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
clone.setReplicaState(Volume.ReplicationState.DETACHED.name());
String msg = String.format("doDetachClone -- Detached volume clone: %s .", task.getMessage());
_log.info(msg);
dbClient.updateObject(clone);
taskCompleter.ready(dbClient);
} else {
String msg = String.format("Failed to detach volume clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
_log.error(msg);
// todo: add error
ServiceError serviceError = ExternalDeviceException.errors.detachVolumeCloneFailed("doDetachClone", msg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
String msg = String.format("Failed to detach volume clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
_log.error(msg, e);
ServiceError serviceError = ExternalDeviceException.errors.detachVolumeCloneFailed("doDetachClone", msg);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method hasExports.
/**
* Check if block object has exports on device
*
* @param driver storage driver
* @param driverBlockObject driver block object
* @return true/false
*/
private boolean hasExports(BlockStorageDriver driver, StorageBlockObject driverBlockObject) {
Map<String, HostExportInfo> blocObjectToHostExportInfo = null;
// get HostExportInfo data for this block object from the driver
if (driverBlockObject instanceof VolumeClone) {
VolumeClone driverClone = (VolumeClone) driverBlockObject;
blocObjectToHostExportInfo = driver.getCloneExportInfoForHosts(driverClone);
_log.info("Export info for clone {} is {}:", driverClone, blocObjectToHostExportInfo);
} else if (driverBlockObject instanceof VolumeSnapshot) {
VolumeSnapshot driverSnapshot = (VolumeSnapshot) driverBlockObject;
blocObjectToHostExportInfo = driver.getSnapshotExportInfoForHosts(driverSnapshot);
_log.info("Export info for snapshot {} is {}:", driverSnapshot, blocObjectToHostExportInfo);
} else if (driverBlockObject instanceof StorageVolume) {
StorageVolume driverVolume = (StorageVolume) driverBlockObject;
blocObjectToHostExportInfo = driver.getVolumeExportInfoForHosts(driverVolume);
_log.info("Export info for volume {} is {}:", driverVolume, blocObjectToHostExportInfo);
} else {
// not supported type in this method
String errorMsg = String.format("Method is not supported for %s objects.", driverBlockObject.getClass().getSimpleName());
throw new RuntimeException(errorMsg);
}
return !(blocObjectToHostExportInfo == null || blocObjectToHostExportInfo.isEmpty());
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doRestoreFromClone.
@Override
public void doRestoreFromClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = null;
Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
_log.info("Restore from volume clone on storage system {}, clone: {} .", storageSystem.getNativeId(), clone.toString());
try {
BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
VolumeClone driverClone = new VolumeClone();
driverClone.setStorageSystemId(storageSystem.getNativeId());
driverClone.setNativeId(clone.getNativeId());
driverClone.setParentId(sourceVolume.getNativeId());
driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
// Call driver
task = driver.restoreFromClone(Collections.unmodifiableList(Collections.singletonList(driverClone)));
if (!isTaskInTerminalState(task.getStatus())) {
// If the task is not in a terminal state and will be completed asynchronously
// create a job to monitor the progress of the request and update the clone
// volume replica state and call the completer as appropriate based on the result
// of the request.
RestoreFromCloneExternalDeviceJob job = new RestoreFromCloneExternalDeviceJob(storageSystem.getId(), cloneVolume, task.getTaskId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(job));
} else if (task.getStatus() == DriverTask.TaskStatus.READY) {
String msg = String.format("doRestoreFromClone -- Restored volume from clone: %s .", task.getMessage());
_log.info(msg);
ExternalDeviceUtils.updateRestoredClone(clone, driverClone, dbClient, true);
taskCompleter.ready(dbClient);
} else {
String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
_log.error(msg);
// todo: add error
ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
_log.error(msg, e);
ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
taskCompleter.error(dbClient, serviceError);
}
}
Aggregations