use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method deleteSnapshotStep.
public String deleteSnapshotStep(Workflow workflow, String waitFor, URI storage, StorageSystem storageSystem, List<URI> snapshotList, boolean isRemoveAll) {
if (isRemoveAll) {
_log.info("Adding group remove snapshot step");
Workflow.Method deleteMethod = deleteSnapshotMethod(storage, snapshotList.get(0));
waitFor = workflow.createStep(SNAPSHOT_DELETE_STEP_GROUP, "Deleting snapshot", waitFor, storage, storageSystem.getSystemType(), getClass(), deleteMethod, null, null);
} else {
for (URI uri : snapshotList) {
_log.info("Adding single remove snapshot step: {}", uri);
Workflow.Method deleteMethod = deleteSelectedSnapshotMethod(storage, uri);
waitFor = workflow.createStep(SNAPSHOT_DELETE_STEP_GROUP, "Deleting snapshot", waitFor, storage, storageSystem.getSystemType(), getClass(), deleteMethod, null, null);
}
}
return waitFor;
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method createFullCopy.
@Override
public void createFullCopy(URI storage, List<URI> fullCopyVolumes, Boolean createInactive, String taskId) throws ControllerException {
_log.info("START fullCopyVolumes");
TaskCompleter taskCompleter = new CloneCreateWorkflowCompleter(fullCopyVolumes, taskId);
Volume clone = _dbClient.queryObject(Volume.class, fullCopyVolumes.get(0));
URI sourceVolume = clone.getAssociatedSourceVolume();
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Workflow workflow = _workflowService.getNewWorkflow(this, FULL_COPY_WORKFLOW, true, taskId);
boolean isCG = false;
Volume source = URIUtil.isType(sourceVolume, Volume.class) ? _dbClient.queryObject(Volume.class, sourceVolume) : null;
VolumeGroup volumeGroup = (source != null) ? source.getApplication(_dbClient) : null;
if (volumeGroup != null) {
/**
* If a Volume is in Volume Group (COPY type),
* Query all volumes belonging to that Volume Group,
* Group full-copies by Array Replication Group and create workflow step for each Array Group,
* these steps runs in parallel
*/
_log.info("Creating full copy for Application {}", volumeGroup.getLabel());
createFullCopyForApplicationCGs(workflow, volumeGroup, fullCopyVolumes, createInactive, taskCompleter);
} else if (checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter)) {
// check if the clone is in a CG
isCG = true;
_log.info("Creating group full copy");
createCGFullCopy(storage, sourceVolume, fullCopyVolumes, storageSystem, workflow, createInactive, isCG);
} else {
for (URI uri : fullCopyVolumes) {
Workflow.Method createMethod = createFullCopyVolumeMethod(storage, sourceVolume, Arrays.asList(uri), createInactive, isCG);
Workflow.Method rollbackMethod = rollbackFullCopyVolumeMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_CREATE_STEP_GROUP, "Creating full copy", null, storage, storageSystem.getSystemType(), getClass(), createMethod, rollbackMethod, null);
// clone state.
if (!createInactive && !getDriverManager().isDriverManaged(storageSystem.getSystemType())) {
// After all full copies have been created, wait for synchronization to complete
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(uri), isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", FULL_COPY_CREATE_STEP_GROUP, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
Volume cloneVol = _dbClient.queryObject(Volume.class, uri);
BlockObject sourceObj = BlockObject.fetch(_dbClient, cloneVol.getAssociatedSourceVolume());
// detach if source is snapshot, or storage system is not vmax/vnx/hds
if (storageSystem.deviceIsType(Type.openstack)) {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
} else if (sourceObj instanceof BlockSnapshot || !(storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.hds) || storageSystem.deviceIsType(Type.vnxblock))) {
Workflow.Method detachMethod = detachFullCopyMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", waitForSyncStep, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
} else if (storageSystem.deviceIsType(Type.vnxblock)) {
workflow.createStep(FULL_COPY_FRACTURE_STEP_GROUP, "fracture full copy", waitForSyncStep, storage, storageSystem.getSystemType(), BlockDeviceController.class, fractureCloneMethod(storage, Arrays.asList(uri), isCG), rollbackMethodNullMethod(), null);
} else {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
}
}
}
}
String successMsg = String.format("Full copy of %s to %s successful", sourceVolume, fullCopyVolumes);
workflow.executePlan(taskCompleter, successMsg);
} catch (InternalException e) {
_log.error("Failed to create full copy of volume", e);
doFailTask(Volume.class, sourceVolume, taskId, e);
WorkflowStepCompleter.stepFailed(taskId, e);
} catch (Exception e) {
_log.error("Failed to create full copy of volume", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, sourceVolume, taskId, serviceError);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method deleteConsistencyGroup.
@Override
public void deleteConsistencyGroup(URI storage, URI consistencyGroup, Boolean markInactive, String opId) throws ControllerException {
_log.info("START delete consistency group");
TaskCompleter wfCompleter = null;
try {
Workflow workflow = _workflowService.getNewWorkflow(this, "deleteReplicationGroupInConsistencyGroup", true, opId);
wfCompleter = new SimpleTaskCompleter(BlockConsistencyGroup.class, consistencyGroup, opId);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
Set<String> groupNames = BlockConsistencyGroupUtils.getGroupNamesForSystemCG(cg, system);
String stepId = null;
for (String groupName : groupNames) {
Workflow.Method deleteStep = new Workflow.Method("deleteReplicationGroupInConsistencyGroup", storage, consistencyGroup, groupName, false, markInactive, true);
stepId = workflow.createStep("DeleteReplicationGroup", "Deleting replication group", stepId, storage, system.getSystemType(), this.getClass(), deleteStep, rollbackMethodNullMethod(), null);
}
String successMsg = String.format("Successfully deleted replication groups %s", Joiner.on(',').join(groupNames));
workflow.executePlan(wfCompleter, successMsg);
} catch (Exception e) {
if (wfCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
wfCompleter.error(_dbClient, serviceError);
}
throw DeviceControllerException.exceptions.deleteConsistencyGroupFailed(e);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method activateFullCopy.
@Override
public void activateFullCopy(URI storage, List<URI> fullCopy, String opId) {
TaskCompleter completer = new CloneWorkflowCompleter(fullCopy, opId);
try {
// need to create a workflow to wait sync finish, then do fracture/activate
Workflow workflow = _workflowService.getNewWorkflow(this, ACTIVATE_CLONE_WF_NAME, false, opId);
_log.info("Created new activate workflow with operation id {}", opId);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
// add CG to taskCompleter
boolean isCG = checkCloneConsistencyGroup(fullCopy.get(0), _dbClient, completer);
if (storageSystem.deviceIsType(Type.vnxblock)) {
String previousStep = null;
if (isCG) {
for (URI cloneUri : fullCopy) {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(cloneUri), false);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
} else {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, fullCopy, isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
workflow.createStep(ACTIVATE_CLONE_GROUP, "Activating clone", previousStep, storage, getDeviceType(storage), BlockDeviceController.class, activateCloneMethod(storage, fullCopy), rollbackMethodNullMethod(), null);
} else {
workflow.createStep(ACTIVATE_CLONE_GROUP, "Activating clone", null, storage, getDeviceType(storage), BlockDeviceController.class, activateCloneMethod(storage, fullCopy), rollbackMethodNullMethod(), null);
}
_log.info("Executing Activate workflow");
String msg = String.format("Actitvate %s completed successfully", fullCopy.get(0));
workflow.executePlan(completer, msg);
} catch (Exception e) {
String msg = String.format("Could not activate the clone %s", fullCopy.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method addStepsForRestoreFromFullcopy.
/**
* Add steps to restore full copy
*
* @param workflow
* - the workflow the steps would be added to
* @param waitFor
* - the step would be waited before the added steps would be executed
* @param storage
* - the storage controller URI
* @param fullcopies
* - the full copies to restore
* @param opId
* @param completer
* - the CloneRestoreCompleter
* @return the step id for the added step
* @throws InternalException
*/
public String addStepsForRestoreFromFullcopy(Workflow workflow, String waitFor, URI storage, List<URI> fullcopies, String opId, TaskCompleter completer) throws InternalException {
Volume firstFullCopy = _dbClient.queryObject(Volume.class, fullcopies.get(0));
// Don't do anything if this is VPLEX full copy
if (firstFullCopy.isVPlexVolume(_dbClient)) {
return waitFor;
}
BlockObject firstSource = BlockObject.fetch(_dbClient, firstFullCopy.getAssociatedSourceVolume());
if (!NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
}
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
Workflow.Method restoreFromFullcopyMethod = new Workflow.Method(RESTORE_FROM_FULLCOPY_METHOD_NAME, storage, fullcopies, Boolean.TRUE);
waitFor = workflow.createStep(RESTORE_FROM_FULLCOPY_STEP, "Restore volumes from full copies", waitFor, storage, system.getSystemType(), this.getClass(), restoreFromFullcopyMethod, null, null);
_log.info("Created workflow step to restore volume from full copies");
return waitFor;
}
Aggregations