use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class XtremIOMaskingOrchestrator method exportGroupAddVolumes.
@Override
public void exportGroupAddVolumes(URI storageURI, URI exportGroupURI, Map<URI, Integer> volumeMap, String token) throws Exception {
ExportTaskCompleter taskCompleter = null;
try {
log.info(String.format("exportAddVolume start - Array: %s ExportGroup: %s Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumeMap.entrySet())));
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
refreshExportMask(storage, getDevice(), null);
List<URI> initiatorURIs = null;
if (exportGroup.getInitiators() != null && !exportGroup.getInitiators().isEmpty()) {
Collection<URI> initiators = Collections2.transform(exportGroup.getInitiators(), CommonTransformerFunctions.FCTN_STRING_TO_URI);
initiatorURIs = new ArrayList<URI>(initiators);
findAndUpdateFreeHLUsForClusterExport(storage, exportGroup, initiatorURIs, volumeMap);
}
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI);
if (exportMasks != null && !exportMasks.isEmpty()) {
// Set up workflow steps.
Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupAddVolumes", true, token);
// For each export mask in export group, invoke add Volumes if export Mask belongs to the same storage Array
List<ExportMask> masks = new ArrayList<ExportMask>();
for (ExportMask exportMask : exportMasks) {
if (exportMask.getStorageDevice().equals(storageURI)) {
log.info("export_volume_add: adding volume to an existing export");
masks.add(exportMask);
}
}
List<URI> volumeURIs = new ArrayList<URI>();
volumeURIs.addAll(volumeMap.keySet());
String zoningStep = generateZoningAddVolumesWorkflow(workflow, null, exportGroup, masks, volumeURIs);
for (ExportMask mask : masks) {
List<URI> initiators = StringSetUtil.stringSetToUriList(mask.getInitiators());
generateExportMaskAddVolumesWorkflow(workflow, zoningStep, storage, exportGroup, mask, volumeMap, initiators);
}
String successMessage = String.format("Volumes successfully added to export on StorageArray %s", storage.getLabel());
workflow.executePlan(taskCompleter, successMessage);
} else {
if (initiatorURIs != null) {
log.info("export_volume_add: adding volume, creating a new export");
// Group Initiators by compute and invoke create Mask
Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupAddVolumes - Create a new mask", true, token);
List<URI> exportMasksToZoneCreate = new ArrayList<URI>();
Map<URI, Integer> volumesToZoneCreate = new HashMap<URI, Integer>();
Map<String, List<URI>> computeResourceToInitiators = mapInitiatorsToComputeResource(exportGroup, initiatorURIs);
for (Map.Entry<String, List<URI>> resourceEntry : computeResourceToInitiators.entrySet()) {
String computeKey = resourceEntry.getKey();
List<URI> computeInitiatorURIs = resourceEntry.getValue();
log.info(String.format("New export masks for %s", computeKey));
GenExportMaskCreateWorkflowResult result = generateExportMaskCreateWorkflow(workflow, EXPORT_GROUP_ZONING_TASK, storage, exportGroup, computeInitiatorURIs, volumeMap, token);
exportMasksToZoneCreate.add(result.getMaskURI());
volumesToZoneCreate.putAll(volumeMap);
}
if (!exportMasksToZoneCreate.isEmpty()) {
generateZoningCreateWorkflow(workflow, null, exportGroup, exportMasksToZoneCreate, volumesToZoneCreate);
}
String successMessage = String.format("Initiators successfully added to export StorageArray %s", storage.getLabel());
workflow.executePlan(taskCompleter, successMessage);
} else {
log.info("export_volume_add: adding volume, no initiators yet");
taskCompleter.ready(_dbClient);
}
}
log.info(String.format("exportAddVolume end - Array: %s ExportGroup: %s Volume: %s", storageURI.toString(), exportGroupURI.toString(), volumeMap.toString()));
} catch (Exception e) {
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
taskCompleter.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.exportGroupAddVolumesFailed(e);
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method deleteExportGroup.
public void deleteExportGroup(URI exportGroup, String stepId) {
try {
BlockExportController blockController = getController(BlockExportController.class, BlockExportController.EXPORT);
_dbClient.createTaskOpStatus(ExportGroup.class, exportGroup, stepId, ResourceOperationTypeEnum.DELETE_EXPORT_GROUP);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_027);
blockController.exportGroupDelete(exportGroup, stepId);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_028);
} catch (Exception ex) {
_log.error("Exception occured while deleting export group {}", exportGroup, ex);
// Clean up any pending tasks
ExportTaskCompleter taskCompleter = new ExportDeleteCompleter(exportGroup, false, stepId);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(_dbClient, serviceError);
// Fail the step
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportRemoveInitiator.
@Test
public void testExportRemoveInitiator() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
Initiator initiator = getInitiators().get(0);
;
List<URI> initiatorURIs = new ArrayList<URI>(1);
initiatorURIs.add(initiator.getId());
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportRemoveInitiatorCompleter(exportGroup.getId(), initiatorURIs, token);
_deviceController.doExportRemoveInitiator(_storageSystem, exportMask, null, initiator, null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportGroupDeletion.
@Test
public void testExportGroupDeletion() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportDeleteCompleter(exportGroup.getId(), false, token);
_deviceController.doExportDelete(_storageSystem, exportMask, null, null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportAddVolumes.
@Test
public void testExportAddVolumes() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Volume> volumes = getVolumes(_storageSystem);
Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
int lun = 1;
for (Volume volume : volumes) {
volumeMap.put(volume.getId(), lun++);
}
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportAddVolumeCompleter(exportGroup.getId(), volumeMap, token);
_deviceController.doExportAddVolumes(_storageSystem, exportMask, null, volumeMap, taskCompleter);
}
Aggregations