Search in sources :

Example 1 with VolumeVarrayChangeTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVarrayChangeTaskCompleter 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)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 VolumeVarrayChangeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVarrayChangeTaskCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1