use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class VnxExportOperations method createExportMask.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#createExportMask(com.emc.storageos.db.client.
* model.StorageSystem, java.net.URI, com.emc.storageos.volumecontroller.impl.VolumeURIHLU[], java.util.List,
* java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*
*/
@Override
public void createExportMask(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} createExportMask START...", storage.getSerialNumber());
try {
_log.info("createExportMask: Export mask id: {}", exportMaskURI);
_log.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
_log.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
_log.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
ExportOperationContext context = new VnxExportOperationContext();
// Prime the context object
taskCompleter.updateWorkflowStepContext(context);
// performing this validation as a precaution.
if (anyInitiatorsAreInAStorageGroup(storage, initiatorList)) {
ServiceError error = SmisException.errors.anExistingSGAlreadyHasTheInitiators(exportMaskURI.toString(), Joiner.on(',').join(initiatorList));
taskCompleter.error(_dbClient, error);
return;
}
CIMObjectPath[] protocolControllers = createOrGrowStorageGroup(storage, exportMaskURI, volumeURIHLUs, null, targetURIList, taskCompleter);
if (protocolControllers != null) {
ExportOperationContext.insertContextOperation(taskCompleter, VnxExportOperationContext.OPERATION_CREATE_STORAGE_GROUP, exportMaskURI);
_log.debug("createExportMask succeeded.");
for (CIMObjectPath protocolController : protocolControllers) {
_helper.setProtocolControllerNativeId(exportMaskURI, protocolController);
}
CimConnection cimConnection = _helper.getConnection(storage);
createOrGrowStorageGroup(storage, exportMaskURI, null, initiatorList, targetURIList, taskCompleter);
// Call populateDeviceNumberFromProtocolControllers only after initiators
// have been added. HLU's will not be reported till the Device is Host
// visible
ExportMaskOperationsHelper.populateDeviceNumberFromProtocolControllers(_dbClient, cimConnection, exportMaskURI, volumeURIHLUs, protocolControllers, taskCompleter);
modifyClarPrivileges(storage, initiatorList);
taskCompleter.ready(_dbClient);
} else {
_log.debug("createExportMask failed. No protocol controller created.");
ServiceError error = DeviceControllerException.errors.smis.noProtocolControllerCreated();
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
_log.error("Unexpected error: createExportMask failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("createExportMask", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} createExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class VnxExportOperations method addVolumes.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#addVolume(com.emc.storageos.db.client.model.
* StorageSystem, java.net.URI, com.emc.storageos.volumecontroller.impl.VolumeURIHLU[],
* com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void addVolumes(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} addVolumes START...", storage.getSerialNumber());
try {
_log.info("addVolumes: Export mask id: {}", exportMaskURI);
_log.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
if (initiatorList != null) {
_log.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
}
ExportOperationContext context = new VnxExportOperationContext();
// Prime the context object
taskCompleter.updateWorkflowStepContext(context);
// Determine if the volume is already in the masking view.
// If so, log and remove from volumes we need to process.
ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
CIMInstance maskingView = _helper.getLunMaskingProtocolController(storage, mask);
Map<String, Integer> discoveredVolumes = new HashMap<String, Integer>();
if (maskingView != null) {
WBEMClient client = _helper.getConnection(storage).getCimClient();
// Get volumes for the masking instance
discoveredVolumes = _helper.getVolumesFromLunMaskingInstance(client, maskingView);
}
List<VolumeURIHLU> removeURIs = new ArrayList<>();
for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
BlockObject bo = BlockObject.fetch(_dbClient, volumeUriHLU.getVolumeURI());
if (discoveredVolumes.keySet().contains(bo.getNativeId())) {
_log.info("Found volume {} is already associated with masking view. Assuming this is from a previous operation.", bo.getLabel());
removeURIs.add(volumeUriHLU);
}
}
// Create the new array of volumes that don't exist yet in the masking view.
VolumeURIHLU[] addVolumeURIHLUs = new VolumeURIHLU[volumeURIHLUs.length - removeURIs.size()];
int index = 0;
for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
if (!removeURIs.contains(volumeUriHLU)) {
addVolumeURIHLUs[index++] = volumeUriHLU;
}
}
CIMObjectPath[] protocolControllers = createOrGrowStorageGroup(storage, exportMaskURI, addVolumeURIHLUs, null, null, taskCompleter);
CimConnection cimConnection = _helper.getConnection(storage);
ExportMaskOperationsHelper.populateDeviceNumberFromProtocolControllers(_dbClient, cimConnection, exportMaskURI, addVolumeURIHLUs, protocolControllers, taskCompleter);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_002);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Unexpected error: addVolumes failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("addVolumes", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} addVolumes END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class VnxExportOperations method addInitiators.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#addInitiator(com.emc.storageos.db.client.model.
* StorageSystem, java.net.URI, java.util.List, java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*
*/
@Override
public void addInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIs, List<Initiator> initiatorList, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} addInitiators START...", storage.getSerialNumber());
try {
_log.info("addInitiators: Export mask id: {}", exportMaskURI);
if (volumeURIs != null) {
_log.info("addInitiators: volumes : {}", Joiner.on(',').join(volumeURIs));
}
_log.info("addInitiators: initiators : {}", Joiner.on(',').join(initiatorList));
_log.info("addInitiators: targets : {}", Joiner.on(",").join(targets));
ExportOperationContext context = new VnxExportOperationContext();
// Prime the context object
taskCompleter.updateWorkflowStepContext(context);
createOrGrowStorageGroup(storage, exportMaskURI, null, initiatorList, targets, taskCompleter);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_003);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Unexpected error: addInitiators failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("addInitiators", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} addInitiators END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class XtremIOExportOperations method addInitiators.
@Override
public void addInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIs, List<Initiator> initiators, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} addInitiators START...", storage.getSerialNumber());
try {
_log.info("addInitiators: Export mask id: {}", exportMaskURI);
if (volumeURIs != null) {
_log.info("addInitiators: volumes : {}", Joiner.on(',').join(volumeURIs));
}
_log.info("addInitiators: initiators : {}", Joiner.on(',').join(initiators));
_log.info("addInitiators: targets : {}", Joiner.on(",").join(targets));
ExportOperationContext context = new XtremIOExportOperationContext();
// Prime the context object
taskCompleter.updateWorkflowStepContext(context);
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
if (exportMask == null || exportMask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskURI);
}
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
List<Initiator> initiatorsToBeCreated = new ArrayList<Initiator>();
ArrayListMultimap<String, Initiator> initiatorToIGMap = XtremIOProvUtils.mapInitiatorToInitiatorGroup(storage.getSerialNumber(), initiators, initiatorsToBeCreated, xioClusterName, client);
XtremIOExportMaskVolumesValidator volumeValidator = (XtremIOExportMaskVolumesValidator) validator.addInitiators(storage, exportMask, volumeURIs);
volumeValidator.setIgNames(initiatorToIGMap.keySet());
volumeValidator.validate();
Map<URI, Integer> map = new HashMap<URI, Integer>();
for (URI volumeURI : volumeURIs) {
String hlu = exportMask.getVolumes().get(volumeURI.toString());
if (NullColumnValueGetter.isNotNullValue(hlu)) {
map.put(volumeURI, Integer.parseInt(hlu));
}
}
// to make it uniform , using these structures
VolumeURIHLU[] volumeLunArray = ControllerUtils.getVolumeURIHLUArray(storage.getSystemType(), map, dbClient);
runLunMapCreationAlgorithm(storage, exportMask, volumeLunArray, initiators, targets, client, xioClusterName, initiatorToIGMap, initiatorsToBeCreated, taskCompleter);
} catch (final Exception ex) {
_log.error("Problem in addInitiators: ", ex);
ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("addInitiators", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
_log.info("{} addInitiators END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.
the class XtremIOExportOperations method deleteExportMask.
@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));
}
List<URI> volumesToBeUnmapped = new ArrayList<URI>();
boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
if (isRollback) {
_log.info("Handling deleteExportMask as a result of rollback");
List<URI> addedVolumes = new ArrayList<URI>();
// Get the context from the task completer
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 && XtremIOExportOperationContext.OPERATION_ADD_VOLUMES_TO_INITIATOR_GROUP.equals(operation.getOperation())) {
addedVolumes = (List<URI>) operation.getArgs().get(0);
_log.info("Removing volumes {} as part of rollback", Joiner.on(',').join(addedVolumes));
}
}
}
volumesToBeUnmapped = addedVolumes;
if (volumesToBeUnmapped == null || volumesToBeUnmapped.isEmpty()) {
_log.info("There was no context found for add volumes. So there is nothing to rollback.");
taskCompleter.ready(dbClient);
return;
}
} else {
if (volumeURIList != null) {
volumesToBeUnmapped = volumeURIList;
}
}
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
if (exportMask == null || exportMask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskURI);
}
runLunMapDeletionOrRemoveInitiatorAlgorithm(storage, exportMask, volumesToBeUnmapped, initiatorList, taskCompleter);
} catch (final Exception ex) {
_log.error("Problem in deleteExportMask: ", ex);
ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("deleteExportMask", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
_log.info("{} deleteExportMask END...", storage.getSerialNumber());
}
Aggregations