use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method establishVolumeFullCopyGroupRelation.
public void establishVolumeFullCopyGroupRelation(URI storage, URI sourceVolume, URI fullCopy, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
TaskCompleter completer = new CloneTaskCompleter(fullCopy, opId);
getDevice(storageObj.getSystemType()).doEstablishVolumeFullCopyGroupRelation(storageObj, sourceVolume, fullCopy, completer);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method restoreVolume.
@Override
public void restoreVolume(URI storage, URI pool, URI volumeURI, URI snapshot, Boolean updateOpStatus, String syncDirection, String opId) throws ControllerException {
SimpleTaskCompleter completer = new SimpleTaskCompleter(BlockSnapshot.class, snapshot, opId);
try {
Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_VOLUME_WF_NAME, false, opId);
_log.info("Created new restore workflow with operation id {}", opId);
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
BlockSnapshot blockSnapshot = _dbClient.queryObject(BlockSnapshot.class, snapshot);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
String description = String.format("Restore volume %s from snapshot %s", volumeURI, snapshot);
String waitFor = null;
URI srdfSourceStorageSystemURI = null;
Volume srdfSourceVolume = null;
Volume srdfTargetVolume = null;
boolean active = false;
/**
* We need to split the SRDF link for R2 snap restore if it is not paused already.
* Refer OPT#476788
*/
if (isNonSplitSRDFTargetVolume(volume)) {
URI srdfSourceVolumeURI = volume.getSrdfParent().getURI();
srdfSourceVolume = _dbClient.queryObject(Volume.class, srdfSourceVolumeURI);
srdfTargetVolume = volume;
srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
if (Mode.ACTIVE.equals(Mode.valueOf(volume.getSrdfCopyMode()))) {
active = true;
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolumeURI, volumeURI, workflow);
} else {
// split all members the group
Workflow.Method splitMethod = srdfDeviceController.splitSRDFGroupLinkMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, volumeURI, false);
Workflow.Method splitRollbackMethod = srdfDeviceController.resumeGroupPairsMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, volumeURI);
waitFor = workflow.createStep(SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_GROUP, SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, srdfSourceStorageSystemURI, getDeviceType(srdfSourceStorageSystemURI), SRDFDeviceController.class, splitMethod, splitRollbackMethod, null);
}
} else if (isNonSplitSRDFSourceVolume(volume)) {
srdfSourceVolume = volume;
srdfSourceStorageSystemURI = volume.getStorageController();
StringSet targets = volume.getSrdfTargets();
if (null != targets) {
for (String target : targets) {
if (NullColumnValueGetter.isNotNullValue(target)) {
srdfTargetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
if (null != srdfTargetVolume && Mode.ACTIVE.equals(Mode.valueOf(srdfTargetVolume.getSrdfCopyMode()))) {
active = true;
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, volume.getId(), srdfTargetVolume.getId(), workflow);
}
break;
}
}
}
}
if (system.checkIfVmax3()) {
_log.info("Creating workflow for restore VMAX3 snapshot {}", blockSnapshot.getId());
// To restore the source from a linked target volume for VMAX3 SnapVX, we must
// do the following:
//
// 1. Terminate any stale restore sessions on the source.
// 2. Create a temporary snapvx snapshot session of the linked target volume or target group.
// 3. Link the source volume(s) of the BlockSnapshot(s) to the temporary snapshot session in copy mode.
// 4. Wait for the data from the session to be copied to the source volume(s)
// 5. Unlink the source volume(s) from the temporary snapvx snapshot session.
// 6. Delete the temporary session.
//
// This is essentially restoring by creating a cascaded snapshot session or group
// snapshot session on the linked target volume associated with the passed block
// snapshot or associated linked target group in the case of a group operation.
// Create a workflow step to terminate stale restore sessions.
waitFor = workflow.createStep(BLOCK_VOLUME_RESTORE_GROUP, String.format("Terminating VMAX restore session from %s to %s", blockSnapshot.getId(), volume.getId()), waitFor, system.getId(), system.getSystemType(), BlockDeviceController.class, terminateRestoreSessionsMethod(system.getId(), volume.getId(), blockSnapshot.getId()), rollbackMethodNullMethod(), null);
// Get all snapshots if this is a group snapshot.
String replicationGroupName = null;
List<BlockSnapshot> allSnapshots = new ArrayList<>();
String replicationGroupId = blockSnapshot.getReplicationGroupInstance();
if (!NullColumnValueGetter.isNullValue(replicationGroupId)) {
allSnapshots.addAll(ControllerUtils.getSnapshotsPartOfReplicationGroup(blockSnapshot, _dbClient));
int nameStartIndex = replicationGroupId.indexOf("+") + 1;
replicationGroupName = replicationGroupId.substring(nameStartIndex);
} else {
allSnapshots.add(blockSnapshot);
}
// Create a temporary BlockSnapshot instance to represent the parent source volumes
// for each block snapshot. Linking to a session required BlockSnapshot instances so
// we need to create some to represent the source volume(s).
StringSet linkedTargets = new StringSet();
List<BlockSnapshot> sourceSnapshots = new ArrayList<>();
List<URI> sourceSnapshotURIs = new ArrayList<>();
URI cgURI = blockSnapshot.getConsistencyGroup();
for (BlockSnapshot aSnapshot : allSnapshots) {
BlockObject aSourceObj = BlockObject.fetch(_dbClient, aSnapshot.getParent().getURI());
BlockSnapshot sourceSnapshot = new BlockSnapshot();
URI sourceSnapshotURI = URIUtil.createId(BlockSnapshot.class);
sourceSnapshot.setId(sourceSnapshotURI);
sourceSnapshot.setNativeId(aSourceObj.getNativeId());
sourceSnapshot.setParent(new NamedURI(aSnapshot.getId(), aSnapshot.getLabel()));
sourceSnapshot.setSourceNativeId(aSnapshot.getNativeId());
sourceSnapshot.setStorageController(storage);
sourceSnapshot.setSystemType(system.getSystemType());
if (!NullColumnValueGetter.isNullURI(cgURI)) {
sourceSnapshot.setConsistencyGroup(cgURI);
}
sourceSnapshot.addInternalFlags(Flag.INTERNAL_OBJECT);
sourceSnapshots.add(sourceSnapshot);
sourceSnapshotURIs.add(sourceSnapshotURI);
linkedTargets.add(sourceSnapshotURI.toString());
}
_dbClient.createObject(sourceSnapshots);
// Create a BlockSnapshotSession instance to represent the temporary snapshot session.
BlockSnapshotSession snapSession = new BlockSnapshotSession();
URI snapSessionURI = URIUtil.createId(BlockSnapshotSession.class);
snapSession.setId(snapSessionURI);
snapSession.setLabel(blockSnapshot.getLabel() + System.currentTimeMillis());
snapSession.setSessionLabel(snapSession.getLabel());
snapSession.setProject(blockSnapshot.getProject());
snapSession.setStorageController(storage);
snapSession.addInternalFlags(Flag.INTERNAL_OBJECT);
if (!NullColumnValueGetter.isNullURI(cgURI) && NullColumnValueGetter.isNotNullValue(replicationGroupName)) {
snapSession.setConsistencyGroup(cgURI);
snapSession.setReplicationGroupInstance(replicationGroupName);
snapSession.setSessionSetName(replicationGroupName);
} else {
snapSession.setParent(new NamedURI(blockSnapshot.getId(), blockSnapshot.getLabel()));
}
snapSession.setLinkedTargets(linkedTargets);
_dbClient.createObject(snapSession);
// Now create a workflow step that will create the snapshot session.
// This will create a group session in the case of a group operation.
waitFor = workflow.createStep(CREATE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Create snapshot session %s for snapshot target volume %s", snapSessionURI, snapshot), waitFor, storage, getDeviceType(storage), BlockDeviceController.class, createBlockSnapshotSessionMethod(storage, snapSessionURI, replicationGroupName), deleteBlockSnapshotSessionMethod(storage, snapSessionURI, replicationGroupName, Boolean.TRUE), null);
// Create a workflow step to link the source volume for the passed snapshot
// to the snapshot session create by the previous step. We link the source
// volume in copy mode so that that the point-in-time copy of the snapshot
// target volume represented by the snapshot session is copied to the source
// volume. This is essentially the restore step so that the source will now
// reflect the data on the snapshot target volume. This step will not complete
// until the data is copied and the link has achieved the copied state. If this
// is group operation the source target group will be linked to the created
// group session.
Workflow.Method linkMethod;
if (!NullColumnValueGetter.isNullURI(cgURI) && NullColumnValueGetter.isNotNullValue(replicationGroupName)) {
linkMethod = linkBlockSnapshotSessionTargetGroupMethod(storage, snapSessionURI, sourceSnapshotURIs, BlockSnapshotSession.CopyMode.copy.name(), Boolean.TRUE);
} else {
linkMethod = linkBlockSnapshotSessionTargetMethod(storage, snapSessionURI, sourceSnapshotURIs.get(0), BlockSnapshotSession.CopyMode.copy.name(), Boolean.TRUE);
}
waitFor = workflow.createStep(LINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Link source volume %s to snapshot session for snapshot target volume %s", volume, snapshot), waitFor, storage, getDeviceType(storage), BlockDeviceController.class, linkMethod, unlinkBlockSnapshotSessionTargetMethod(storage, snapSessionURI, sourceSnapshotURIs.get(0), Boolean.FALSE), null);
// Once the data is fully copied to the source, we can unlink the source from the session.
// Again, for a group operation, this will unlink the source group from the group session.
waitFor = workflow.createStep(UNLINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Unlink source volume %s from snapshot session for snapshot target volume %s", volumeURI, snapshot), waitFor, storage, getDeviceType(storage), BlockDeviceController.class, unlinkBlockSnapshotSessionTargetMethod(storage, snapSessionURI, sourceSnapshotURIs.get(0), Boolean.FALSE), rollbackMethodNullMethod(), null);
// Finally create a step to delete the snapshot session we created on the snapshot
// target volume.
waitFor = workflow.createStep(DELETE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Delete snapshot session %s for snapshot target volume %s", snapSessionURI, snapshot), waitFor, storage, getDeviceType(storage), BlockDeviceController.class, deleteBlockSnapshotSessionMethod(storage, snapSessionURI, replicationGroupName, Boolean.TRUE), rollbackMethodNullMethod(), null);
/*
* If Active mode then create a step to resume srdf group or restore R2 To R1 or do nothing.
* If syncdirection is not specified means its null then after R1 snapshot restore, resume.
* If syncdirection is not specified means its null then after R2 snapshot restore, restore R2 to R1.
* If syncdirection is SOURCE_TO_TARGET then after R1 or R2 snapshot restore, resume.
* If syncdirection is TARGET_TO_SOURCE then after R1 or R2 snapshot restore, restore R2 to R1.
* If syncdirection is NONE then do nothing, RDF group will stay in suspend state.
*/
if (active) {
if (null == syncDirection) {
if (null != srdfSourceVolume && volumeURI.equals(srdfSourceVolume.getId())) {
resumeSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
} else if (null != srdfTargetVolume && volumeURI.equals(srdfTargetVolume.getId())) {
restoreWorkflowStep(waitFor, srdfTargetVolume.getStorageController(), srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
}
} else if (null != syncDirection) {
if (SRDFUtils.SyncDirection.SOURCE_TO_TARGET.toString().equals(syncDirection)) {
resumeSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
} else if (SRDFUtils.SyncDirection.TARGET_TO_SOURCE.toString().equals(syncDirection)) {
restoreWorkflowStep(waitFor, srdfTargetVolume.getStorageController(), srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
} else if (SRDFUtils.SyncDirection.NONE.toString().equals(syncDirection)) {
_log.info("Sync direction is specified as {} hence no action will be done after retsore snapshot which" + " means the RDF group for volume {} will be in a suspended state.", syncDirection, volume.getLabel());
}
}
}
} else {
waitFor = workflow.createStep(BLOCK_VOLUME_RESTORE_GROUP, description, waitFor, storage, getDeviceType(storage), BlockDeviceController.class, restoreVolumeMethod(storage, pool, volumeURI, snapshot, updateOpStatus), rollbackMethodNullMethod(), null);
// Skip the step for VMAX3, as restore operation may still be in progress (OPT#476325)
// Regardless, termination of restore session should be call before restore
// Note this is not needed for VNX
addPostRestoreVolumeSteps(workflow, system, volume, blockSnapshot, waitFor);
}
_log.info("Executing workflow {}", BLOCK_VOLUME_RESTORE_GROUP);
String msg = String.format("Restore of volume %s from %s completed successfully", volumeURI, snapshot);
workflow.executePlan(completer, msg);
} catch (Exception e) {
String msg = String.format("Could not restore volume %s from snapshot %s", volumeURI, snapshot);
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method detachFullCopy.
@Override
public void detachFullCopy(URI storage, List<URI> fullCopyVolumes, String taskId) throws ControllerException {
_log.info("START detachFullCopy: {}", fullCopyVolumes);
TaskCompleter taskCompleter = new CloneWorkflowCompleter(fullCopyVolumes, taskId);
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Workflow workflow = _workflowService.getNewWorkflow(this, DETACH_CLONE_WF_NAME, true, taskId);
_log.info("Created new detach workflow with operation id {}", taskId);
// add CG to taskCompleter
checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter);
Workflow.Method detachMethod = detachFullCopyMethod(storage, fullCopyVolumes);
workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", null, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
String msg = String.format("Detach %s completed successfully", fullCopyVolumes.get(0));
workflow.executePlan(taskCompleter, msg);
} catch (Exception e) {
String msg = String.format("Could not detach the clone %s", fullCopyVolumes.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method attachNativeContinuousCopies.
@Override
public void attachNativeContinuousCopies(URI storage, URI sourceVolume, List<URI> mirrorList, String opId) throws ControllerException {
_log.info("START attach continuous copies workflow");
Workflow workflow = _workflowService.getNewWorkflow(this, ATTACH_MIRRORS_WF_NAME, true, opId);
TaskCompleter taskCompleter = null;
Volume sourceVolumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
boolean isCG = sourceVolumeObj.isInCG();
try {
addStepsForCreateMirrors(workflow, null, storage, sourceVolume, mirrorList, isCG);
taskCompleter = new BlockMirrorTaskCompleter(BlockMirror.class, mirrorList, opId);
workflow.executePlan(taskCompleter, "Successfully attached continuous copies");
} catch (Exception e) {
String msg = String.format("Failed to execute attach continuous copies workflow for volume %s", sourceVolume);
_log.error(msg, e);
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method createListSnapshot.
public void createListSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, snapshotList, createInactive, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
}
}
}
Aggregations