use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method setHostBootVolume.
@Override
public void setHostBootVolume(URI host, URI bootVolumeId, boolean updateSanBootTargets, String taskId) throws ControllerException {
TaskCompleter completer = null;
try {
completer = new HostCompleter(host, false, taskId);
Workflow workflow = _workflowService.getNewWorkflow(this, SET_SAN_BOOT_TARGETS_WF_NAME, true, taskId);
String waitFor = addStepsForBootVolume(workflow, host, bootVolumeId);
if (updateSanBootTargets) {
waitFor = addStepsForSanBootTargets(workflow, host, bootVolumeId, waitFor);
}
workflow.executePlan(completer, "Success", null, null, null, null);
} catch (Exception ex) {
String message = "setHostSanBootTargets caught an exception.";
_log.error(message, ex);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method relinkTargetsToSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void relinkTargetsToSnapshotSession(URI systemURI, URI tgtSnapSessionURI, List<URI> snapshotURIs, Boolean updateStatus, String opId) throws InternalException {
TaskCompleter completer = new BlockSnapshotSessionRelinkTargetsWorkflowCompleter(tgtSnapSessionURI, updateStatus, opId);
try {
// Get a new workflow to execute the linking of the target volumes
// to the new session.
Workflow workflow = _workflowService.getNewWorkflow(this, RELINK_SNAPSHOT_SESSION_TARGETS_WF_NAME, false, opId);
_log.info("Created new workflow to re-link targets to snapshot session {} with operation id {}", tgtSnapSessionURI, opId);
Iterable<URI> snapshotsIterable = snapshotURIs;
BlockSnapshotSession tgtSnapSession = _dbClient.queryObject(BlockSnapshotSession.class, tgtSnapSessionURI);
// For CG's, ensure 1 target per ReplicationGroup
if (tgtSnapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(tgtSnapSession.getReplicationGroupInstance())) {
snapshotsIterable = ControllerUtils.ensureOneSnapshotPerReplicationGroup(snapshotURIs, _dbClient);
}
String waitFor = null;
for (URI snapshotURI : snapshotsIterable) {
waitFor = workflow.createStep(RELINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Re-linking target to snapshot session %s", tgtSnapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), relinkBlockSnapshotSessionTargetMethod(systemURI, tgtSnapSessionURI, snapshotURI), null, null);
}
workflow.executePlan(completer, "Re-link target volumes to block snapshot session successful");
} catch (Exception e) {
_log.error("Re-link target volumes to block snapshot session failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.relinkBlockSnapshotSessionTargetsFailed(e);
completer.error(_dbClient, serviceException);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method pauseNativeContinuousCopies.
@Override
public void pauseNativeContinuousCopies(URI storage, List<URI> mirrors, Boolean sync, String opId) throws ControllerException {
_log.info("START pause continuous copies workflow");
boolean isCG = isCGMirror(mirrors.get(0), _dbClient);
if (mirrors.size() == 1 || isCG) {
fractureMirror(storage, mirrors, isCG, sync, opId);
return;
}
Workflow workflow = _workflowService.getNewWorkflow(this, PAUSE_MIRRORS_WF_NAME, false, opId);
TaskCompleter taskCompleter = null;
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrors.get(0));
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
try {
for (URI mirrorUri : mirrors) {
BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, mirrorUri);
if (!mirrorIsPausable(asList(blockMirror))) {
String errorMsg = format("Can not pause continuous copy %s with synchronization state %s for volume %s", blockMirror.getId(), blockMirror.getSyncState(), blockMirror.getSource().getURI());
_log.error(errorMsg);
String opName = ResourceOperationTypeEnum.PAUSE_NATIVE_CONTINUOUS_COPIES.getName();
ServiceError serviceError = DeviceControllerException.errors.jobFailedOp(opName);
WorkflowStepCompleter.stepFailed(opId, serviceError);
throw new IllegalStateException(errorMsg);
}
workflow.createStep("pauseMirror", "pause mirror", null, storage, storageObj.getSystemType(), this.getClass(), fractureMirrorMethod(storage, asList(mirrorUri), isCG, sync), null, null);
}
taskCompleter = new BlockMirrorTaskCompleter(Volume.class, asList(mirror.getSource().getURI()), opId);
workflow.executePlan(taskCompleter, "Successfully paused continuous copies");
} catch (Exception e) {
String msg = String.format("Failed to execute pause continuous copies workflow for volume %s", mirror.getSource().getURI());
_log.error(msg, e);
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method updateConsistencyGroup.
@Override
public void updateConsistencyGroup(URI storage, URI consistencyGroup, List<URI> addVolumesList, List<URI> removeVolumesList, String task) {
TaskCompleter completer = new BlockConsistencyGroupUpdateCompleter(consistencyGroup, task);
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
boolean srdfCG = false;
// check if SRDF
if (addVolumesList != null && !addVolumesList.isEmpty()) {
URI volumeURI = addVolumesList.get(0);
if (URIUtil.isType(volumeURI, Volume.class)) {
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (volume.isSRDFSource()) {
srdfCG = true;
cg.getRequestedTypes().add(Types.SRDF.name());
_dbClient.updateObject(cg);
}
}
}
// Generate the Workflow.
Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_CONSISTENCY_GROUP_WF_NAME, false, task);
String waitFor = null;
// check if cg is created, if not create it
if (!cg.created()) {
_log.info("Consistency group not created. Creating it");
String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, cg, null, _dbClient);
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Creating consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), createConsistencyGroupMethod(storage, consistencyGroup, groupName), deleteConsistencyGroupMethod(storage, consistencyGroup, groupName, false, false, true), null);
}
if (addVolumesList != null && !addVolumesList.isEmpty()) {
String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, cg, null, _dbClient);
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Adding volumes to consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), addToConsistencyGroupMethod(storage, consistencyGroup, groupName, addVolumesList), removeFromConsistencyGroupMethod(storage, consistencyGroup, addVolumesList, false), null);
// call ReplicaDeviceController
waitFor = _replicaDeviceController.addStepsForAddingSessionsToCG(workflow, waitFor, consistencyGroup, addVolumesList, groupName, task);
}
if (removeVolumesList != null && !removeVolumesList.isEmpty()) {
Volume volume = _dbClient.queryObject(Volume.class, removeVolumesList.get(0));
if (volume != null && !volume.getInactive()) {
String groupName = volume.getReplicationGroupInstance();
// call ReplicaDeviceController
waitFor = _replicaDeviceController.addStepsForRemovingVolumesFromCG(workflow, waitFor, consistencyGroup, removeVolumesList, task);
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Removing volumes from consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), removeFromConsistencyGroupMethod(storage, consistencyGroup, removeVolumesList, false), addToConsistencyGroupMethod(storage, consistencyGroup, groupName, removeVolumesList), null);
// remove replication group if the CG will become empty
if ((addVolumesList == null || addVolumesList.isEmpty()) && ControllerUtils.cgHasNoOtherVolume(_dbClient, consistencyGroup, removeVolumesList)) {
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Deleting replication group for consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), deleteConsistencyGroupMethod(storage, consistencyGroup, groupName, false, false, true), createConsistencyGroupMethod(storage, consistencyGroup, groupName), null);
}
}
}
// add target volumes to that target consistency group.
if (srdfCG) {
createTargetConsistencyGroup(cg, addVolumesList, workflow, waitFor, task);
}
// Finish up and execute the plan.
_log.info("Executing workflow plan {}", UPDATE_CONSISTENCY_GROUP_STEP_GROUP);
String successMessage = String.format("Update consistency group successful for %s", consistencyGroup);
workflow.executePlan(completer, successMessage);
} catch (Exception e) {
_log.error("Error updating consistency group: {}", consistencyGroup, e);
completer.error(_dbClient, DeviceControllerException.exceptions.failedToUpdateConsistencyGroup(e.getMessage()));
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class BlockDeviceController method addStepsForCreateFullCopy.
/* (non-Javadoc)
* @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationInterface#addStepsForCreateFullCopy(com.emc.storageos.workflow.Workflow, java.lang.String, java.util.List, java.lang.String)
*/
@Override
public String addStepsForCreateFullCopy(Workflow workflow, String waitFor, List<VolumeDescriptor> volumeDescriptors, String taskId) throws InternalException {
List<VolumeDescriptor> blockVolmeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME }, new VolumeDescriptor.Type[] {});
// If no volumes to create, just return
if (blockVolmeDescriptors.isEmpty()) {
return waitFor;
}
URI storageURI = null;
boolean createInactive = false;
List<URI> fullCopyList = new ArrayList<URI>();
for (VolumeDescriptor descriptor : blockVolmeDescriptors) {
Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
if (volume != null && !volume.getInactive()) {
URI parentId = volume.getAssociatedSourceVolume();
if (!NullColumnValueGetter.isNullURI(parentId)) {
fullCopyList.add(volume.getId());
storageURI = volume.getStorageController();
createInactive = Boolean.getBoolean(descriptor.getCapabilitiesValues().getReplicaCreateInactive());
}
}
}
if (!fullCopyList.isEmpty()) {
String stepId = workflow.createStepId();
// Now add the steps to create the block full copy on the storage system
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageURI);
Workflow.Method createFullCopyMethod = new Workflow.Method(METHOD_CREATE_FULL_COPY_STEP, storageURI, fullCopyList, createInactive);
Workflow.Method createFullCopyOrchestrationExecutionRollbackMethod = new Workflow.Method(METHOD_CREATE_FULLCOPY_ORCHESTRATE_ROLLBACK_STEP, workflow.getWorkflowURI(), stepId);
waitFor = workflow.createStep(FULL_COPY_CREATE_ORCHESTRATION_STEP, "Create Block Full Copy", waitFor, storageSystem.getId(), storageSystem.getSystemType(), this.getClass(), createFullCopyMethod, createFullCopyOrchestrationExecutionRollbackMethod, stepId);
_log.info(String.format("Added %s step [%s] in workflow", FULL_COPY_CREATE_STEP_GROUP, stepId));
}
return waitFor;
}
Aggregations