Search in sources :

Example 21 with ExportOperationContext

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) CIMObjectPath(javax.cim.CIMObjectPath) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException)

Example 22 with ExportOperationContext

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 23 with ExportOperationContext

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException)

Example 24 with ExportOperationContext

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOExportMaskVolumesValidator(com.emc.storageos.volumecontroller.impl.validators.xtremio.XtremIOExportMaskVolumesValidator) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 25 with ExportOperationContext

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) ExportOperationContextOperation(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext.ExportOperationContextOperation) ListIterator(java.util.ListIterator) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

ExportOperationContext (com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext)39 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)33 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)33 ExportMask (com.emc.storageos.db.client.model.ExportMask)29 ArrayList (java.util.ArrayList)28 URI (java.net.URI)24 Initiator (com.emc.storageos.db.client.model.Initiator)17 ExportOperationContextOperation (com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext.ExportOperationContextOperation)14 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)13 ExportMaskValidationContext (com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext)13 WBEMException (javax.wbem.WBEMException)13 HashSet (java.util.HashSet)12 ListIterator (java.util.ListIterator)10 BlockObject (com.emc.storageos.db.client.model.BlockObject)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)7 WorkflowException (com.emc.storageos.workflow.WorkflowException)7