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);
}
}
Aggregations