use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method generateExportMaskDeleteWorkflow.
/**
* Generate export mask steps and add to workflow.
*
* @param workflow
* workflow to add steps to
* @param previousStep
* previous step before these steps
* @param storage
* storage system
* @param exportGroup
* export group impacted
* @param exportMask
* export mask to delete
* @param volumes
* volumes we expect to be impacted
* @param initiators
* initiators we expect to be impacted
* @param taskCompleter
* completer
* @return step ID
* @throws Exception
*/
public String generateExportMaskDeleteWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, ExportMask exportMask, List<URI> volumes, List<URI> initiators, ExportTaskCompleter taskCompleter) throws Exception {
URI exportGroupURI = exportGroup.getId();
URI exportMaskURI = exportMask.getId();
URI storageURI = storage.getId();
String maskingStep = workflow.createStepId();
ExportTaskCompleter exportTaskCompleter = null;
if (null != taskCompleter) {
exportTaskCompleter = taskCompleter;
exportTaskCompleter.setOpId(maskingStep);
} else {
exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroupURI, exportMaskURI, maskingStep);
}
Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupDelete", storageURI, exportGroupURI, exportMaskURI, volumes, initiators, exportTaskCompleter);
maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Deleting mask %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, null, maskingStep);
return maskingStep;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method deleteStorageView.
/**
* A Workflow Step to delete a VPlex Storage View.
*
* @param vplexURI vplex
* @param exportMaskURI export mask
* @param isRollbackStep is this being run as a rollback step?
* @param stepId step ID
* @throws WorkflowException
*/
public void deleteStorageView(URI vplexURI, URI exportGroupURI, URI exportMaskURI, boolean isRollbackStep, String stepId) throws WorkflowException {
ExportMaskDeleteCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
completer = new ExportMaskDeleteCompleter(exportGroupURI, exportMaskURI, stepId);
completer.setRollingBack(isRollbackStep);
StorageSystem vplex = getDataObject(StorageSystem.class, vplexURI, _dbClient);
Boolean[] viewFound = new Boolean[] { new Boolean(false) };
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplex, _dbClient);
if (exportMask != null) {
String vplexClusterName = VPlexUtil.getVplexClusterName(exportMask, vplexURI, client, _dbClient);
VPlexStorageViewInfo storageView = client.getStorageView(vplexClusterName, exportMask.getMaskName());
if (storageView != null) {
// we can ignore this in the case of a missing storage view on the VPLEX, it has already been
// deleted
_log.info("Refreshing ExportMask {}", exportMask.getMaskName());
VPlexControllerUtils.refreshExportMask(_dbClient, storageView, exportMask, VPlexControllerUtils.getTargetPortToPwwnMap(client, vplexClusterName), _networkDeviceController);
}
if (exportMask.hasAnyExistingVolumes() || exportMask.hasAnyExistingInitiators()) {
_log.warn("ExportMask {} still has non-ViPR-created existing volumes or initiators, " + "so ViPR will not remove it from the VPLEX device", exportMask.getMaskName());
}
if (exportMask.getInactive()) {
_log.warn("ExportMask {} is already inactive, so there's " + "no need to delete it off the VPLEX", exportMask.getMaskName());
} else {
List<URI> volumeURIs = new ArrayList<URI>();
if (exportMask.getUserAddedVolumes() != null && !exportMask.getUserAddedVolumes().isEmpty()) {
volumeURIs = StringSetUtil.stringSetToUriList(exportMask.getUserAddedVolumes().values());
}
List<Initiator> initiators = new ArrayList<>();
if (exportMask.getUserAddedInitiators() != null && !exportMask.getUserAddedInitiators().isEmpty()) {
List<URI> initiatorURIs = StringSetUtil.stringSetToUriList(exportMask.getUserAddedInitiators().values());
initiators.addAll(_dbClient.queryObject(Initiator.class, initiatorURIs));
}
ExportMaskValidationContext ctx = new ExportMaskValidationContext();
ctx.setStorage(vplex);
ctx.setExportMask(exportMask);
ctx.setBlockObjects(volumeURIs, _dbClient);
ctx.setInitiators(initiators);
ctx.setAllowExceptions(!WorkflowService.getInstance().isStepInRollbackState(stepId));
validator.exportMaskDelete(ctx).validate();
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_084);
// note: there's a chance if the existing storage view originally had only
// storage ports configured in it, then it would be deleted by this
_log.info("removing this export mask from VPLEX: " + exportMask.getMaskName());
client.deleteStorageView(exportMask.getMaskName(), vplexClusterName, viewFound);
if (viewFound[0]) {
_log.info("as expected, storage view was found for deletion on the VPLEX.");
} else {
_log.info("storage view was not found on the VPLEX during deletion, " + "but no errors were encountered.");
}
}
_log.info("Marking export mask for deletion from Vipr: " + exportMask.getMaskName());
_dbClient.markForDeletion(exportMask);
_log.info("updating ExportGroups containing this ExportMask");
List<ExportGroup> exportGroups = ExportMaskUtils.getExportGroups(_dbClient, exportMask);
for (ExportGroup exportGroup : exportGroups) {
_log.info("Removing mask from ExportGroup " + exportGroup.getGeneratedName());
exportGroup.removeExportMask(exportMaskURI);
_dbClient.updateObject(exportGroup);
}
} else {
_log.info("ExportMask to delete could not be found in database: " + exportMaskURI);
}
completer.ready(_dbClient);
} catch (VPlexApiException vae) {
_log.error("Exception deleting ExportMask: " + exportMaskURI, vae);
failStep(completer, stepId, vae);
} catch (DeviceControllerException ex) {
_log.error("Exception deleting ExportMask: " + exportMaskURI, ex);
failStep(completer, stepId, ex);
} catch (Exception ex) {
_log.error("Exception deleting ExportMask: " + exportMaskURI, ex);
ServiceError svcError = VPlexApiException.errors.deleteStorageViewFailed(ex);
failStep(completer, stepId, svcError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.
the class HDSMaskingOrchestrator method generateWorkflowStepToMarkExportMaskInActive.
/**
* Generates workflow step to Mark ExportMask inActive.
*
* @param workflow
* @param previousStep
* @param exportGroup
* @param exportMask
* @param completer
* @return
*/
public String generateWorkflowStepToMarkExportMaskInActive(Workflow workflow, String previousStep, ExportGroup exportGroup, ExportMask exportMask, ExportTaskCompleter completer) {
URI exportGroupURI = exportGroup.getId();
String stepId = workflow.createStepId();
ExportTaskCompleter exportTaskCompleter;
if (completer != null) {
exportTaskCompleter = completer;
exportTaskCompleter.setOpId(stepId);
} else {
exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroupURI, exportMask.getId(), stepId);
}
Workflow.Method markExportMaskInActiveExecuteMethod = new Workflow.Method("doExportGroupToCleanExportMask", exportGroupURI, exportMask.getId(), exportTaskCompleter);
stepId = workflow.createStep(EXPORT_MASK_CLEANUP_TASK, String.format("Marking exportmasks to inactive %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, NullColumnValueGetter.getNullURI(), "storage-system", MaskingWorkflowEntryPoints.class, markExportMaskInActiveExecuteMethod, null, stepId);
return stepId;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.
the class VmaxMaskingOrchestrator method generateChangePortGroupDeleteMaskWorkflowstep.
/**
* Generate change port group delete old mask steps
*
* @param storageURI - Storage system URI
* @param exportGroupURI - Export group URI
* @param oldMaskURI - Old export mask URI
* @param waitFor - The previous step
* @param workflow - Workflow
* @return - The last step it generates
* @throws Exception
*/
private String generateChangePortGroupDeleteMaskWorkflowstep(URI storageURI, ExportGroup exportGroup, ExportMask oldMask, String waitFor, Workflow workflow) throws Exception {
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
// Remove the old export mask.
String maskingStep = workflow.createStepId();
ExportTaskCompleter exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroup.getId(), oldMask.getId(), maskingStep);
StringMap volMap = oldMask.getVolumes();
List<URI> volumes = null;
if (volMap != null) {
volumes = StringSetUtil.stringSetToUriList(volMap.keySet());
}
List<URI> inits = StringSetUtil.stringSetToUriList(oldMask.getInitiators());
Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupDelete", storageURI, exportGroup.getId(), oldMask.getId(), volumes, inits, exportTaskCompleter);
_log.info(String.format("ExportMask %s is to be deleted:", oldMask.getMaskName()));
Workflow.Method maskinkRollbackMethod = new Workflow.Method("rollbackChangePortGroupDeleteMask", storageURI, exportGroup.getId(), oldMask.getId());
maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Deleting mask %s (%s)", oldMask.getMaskName(), oldMask.getId().toString()), waitFor, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, maskinkRollbackMethod, maskingStep);
List<ExportMask> masks = new ArrayList<ExportMask>();
masks.add(oldMask);
String zoningStep = generateZoningDeleteWorkflow(workflow, maskingStep, exportGroup, masks);
return zoningStep;
}
Aggregations