Search in sources :

Example 16 with ExportOperationContext

use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method addVolumes.

@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 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();
        ArrayListMultimap<String, Initiator> initiatorToIGMap = XtremIOProvUtils.mapInitiatorToInitiatorGroup(storage.getSerialNumber(), initiatorList, null, xioClusterName, client);
        XtremIOExportMaskInitiatorsValidator initiatorsValidator = (XtremIOExportMaskInitiatorsValidator) validator.addVolumes(storage, exportMaskURI, initiatorList);
        initiatorsValidator.setInitiatorToIGMap(initiatorToIGMap);
        initiatorsValidator.validate();
        runLunMapCreationAlgorithm(storage, exportMask, volumeURIHLUs, initiatorList, null, client, xioClusterName, initiatorToIGMap, null, taskCompleter);
    } catch (final Exception ex) {
        _log.error("Problem in addVolumes: ", ex);
        ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("addVolumes", ex.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    _log.info("{} addVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) XtremIOExportMaskInitiatorsValidator(com.emc.storageos.volumecontroller.impl.validators.xtremio.XtremIOExportMaskInitiatorsValidator) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 17 with ExportOperationContext

use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskURI, List<URI> volumeUris, 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(volumeUris));
        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.
            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));
                    }
                }
            }
            volumeUris = addedVolumes;
            if (volumeUris == null || volumeUris.isEmpty()) {
                _log.info("There was no context found for add volumes. So there is nothing to rollback.");
                taskCompleter.ready(dbClient);
                return;
            }
        }
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        if (exportMask == null || exportMask.getInactive()) {
            throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskURI);
        }
        runLunMapDeletionAlgorithm(storage, exportMask, volumeUris, initiatorList, taskCompleter);
    } catch (final Exception ex) {
        _log.error("Problem in removeVolumes: ", ex);
        ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("removeVolumes", ex.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    _log.info("{} removeVolumes 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)

Example 18 with ExportOperationContext

use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method runLunMapDeletionOrRemoveInitiatorAlgorithm.

/**
 * It deletes the LunMap if the IG contains no other initiators than the requested ones.
 * Else it removes the requested initiators from the IG
 */
private void runLunMapDeletionOrRemoveInitiatorAlgorithm(StorageSystem storage, ExportMask exportMask, List<URI> volumes, List<Initiator> initiators, TaskCompleter taskCompleter) throws DeviceControllerException {
    // find LunMap associated with Volume
    // Then find initiatorGroup associated with this lun map
    XtremIOClient client = null;
    // Default_IG;
    try {
        String hostName = null;
        String clusterName = null;
        client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        boolean initiatorsOfRP = ExportUtils.checkIfInitiatorsForRP(initiators);
        for (Initiator initiator : initiators) {
            if (null != initiator.getHostName()) {
                // initiators already grouped by Host
                hostName = initiator.getHostName();
                clusterName = initiator.getClusterName();
                break;
            }
        }
        ArrayListMultimap<String, Initiator> groupInitiatorsByIG = XtremIOProvUtils.mapInitiatorToInitiatorGroup(storage.getSerialNumber(), initiators, null, xioClusterName, client);
        ArrayListMultimap<String, Initiator> knownInitiatorsToIGMap = ArrayListMultimap.create();
        // DU validations for removing volumes from IG.
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(exportMask);
        ctx.setInitiators(initiators);
        ctx.setAllowExceptions(!WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId()));
        XtremIOExportMaskInitiatorsValidator initiatorsValidator = (XtremIOExportMaskInitiatorsValidator) validator.removeVolumes(ctx);
        initiatorsValidator.setInitiatorToIGMap(groupInitiatorsByIG);
        initiatorsValidator.setKnownInitiatorToIGMap(knownInitiatorsToIGMap);
        initiatorsValidator.validate();
        Set<String> igNames = groupInitiatorsByIG.keySet();
        List<String> failedVolumes = new ArrayList<String>();
        List<String> failedIGs = new ArrayList<String>();
        for (URI volumeUri : volumes) {
            BlockObject blockObj = BlockObject.fetch(dbClient, volumeUri);
            _log.info("Block Obj {} , wwn {}", blockObj.getId(), blockObj.getWWN());
            XtremIOVolume xtremIOVolume = null;
            if (URIUtil.isType(volumeUri, Volume.class)) {
                xtremIOVolume = XtremIOProvUtils.isVolumeAvailableInArray(client, blockObj.getDeviceLabel(), xioClusterName);
            } else {
                if (URIUtil.isType(volumeUri, BlockSnapshot.class) && BlockObject.checkForRP(dbClient, volumeUri)) {
                    // If the BlockObject is a BlockSnapshot of type RP (bookmark), there will be no exported
                    // snapshot. In this case, a target volume will have been exported and the deviceLabel of
                    // the BlockSnapshot reflects the name of that target.
                    _log.info(String.format("Dealing with a RecoverPoint bookmark lun mapping.  Checking to see if volume %s is available on array.", blockObj.getDeviceLabel()));
                    xtremIOVolume = XtremIOProvUtils.isVolumeAvailableInArray(client, blockObj.getDeviceLabel(), xioClusterName);
                } else {
                    xtremIOVolume = XtremIOProvUtils.isSnapAvailableInArray(client, blockObj.getDeviceLabel(), xioClusterName);
                }
            }
            if (null != xtremIOVolume) {
                // I need lun map id and igName
                // if iGName is available in the above group:
                _log.info("Volume Details {}", xtremIOVolume.toString());
                _log.info("Volume lunMap details {}", xtremIOVolume.getLunMaps().toString());
                // Lun Maps to delete
                Set<String> lunMaps = new HashSet<String>();
                boolean removeInitiator = false;
                String volId = xtremIOVolume.getVolInfo().get(2);
                if (xtremIOVolume.getLunMaps().isEmpty()) {
                    // handle scenarios where volumes gets unexported already
                    _log.info("Volume  {} doesn't have any existing export available on Array, unexported already.", xtremIOVolume.toString());
                    exportMask.removeFromUserCreatedVolumes(blockObj);
                    exportMask.removeVolume(blockObj.getId());
                    continue;
                }
                for (List<Object> lunMapEntries : xtremIOVolume.getLunMaps()) {
                    @SuppressWarnings("unchecked") List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
                    String igName = (String) igDetails.get(1);
                    // IG details is actually transforming to a double by default, even though
                    // its modeled as List<String>
                    // hence this logic
                    Double IgIdDouble = (Double) igDetails.get(2);
                    String igId = String.valueOf(IgIdDouble.intValue());
                    _log.info("IG Name: {} Id: {} found in Lun Map", igName, igId);
                    if (!igNames.contains(igName)) {
                        _log.info("Volume is associated with IG {} which is not in the removal list requested, ignoring..", igName);
                        continue;
                    }
                    /**
                     * i) If Cluster export:
                     * If there are additional initiators other than the requested ones (Single IG with all cluster
                     * initiators)
                     * - - - remove initiator from IG,
                     * - - - Note: If initiators are of RP (CTRL-13622), always delete LunMap.
                     * - ii) Host export:
                     * - - -- delete LunMap
                     */
                    boolean igHasOtherHostInitiatorsOfSameCluster = knownInitiatorsToIGMap.get(igName).size() > groupInitiatorsByIG.get(igName).size();
                    if (!initiatorsOfRP && clusterName != null && igHasOtherHostInitiatorsOfSameCluster) {
                        removeInitiator = true;
                    }
                    if (!removeInitiator) {
                        // delete LunMap
                        @SuppressWarnings("unchecked") List<Object> tgtGroupDetails = (List<Object>) lunMapEntries.get(1);
                        Double tgIdDouble = (Double) tgtGroupDetails.get(2);
                        String tgtid = String.valueOf(tgIdDouble.intValue());
                        String lunMapId = volId.concat(XtremIOConstants.UNDERSCORE).concat(igId).concat(XtremIOConstants.UNDERSCORE).concat(tgtid);
                        _log.info("LunMap Id {} Found associated with Volume {}", lunMapId, blockObj.getDeviceLabel());
                        lunMaps.add(lunMapId);
                    }
                }
                // there will be only one lun map always
                for (String lunMap : lunMaps) {
                    try {
                        client.deleteLunMap(lunMap, xioClusterName);
                    } catch (Exception e) {
                        failedVolumes.add(volumeUri.toString().concat(XtremIOConstants.DASH).concat(e.getMessage()));
                        _log.warn("Deletion of Lun Map {} failed}", lunMap, e);
                    }
                }
                // remove initiator from IG
                if (removeInitiator) {
                    _log.info("Removing requested intiators from IG instead of deleting LunMap" + " as the IG contains other Host's initiators belonging to same Cluster.");
                    ctx = new ExportMaskValidationContext();
                    ctx.setStorage(storage);
                    ctx.setExportMask(exportMask);
                    ctx.setBlockObjects(volumes, dbClient);
                    ctx.setAllowExceptions(!WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId()));
                    // DU validation when removing initiators
                    XtremIOExportMaskVolumesValidator volumeValidator = (XtremIOExportMaskVolumesValidator) validator.removeInitiators(ctx);
                    volumeValidator.setIgNames(groupInitiatorsByIG.keySet());
                    volumeValidator.validate();
                    List<Initiator> initiatorsToBeRemoved = new ArrayList<Initiator>();
                    // Get the context from the task completer, in case 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()) {
                            _log.info("Handling deleteExportMask as a result of rollback");
                            ExportOperationContextOperation operation = (ExportOperationContextOperation) li.previous();
                            if (operation != null && XtremIOExportOperationContext.OPERATION_ADD_INITIATORS_TO_INITIATOR_GROUP.equals(operation.getOperation())) {
                                initiatorsToBeRemoved = (List<Initiator>) operation.getArgs().get(0);
                                _log.info("Removing initiators {} as part of rollback", Joiner.on(',').join(initiatorsToBeRemoved));
                            }
                        }
                    } else {
                        initiatorsToBeRemoved = initiators;
                    }
                    // Deleting the initiator automatically removes the initiator from lun map
                    for (Initiator initiator : initiatorsToBeRemoved) {
                        try {
                            // check if Initiator has already been deleted during previous volume processing
                            String initiatorName = initiator.getMappedInitiatorName(storage.getSerialNumber());
                            XtremIOInitiator initiatorObj = client.getInitiator(initiatorName, xioClusterName);
                            if (null != initiatorObj) {
                                client.deleteInitiator(initiatorName, xioClusterName);
                            } else {
                                _log.info("Initiator {} already deleted", initiatorName);
                            }
                        } catch (Exception e) {
                            failedIGs.add(initiator.getLabel().concat(XtremIOConstants.DASH).concat(e.getMessage()));
                            _log.warn("Removal of Initiator {} from IG failed", initiator.getLabel(), e);
                        }
                    }
                }
            } else {
                exportMask.removeFromUserCreatedVolumes(blockObj);
                exportMask.removeVolume(blockObj.getId());
            }
        }
        dbClient.updateObject(exportMask);
        if (!failedVolumes.isEmpty()) {
            String errMsg = "Export Operations failed for these volumes: ".concat(Joiner.on(", ").join(failedVolumes));
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(errMsg, null);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        if (!failedIGs.isEmpty()) {
            String errMsg = "Export Operations failed deleting these initiators: ".concat(Joiner.on(", ").join(failedIGs));
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(errMsg, null);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        // Clean IGs if empty
        deleteInitiatorGroup(groupInitiatorsByIG, client, xioClusterName);
        // delete IG Folder as well if IGs are empty
        deleteInitiatorGroupFolder(client, xioClusterName, clusterName, hostName, storage);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error(String.format("Export Operations failed - maskName: %s", exportMask.getId().toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : XtremIOExportMaskInitiatorsValidator(com.emc.storageos.volumecontroller.impl.validators.xtremio.XtremIOExportMaskInitiatorsValidator) ArrayList(java.util.ArrayList) URI(java.net.URI) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) 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) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ExportOperationContextOperation(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext.ExportOperationContextOperation) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOExportMaskVolumesValidator(com.emc.storageos.volumecontroller.impl.validators.xtremio.XtremIOExportMaskVolumesValidator) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ListIterator(java.util.ListIterator) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 19 with ExportOperationContext

use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method createExportMask.

@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 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(), initiatorList, initiatorsToBeCreated, xioClusterName, client);
        runLunMapCreationAlgorithm(storage, exportMask, volumeURIHLUs, initiatorList, targetURIList, client, xioClusterName, initiatorToIGMap, initiatorsToBeCreated, taskCompleter);
    } catch (final Exception ex) {
        _log.error("Problem in createExportMask: ", ex);
        ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("createExportMask", ex.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    _log.info("{} createExportMask END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) ArrayList(java.util.ArrayList) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 20 with ExportOperationContext

use of com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext in project coprhd-controller by CoprHD.

the class VnxExportOperations method removeInitiators.

/*
     * (non-Javadoc)
     *
     * @see
     * com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#removeInitiator(com.emc.storageos.db.client.
     * model.StorageSystem, java.net.URI, java.util.List, java.util.List,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     *
     */
@Override
public void removeInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<Initiator> initiatorList, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} removeInitiators START...", storage.getSerialNumber());
    try {
        _log.info("removeInitiators: Export mask id: {}", exportMaskURI);
        if (volumeURIList != null) {
            _log.info("removeInitiators: volumes : {}", Joiner.on(',').join(volumeURIList));
        }
        _log.info("removeInitiators: initiators : {}", Joiner.on(',').join(initiatorList));
        if (targets != null) {
            _log.info("removeInitiators: targets : {}", Joiner.on(',').join(targets));
        }
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
        if (isRollback) {
            _log.info("Handling removeInitiators as a result of rollback");
            List<Initiator> addedInitiators = new ArrayList<Initiator>();
            // 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_INITIATORS_TO_STORAGE_GROUP.equals(operation.getOperation())) {
                        addedInitiators = (List<Initiator>) operation.getArgs().get(0);
                        _log.info("Removing initiators {} as part of rollback", Joiner.on(',').join(addedInitiators));
                    }
                }
            }
            initiatorList = addedInitiators;
            if (initiatorList == null || initiatorList.isEmpty()) {
                _log.info("There was no context found for add initiator. So there is nothing to rollback.");
                taskCompleter.ready(_dbClient);
                return;
            }
        }
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(exportMask);
        ctx.setBlockObjects(volumeURIList, _dbClient);
        ctx.setAllowExceptions(!isRollback);
        validator.removeInitiators(ctx).validate();
        deleteStorageHWIDs(storage, initiatorList);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Unexpected error: removeInitiators failed.", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("removeInitiators", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("{} removeInitiators END...", storage.getSerialNumber());
}
Also used : ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Initiator(com.emc.storageos.db.client.model.Initiator) 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) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException)

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