use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class ExportMaskAddInitiatorCompleter method getContextOperations.
/**
* Retrieves the context operations
*
* @return the operations context object from the step data
*/
private List<ExportOperationContext.ExportOperationContextOperation> getContextOperations() {
List<ExportOperationContext.ExportOperationContextOperation> operations = null;
try {
ExportOperationContext context = null;
// Only specific platforms create a context object. If there is no context object, default to updating the
// object in the DB
context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(getOpId());
if (context == null) {
return null;
}
// If initiators/ports were added to the mask, there will be operations hanging off the context
operations = context.getOperations();
} catch (ClassCastException cce) {
// Step state data was stored, but it's not a context object, so return true by default.
}
return operations;
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method rollbackExportGroupAddVolumes.
/**
* Rollback entry point. This is a wrapper around the exportGroupRemoveVolumes
* 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 storageURI
* [in] - StorageSystem URI
* @param exportGroupURI
* [in] - ExportGroup URI
* @param exportGroupURIs
* [in] - All ExportGroup URIs that the export mask associates with
* @param exportMaskURI
* [in] - ExportMask URI
* @param volumeMap
* [in] - Map of Volume URI to HLU Integer value
* @param initiatorURIs
* [in] - Impacted initiators
* @param contextKey
* [in] - context token
* @param token
* [in] - String token generated by the rollback processing
* @throws ControllerException
*/
public void rollbackExportGroupAddVolumes(URI storageURI, URI exportGroupURI, List<URI> exportGroupURIs, URI exportMaskURI, Map<URI, Integer> volumeMap, List<URI> initiatorURIs, String contextKey, String token) throws ControllerException {
List<URI> list = new ArrayList<URI>();
list.addAll(volumeMap.keySet());
ExportTaskCompleter taskCompleter = new ExportMaskRemoveVolumeCompleter(exportGroupURI, exportMaskURI, list, token);
taskCompleter.setExportGroups(exportGroupURIs);
// in order to only perform rollback of operations we successfully performed.
try {
ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(contextKey);
WorkflowService.getInstance().storeStepData(token, context);
} catch (ClassCastException e) {
_log.info("Step {} has stored step data other than ExportOperationContext. Exception: {}", token, e);
}
doExportGroupRemoveVolumes(storageURI, exportGroupURI, exportMaskURI, list, initiatorURIs, taskCompleter, token);
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method rollbackExportGroupCreate.
/**
* Rollback entry point. This is a wrapper around the exportGroupDelete 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 storageURI
* [in] - StorageSystem URI
* @param exportGroupURI
* [in] - ExportGroup URI
* @param exportMaskURI
* [in] - ExportMask URI
* @param contextKey
* [in] - context token
* @param token
* [in] - String token generated by the rollback processing
*
* @throws ControllerException
*/
public void rollbackExportGroupCreate(URI storageURI, URI exportGroupURI, URI exportMaskURI, String contextKey, String token) throws ControllerException {
ExportTaskCompleter taskCompleter = new RollbackExportGroupCreateCompleter(exportGroupURI, exportMaskURI, token);
// Take the context of the step in flight and feed it into our current step
// in order to only perform rollback of operations we successfully performed.
ExportOperationContext context = null;
try {
context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(contextKey);
WorkflowService.getInstance().storeStepData(token, context);
} catch (ClassCastException e) {
_log.info("Step {} has stored step data other than ExportOperationContext. Exception: {}", token, e);
}
_log.info("Rolling back operations: " + context);
doExportGroupDelete(storageURI, exportGroupURI, exportMaskURI, null, null, taskCompleter, token);
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class VnxExportOperations method deleteExportMask.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#deleteExportMask(com.emc.storageos.db.client.
* model.StorageSystem, java.net.URI, java.util.List, java.util.List, java.util.List,
* com.emc.storageos.volumecontroller.TaskCompleter)
*
* IDs
* Note: No need to verify storage ports.
*/
@Override
public void deleteExportMask(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} deleteExportMask START...", storage.getSerialNumber());
try {
_log.info("Export mask id: {}", exportMaskURI);
if (volumeURIList != null) {
_log.info("deleteExportMask: volumes: {}", Joiner.on(',').join(volumeURIList));
}
if (targetURIList != null) {
_log.info("deleteExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
}
if (initiatorList != null) {
_log.info("deleteExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
}
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
String nativeId = exportMask.getNativeId();
if (Strings.isNullOrEmpty(nativeId)) {
_log.warn(String.format("ExportMask %s does not have a nativeID, " + "indicating that this export may not have been created " + "successfully. Marking the delete operation ready.", exportMaskURI.toString()));
// Perform post-mask-delete cleanup steps
ExportUtils.cleanupAssociatedMaskResources(_dbClient, exportMask);
taskCompleter.ready(_dbClient);
return;
}
boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
if (isRollback) {
boolean maskCreated = false;
// Get the context from the task completer as this is a rollback.
ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(taskCompleter.getOpId());
if (context != null && context.getOperations() != null) {
ListIterator li = context.getOperations().listIterator(context.getOperations().size());
while (li.hasPrevious()) {
ExportOperationContextOperation operation = (ExportOperationContextOperation) li.previous();
_log.info("Handling deleteExportMask as a result of rollback");
if (operation != null && VnxExportOperationContext.OPERATION_CREATE_STORAGE_GROUP.equals(operation.getOperation())) {
URI createdExportMaskURI = (URI) operation.getArgs().get(0);
if (exportMask.getId().equals(createdExportMaskURI)) {
maskCreated = true;
break;
}
}
}
}
if (!maskCreated) {
_log.warn(String.format("This is a case of rollback but the ExportMask %s was not found in the export context, " + "indicating that this export may not have been created successfully. Marking the delete operation ready.", exportMaskURI.toString()));
// Perform post-mask-delete cleanup steps
ExportUtils.cleanupAssociatedMaskResources(_dbClient, exportMask);
taskCompleter.ready(_dbClient);
return;
}
}
ExportMaskValidationContext ctx = new ExportMaskValidationContext();
ctx.setStorage(storage);
ctx.setExportMask(exportMask);
ctx.setBlockObjects(volumeURIList, _dbClient);
ctx.setInitiators(initiatorList);
ctx.setAllowExceptions(!isRollback);
validator.exportMaskDelete(ctx).validate();
CIMObjectPath protocolController = _cimPath.getClarProtocolControllers(storage, nativeId)[0];
CIMInstance instance = _helper.checkExists(storage, protocolController, true, true);
if (instance != null) {
_helper.setProtocolControllerNativeId(exportMaskURI, null);
ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
if (mask != null) {
List<URI> initiatorURIs = new ArrayList<URI>();
if (mask.getInitiators() != null) {
for (String initUriStr : mask.getInitiators()) {
initiatorURIs.add(URI.create(initUriStr));
}
}
List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
deleteStorageHWIDs(storage, initiators);
deleteOrShrinkStorageGroup(storage, exportMaskURI, null, null);
}
}
// Perform post-mask-delete cleanup steps
ExportUtils.cleanupAssociatedMaskResources(_dbClient, exportMask);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Unexpected error: deleteExportMask failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("deleteExportMask", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} deleteExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class VnxExportOperations method removeVolumes.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#removeVolume(com.emc.storageos.db.client.model.
* StorageSystem, java.net.URI, java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*
*/
@Override
public void removeVolumes(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} removeVolumes START...", storage.getSerialNumber());
try {
_log.info("removeVolumes: Export mask id: {}", exportMaskURI);
_log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeURIList));
if (initiatorList != null) {
_log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
}
boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
if (isRollback) {
_log.info("Handling removeVolumes as a result of rollback");
List<URI> addedVolumes = new ArrayList<URI>();
// Get the context from the task completer as this is a rollback.
ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(taskCompleter.getOpId());
if (context != null && context.getOperations() != null) {
ListIterator li = context.getOperations().listIterator(context.getOperations().size());
while (li.hasPrevious()) {
ExportOperationContextOperation operation = (ExportOperationContextOperation) li.previous();
if (operation != null && VnxExportOperationContext.OPERATION_ADD_VOLUMES_TO_STORAGE_GROUP.equals(operation.getOperation())) {
addedVolumes = (List<URI>) operation.getArgs().get(0);
_log.info("Removing volumes {} as part of rollback", Joiner.on(',').join(addedVolumes));
}
}
}
volumeURIList = addedVolumes;
if (volumeURIList == null || volumeURIList.isEmpty()) {
_log.info("There was no context found for add volumes. So there is nothing to rollback.");
taskCompleter.ready(_dbClient);
return;
}
}
if (null == volumeURIList || volumeURIList.isEmpty()) {
taskCompleter.ready(_dbClient);
_log.warn("{} removeVolumes invoked with zero volumes, resulting in no-op....", storage.getSerialNumber());
return;
}
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
ExportMaskValidationContext ctx = new ExportMaskValidationContext();
ctx.setStorage(storage);
ctx.setExportMask(exportMask);
ctx.setInitiators(initiatorList);
ctx.setAllowExceptions(!isRollback);
validator.removeVolumes(ctx).validate();
String[] volumeNames = null;
volumeNames = _helper.getBlockObjectAlternateNames(volumeURIList);
/**
* This extra condition makes sure ViPR do not pass null as volume name while invoking HidePaths.
* If we pass null into HidePaths call, SMI will remove the entire storage group and that will give DU.
*/
if (volumeNames == null || volumeNames.length == 0) {
_log.error("Volume's {} alternate name can not be null", volumeURIList);
ServiceError error = DeviceControllerException.errors.removeVolumeFromMaskFailed(volumeURIList.toString());
taskCompleter.error(_dbClient, error);
} else {
deleteOrShrinkStorageGroup(storage, exportMaskURI, volumeURIList, null);
taskCompleter.ready(_dbClient);
}
} catch (Exception e) {
_log.error("Unexpected error: removeVolumes failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("removeVolumes", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Aggregations