use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportRemoveVolumes.
@Test
public void testExportRemoveVolumes() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Volume> volumes = getVolumes(_storageSystem);
List<URI> volumeURIs = new ArrayList<URI>();
for (Volume volume : volumes) {
volumeURIs.add(volume.getId());
}
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportRemoveVolumeCompleter(exportGroup.getId(), volumeURIs, token);
_deviceController.doExportRemoveVolumes(_storageSystem, exportMask, volumeURIs, null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method addStepsForExportMaskCreate.
/**
* Handles adding ExportMask creation into the export workflow.
*
* @param blockObjectMap
* the map of URIs to block volumes for export
* @param workflow
* the controller Workflow
* @param vplexSystem
* a StorageSystem objet representing the VPLEX
* @param exportGroup
* the ViPR ExportGroup in question
* @param storageViewStepId
* the current workflow step id, to be updated on return
* @param exportMask
* the ExportMask object to be created
* @return the workflow step id
*/
private String addStepsForExportMaskCreate(Map<URI, Integer> blockObjectMap, Workflow workflow, StorageSystem vplexSystem, ExportGroup exportGroup, String storageViewStepId, ExportMask exportMask) {
_log.info("adding step to create export mask: " + exportMask.getMaskName());
List<URI> inits = new ArrayList<URI>();
for (String init : exportMask.getInitiators()) {
inits.add(URI.create(init));
}
// Make the targets for this host.
List<URI> hostTargets = new ArrayList<URI>();
for (String targetId : exportMask.getStoragePorts()) {
hostTargets.add(URI.create(targetId));
}
String maskingStep = workflow.createStepId();
ExportTaskCompleter exportTaskCompleter = new ExportMaskCreateCompleter(exportGroup.getId(), exportMask.getId(), inits, blockObjectMap, maskingStep);
// Add a step to export on the VPlex. They call this a Storage View.
Workflow.Method storageViewExecuteMethod = new Workflow.Method(CREATE_STORAGE_VIEW, vplexSystem.getId(), exportGroup.getId(), exportMask.getId(), blockObjectMap, inits, hostTargets, exportTaskCompleter);
// Workflow.Method storageViewRollbackMethod = new Workflow.Method(ROLLBACK_METHOD_NULL);
Workflow.Method storageViewRollbackMethod = deleteStorageViewMethod(vplexSystem.getId(), exportGroup.getId(), exportMask.getId(), true);
storageViewStepId = workflow.createStep("storageView", String.format("Create VPLEX Storage View for ExportGroup %s Mask %s", exportGroup.getId(), exportMask.getMaskName()), storageViewStepId, vplexSystem.getId(), vplexSystem.getSystemType(), this.getClass(), storageViewExecuteMethod, storageViewRollbackMethod, maskingStep);
return storageViewStepId;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method storageViewAddInitiatorsRollback.
/**
* Rollback entry point. This is a wrapper around the exportRemoveInitiators
* operation, which requires that we create a specific completer using the token
* that's passed in. This token is generated by the rollback processing.
*
* @param vplexURI
* [in] - StorageSystem URI
* @param exportGroupURI
* [in] - ExportGroup URI
* @param exportMaskURI
* [in] - ExportMask URI
* @param initiatorURIs
* [in] - List of Initiator URIs
* @param targetURIs
* [in] - List of storage port URIs
* @param rollbackContextKey
* [in] - context token
* @param token
* [in] - String token generated by the rollback processing
* @throws ControllerException
*/
public void storageViewAddInitiatorsRollback(URI vplexURI, URI exportGroupURI, URI exportMaskURI, List<URI> initiatorURIs, List<URI> targetURIs, String rollbackContextKey, String token) throws ControllerException {
ExportTaskCompleter taskCompleter = new ExportMaskRemoveInitiatorCompleter(exportGroupURI, exportMaskURI, initiatorURIs, token);
// in order to only perform rollback of operations we successfully performed.
try {
ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(rollbackContextKey);
WorkflowService.getInstance().storeStepData(token, context);
} catch (ClassCastException e) {
_log.info("Step {} has stored step data other than ExportOperationContext. Exception: {}", token, e);
}
storageViewRemoveInitiators(vplexURI, exportGroupURI, exportMaskURI, initiatorURIs, targetURIs, taskCompleter, rollbackContextKey, token);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class VNXeMaskingOrchestrator method exportGroupRemoveVolumes.
@Override
public void exportGroupRemoveVolumes(URI storageURI, URI exportGroupURI, List<URI> volumes, String token) throws Exception {
ExportTaskCompleter taskCompleter = null;
try {
_log.info(String.format("exportRemoveVolume start - Array: %s ExportMask: %s " + "Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumes)));
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI);
if (exportMasks != null && !exportMasks.isEmpty()) {
Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupRemoveVolumes", true, token);
List<ExportMask> deleteMasks = new ArrayList<ExportMask>();
List<ExportMask> updateMasks = new ArrayList<ExportMask>();
for (ExportMask mask : exportMasks) {
refreshExportMask(storage, getDevice(), mask);
// Determine if we're deleting the last volume.
Set<String> remainingVolumes = new HashSet<String>();
if (mask.getVolumes() != null) {
remainingVolumes.addAll(mask.getVolumes().keySet());
}
for (URI volume : volumes) {
remainingVolumes.remove(volume.toString());
}
// If so, delete the ExportMask.
if (remainingVolumes.isEmpty()) {
deleteMasks.add(mask);
} else {
updateMasks.add(mask);
}
}
if (!deleteMasks.isEmpty()) {
String deleteStep = null;
for (ExportMask exportMask : deleteMasks) {
deleteStep = generateExportMaskDeleteWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, null, null, null);
}
generateZoningDeleteWorkflow(workflow, deleteStep, exportGroup, deleteMasks);
}
if (!updateMasks.isEmpty()) {
String unexportStep = null;
for (ExportMask exportMask : updateMasks) {
unexportStep = generateExportMaskRemoveVolumesWorkflow(workflow, unexportStep, storage, exportGroup, exportMask, volumes, null, null);
}
generateZoningRemoveVolumesWorkflow(workflow, null, exportGroup, updateMasks, volumes);
}
String successMessage = String.format("Volumes successfully unexported from StorageArray %s", storage.getLabel());
workflow.executePlan(taskCompleter, successMessage);
} else {
_log.info("export_volume_remove: no export (initiator should be empty)");
exportGroup.removeVolumes(volumes);
_dbClient.updateObject(exportGroup);
taskCompleter.ready(_dbClient);
}
_log.info(String.format("exportRemoveVolume end - Array: %s ExportMask: %s " + "Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumes)));
} catch (Exception e) {
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
taskCompleter.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.exportRemoveVolumes(e);
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class VNXeMaskingOrchestrator method exportGroupRemoveInitiators.
@Override
public void exportGroupRemoveInitiators(URI storageURI, URI exportGroupURI, List<URI> initiatorURIs, String token) throws Exception {
ExportTaskCompleter taskCompleter = null;
try {
List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
_log.info(String.format("exportRemoveInitiator start - Array: %s " + "ExportMask: %s Initiator: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(initiatorURIs)));
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
// Set up workflow steps.
Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupRemoveInitiators", true, token);
/**
* export mask must exist since both volume & initiator exist
*/
Map<ExportMask, List<Initiator>> exportMasksMap = getInitiatorExportMasks(initiators, _dbClient, exportGroup, storageURI);
Map<URI, List<URI>> maskToInitiatorsMap = new HashMap<URI, List<URI>>();
for (Entry<ExportMask, List<Initiator>> entry : exportMasksMap.entrySet()) {
ExportMask mask = entry.getKey();
List<Initiator> inits = entry.getValue();
List<URI> initURIList = new ArrayList<URI>();
for (Initiator init : inits) {
initURIList.add(init.getId());
}
maskToInitiatorsMap.put(mask.getId(), initURIList);
}
String deleteStep = null;
for (ExportMask exportMask : exportMasksMap.keySet()) {
refreshExportMask(storage, getDevice(), exportMask);
List<Initiator> inits = exportMasksMap.get(exportMask);
if (exportMask.getInitiators().size() == inits.size() && exportMask.getVolumes() != null) {
_log.info(String.format("deleting the exportMask: %s", exportMask.getId().toString()));
// Initiator list (initiatorURIs) need to be provided when deleting export mask as a result of removing last initiators
deleteStep = generateExportMaskDeleteWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, null, initiatorURIs, null);
} else {
Collection<URI> volumeURIs = (Collections2.transform(exportMask.getVolumes().keySet(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
generateExportMaskRemoveInitiatorsWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, new ArrayList<URI>(volumeURIs), initiatorURIs, true);
}
_log.info(String.format("exportRemoveInitiator end - Array: %s ExportMask: %s", storageURI.toString(), exportGroupURI.toString()));
}
generateZoningRemoveInitiatorsWorkflow(workflow, deleteStep, exportGroup, maskToInitiatorsMap);
String successMessage = String.format("Initiators successfully removed from export StorageArray %s", storage.getLabel());
workflow.executePlan(taskCompleter, successMessage);
} catch (Exception e) {
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
taskCompleter.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.exportGroupRemoveInitiatorsFailed(e);
}
}
}
Aggregations