Search in sources :

Example 56 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method generateExportMaskRemovePathsWorkflow.

/**
 * Generate export mask remove path workflow step
 *
 * @param workflow - The workflow
 * @param storage - Storage system
 * @param exportGroupURI - Export group URI
 * @param exportMaskURI - Export mask URI
 * @param adjustedPaths - Adjusted paths
 * @param removePaths - Paths to be removed
 * @param previousStep - previous step that this step will wait for
 * @return The created step id
 * @throws Exception
 */
public String generateExportMaskRemovePathsWorkflow(Workflow workflow, StorageSystem storage, URI exportGroupURI, URI exportMaskURI, Map<URI, List<URI>> adjustedPaths, Map<URI, List<URI>> removePaths, String previousStep) throws Exception {
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = new ExportMaskRemovePathsCompleter(exportGroupURI, exportMaskURI, maskingStep);
    Workflow.Method executeMethod = new Workflow.Method("doExportMaskRemovePaths", storage.getId(), exportGroupURI, exportMaskURI, adjustedPaths, removePaths, exportTaskCompleter);
    maskingStep = workflow.createStep(EXPORT_MASK_REMOVE_PATHS_TASK, String.format("Removeing paths to export mask %s", exportMaskURI.toString()), previousStep, storage.getId(), storage.getSystemType(), MaskingWorkflowEntryPoints.class, executeMethod, null, maskingStep);
    return maskingStep;
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) ExportMaskRemovePathsCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskRemovePathsCompleter)

Example 57 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class BlockOrchestrationDeviceController method changeVirtualArray.

@Override
public void changeVirtualArray(List<VolumeDescriptor> volumeDescriptors, String taskId) throws ControllerException {
    // The descriptors that contain descriptor parameters
    // specifying the new target varray are the volumes being
    // moved to the new virtual array.
    List<URI> changeVArrayVolURIList = new ArrayList<URI>();
    List<URI> migrationURIs = new ArrayList<URI>();
    for (VolumeDescriptor volumeDescriptor : volumeDescriptors) {
        Map<String, Object> descrParams = volumeDescriptor.getParameters();
        if ((descrParams != null) && (!descrParams.isEmpty())) {
            changeVArrayVolURIList.add(volumeDescriptor.getVolumeURI());
        }
        URI migrationURI = volumeDescriptor.getMigrationId();
        if (!NullColumnValueGetter.isNullURI(migrationURI)) {
            migrationURIs.add(migrationURI);
        }
    }
    // Create a completer that will update the task status for these
    // volumes and associated migrations when the workflow completes.
    VolumeVarrayChangeTaskCompleter completer = new VolumeVarrayChangeTaskCompleter(VolumeDescriptor.getVolumeURIs(volumeDescriptors), migrationURIs, taskId);
    try {
        // Validate the volume identities before proceeding
        validator.volumeURIs(changeVArrayVolURIList, true, true, ValCk.ID, ValCk.VPLEX);
        // Generate the Workflow.
        String waitFor = null;
        Workflow workflow = _workflowService.getNewWorkflow(this, CHANGE_VARRAY_WF_NAME, true, taskId);
        // First, call the BlockDeviceController to add its steps.
        // This will create the migration target volumes.
        waitFor = _blockDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumeDescriptors, taskId);
        // Then call the VPlexDeviceController to add change virtual array steps.
        waitFor = _vplexDeviceController.addStepsForChangeVirtualArray(workflow, waitFor, volumeDescriptors, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = String.format("Change virtual array suceeded for volumes: %s", changeVArrayVolURIList);
        Object[] callbackArgs = new Object[] { changeVArrayVolURIList };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not change virtual array for volumes: " + changeVArrayVolURIList, ex);
        String opName = ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VARRAY.getName();
        ServiceError serviceError = DeviceControllerException.errors.changeVirtualArrayFailed(changeVArrayVolURIList.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) VolumeVarrayChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVarrayChangeTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 58 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class BlockOrchestrationDeviceController method deleteVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#deleteVolumes(java.util.List,
     * java.lang.String)
     */
@Override
public void deleteVolumes(List<VolumeDescriptor> volumes, String taskId) throws ControllerException {
    List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumes);
    VolumeWorkflowCompleter completer = new VolumeWorkflowCompleter(volUris, taskId);
    Workflow workflow = null;
    try {
        // Validate the volume identities before proceeding
        validator.volumeURIs(volUris, true, true, ValCk.ID, ValCk.VPLEX);
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, DELETE_VOLUMES_WF_NAME, true, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        // Call the RPDeviceController to add its methods if there are RP protections.
        waitFor = _rpDeviceController.addStepsForDeleteVolumes(workflow, waitFor, volumes, taskId);
        // Call the ReplicaDeviceController to add its methods if volumes are removed from,
        // and the CG associated with replication group(s)
        waitFor = _replicaDeviceController.addStepsForDeleteVolumes(workflow, waitFor, volumes, taskId);
        // Call the VPlexDeviceController to add its methods if there are VPLEX volumes.
        waitFor = _vplexDeviceController.addStepsForDeleteVolumes(workflow, waitFor, volumes, taskId);
        // Call the RPDeviceController to add its post-delete methods.
        waitFor = _rpDeviceController.addStepsForPostDeleteVolumes(workflow, waitFor, volumes, taskId, completer, _blockDeviceController);
        // Call the SRDFDeviceController to add its methods if there are SRDF volumes.
        waitFor = _srdfDeviceController.addStepsForDeleteVolumes(workflow, waitFor, volumes, taskId);
        // Next, call the BlockDeviceController to add its methods.
        waitFor = _blockDeviceController.addStepsForDeleteVolumes(workflow, waitFor, volumes, taskId);
        // Next, call the BlockDeviceController to add post deletion methods.
        waitFor = _blockDeviceController.addStepsForPostDeleteVolumes(workflow, waitFor, volumes, taskId, completer);
        // Call the VPlexDeviceController to add its post-delete methods.
        waitFor = _vplexDeviceController.addStepsForPostDeleteVolumes(workflow, waitFor, volumes, taskId, completer);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Delete volumes successful for: " + volUris.toString();
        Object[] callbackArgs = new Object[] { volUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not delete volumes: " + volUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.DELETE_BLOCK_VOLUME.getName();
        ServiceError serviceError = DeviceControllerException.errors.deleteVolumesFailed(volUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) BlockObject(com.emc.storageos.db.client.model.BlockObject) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException)

Example 59 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class BlockOrchestrationDeviceController method restoreFromFullCopy.

@Override
public void restoreFromFullCopy(URI storage, List<URI> fullCopyURIs, String taskId) throws InternalException {
    CloneRestoreCompleter completer = new CloneRestoreCompleter(fullCopyURIs, taskId);
    // add the CG to the completer if this is a CG restore
    Iterator<Volume> iter = getDbClient().queryIterativeObjects(Volume.class, fullCopyURIs);
    while (iter.hasNext()) {
        Volume fc = iter.next();
        if (!NullColumnValueGetter.isNullURI(fc.getAssociatedSourceVolume())) {
            BlockObject firstSource = BlockObject.fetch(getDbClient(), fc.getAssociatedSourceVolume());
            if (firstSource != null) {
                if (firstSource instanceof Volume && !NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
                    completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
                }
                break;
            }
        }
    }
    s_logger.info("Creating steps for restore from full copy.");
    try {
        // Validate the volume identities before proceeding
        validator.volumeURIs(fullCopyURIs, true, true, ValCk.ID, ValCk.VPLEX);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_FROM_FULLCOPY_WF_NAME, true, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        // First, call the RP controller to add RP steps for volume restore
        waitFor = _rpDeviceController.addPreRestoreFromFullcopySteps(workflow, waitFor, storage, fullCopyURIs, taskId);
        // Call the VplexDeviceController to add its steps for restore volume from full copy
        waitFor = _vplexDeviceController.addStepsForRestoreFromFullcopy(workflow, waitFor, storage, fullCopyURIs, taskId, completer);
        // Call the BlockDeviceController to add its steps for restore volume from full copy
        waitFor = _blockDeviceController.addStepsForRestoreFromFullcopy(workflow, waitFor, storage, fullCopyURIs, taskId, completer);
        // Call the RPDeviceController to add its steps for post restore volume from full copy
        waitFor = _rpDeviceController.addPostRestoreFromFullcopySteps(workflow, waitFor, storage, fullCopyURIs, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Restore from full copy completed successfully";
        Object[] callbackArgs = new Object[] { new ArrayList<URI>(fullCopyURIs) };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not restore volume: ", ex);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockObject(com.emc.storageos.db.client.model.BlockObject) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException)

Example 60 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class BlockOrchestrationDeviceController method createVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#createVolumes(java.util.List,
     * java.lang.String)
     */
@Override
public void createVolumes(List<VolumeDescriptor> volumes, String taskId) throws ControllerException {
    List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumes);
    VolumeCreateWorkflowCompleter completer = new VolumeCreateWorkflowCompleter(volUris, taskId, volumes);
    Workflow workflow = null;
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, CREATE_VOLUMES_WF_NAME, true, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        s_logger.info("Generating steps for create Volume");
        // First, call the BlockDeviceController to add its methods.
        waitFor = _blockDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for SRDF steps");
        // Call the SRDFDeviceController to add its methods if there are SRDF volumes.
        waitFor = _srdfDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for VPLEX steps");
        // Call the VPlexDeviceController to add its methods if there are VPLEX volumes.
        waitFor = _vplexDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for RP steps");
        // Call the RPDeviceController to add its methods if there are RP protections
        waitFor = _rpDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for Replica steps");
        // Call the ReplicaDeviceController to add its methods if volumes are added to CG, and the CG associated
        // with replication
        // group(s)
        waitFor = _replicaDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Create volumes successful for: " + volUris.toString();
        Object[] callbackArgs = new Object[] { volUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (LockRetryException ex) {
        /**
         * Added this catch block to mark the current workflow as completed so that lock retry will not get exception while creating new
         * workflow using the same taskid.
         */
        s_logger.info(String.format("Lock retry exception key: %s remaining time %d", ex.getLockIdentifier(), ex.getRemainingWaitTimeSeconds()));
        releaseWorkflowLocks(workflow);
        if (workflow != null && !NullColumnValueGetter.isNullURI(workflow.getWorkflowURI()) && workflow.getWorkflowState() == WorkflowState.CREATED) {
            com.emc.storageos.db.client.model.Workflow wf = s_dbClient.queryObject(com.emc.storageos.db.client.model.Workflow.class, workflow.getWorkflowURI());
            if (!wf.getCompleted()) {
                s_logger.error("Marking the status to completed for the newly created workflow {}", wf.getId());
                wf.setCompleted(true);
                s_dbClient.updateObject(wf);
            }
        }
        throw ex;
    } catch (Exception ex) {
        s_logger.error("Could not create volumes: " + volUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME.getName();
        ServiceError serviceError = DeviceControllerException.errors.createVolumesFailed(volUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) LockRetryException(com.emc.storageos.locking.LockRetryException) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) VolumeCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateWorkflowCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

Workflow (com.emc.storageos.workflow.Workflow)285 URI (java.net.URI)204 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)171 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)127 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)126 ControllerException (com.emc.storageos.volumecontroller.ControllerException)126 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)124 ArrayList (java.util.ArrayList)123 WorkflowException (com.emc.storageos.workflow.WorkflowException)119 NamedURI (com.emc.storageos.db.client.model.NamedURI)102 Volume (com.emc.storageos.db.client.model.Volume)76 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)72 HashMap (java.util.HashMap)66 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)65 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)61 ExportMask (com.emc.storageos.db.client.model.ExportMask)54 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)54 List (java.util.List)54 BlockObject (com.emc.storageos.db.client.model.BlockObject)41 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)41