Search in sources :

Example 1 with RemoteGroupAssociationNotFoundException

use of com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException in project coprhd-controller by CoprHD.

the class SRDFOperations method performSwap.

public void performSwap(StorageSystem targetSystem, Volume target, TaskCompleter completer) {
    log.info("START performSwap");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        Volume sourceVolume = getSourceVolume(target);
        StorageSystem activeSystem = findProviderWithGroup(target);
        Collection<CIMObjectPath> syncPaths = utils.getSynchronizations(activeSystem, sourceVolume, target, false);
        CIMInstance firstSync = getInstance(syncPaths.iterator().next(), activeSystem);
        AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(activeSystem);
        SRDFOperationContext ctx = null;
        if (!isFailedOver(firstSync)) {
            log.info("Failing over link");
            ctx = ctxFactory.build(SRDFOperation.FAIL_OVER, target);
            ctx.perform();
        }
        ctx = ctxFactory.build(SRDFOperation.SWAP, target);
        ctx.perform();
        log.info("Swapping Volume Pair {} succeeded ", sourceVolume.getId());
        log.info("Changing R1 and R2 characteristics after swap");
        LinkStatus successLinkStatus = LinkStatus.SWAPPED;
        if (LinkStatus.SWAPPED.name().equalsIgnoreCase(target.getLinkStatus())) {
            // Already swapped. Move back to CONSISTENT or IN_SYNC.
            if (Mode.ASYNCHRONOUS.name().equalsIgnoreCase(target.getSrdfCopyMode())) {
                successLinkStatus = LinkStatus.CONSISTENT;
            } else {
                successLinkStatus = LinkStatus.IN_SYNC;
            }
        }
        changeSRDFVolumeBehaviors(sourceVolume, target, dbClient, successLinkStatus.toString());
        log.info("Updating RemoteDirectorGroup after swap");
        changeRemoteDirectorGroup(target.getSrdfGroup());
        StorageSystem sourceSystemAfterSwap = dbClient.queryObject(StorageSystem.class, target.getStorageController());
        // we run all SRDF operations using RDF group's source provider.
        // target provider needs to be refreshed to perform any snap/clone operations following swap.
        callEMCRefresh(helper, sourceSystemAfterSwap);
        // Refresh our view of the target, since it is now the source volume.
        target = dbClient.queryObject(Volume.class, sourceVolume.getId());
        boolean success = false;
        int attempts = 1;
        while (!success && attempts <= RESUME_AFTER_SWAP_MAX_ATTEMPTS) {
            try {
                // Use new context to perform resume operation.
                AbstractSRDFOperationContextFactory establishFactory = getContextFactory(activeSystem);
                ctx = establishFactory.build(SRDFOperation.ESTABLISH, target);
                ctx.appendFilters(new ErrorOnEmptyFilter());
                ctx.perform();
                success = true;
            } catch (WBEMException | NoSynchronizationsFoundException e) {
                log.warn(format(RESUME_AFTER_SWAP_EXCEPTION_MSG, attempts, RESUME_AFTER_SWAP_MAX_ATTEMPTS), e);
                attempts++;
                Thread.sleep(RESUME_AFTER_SWAP_SLEEP);
            }
        }
        if (!success) {
            URI sourceId = target.getSrdfParent().getURI();
            String msg = format("Failed to resume SRDF link after swap for source: %s", sourceId);
            log.error(msg);
            error = SmisException.errors.establishAfterSwapFailure(sourceId.toString(), target.getId().toString());
        }
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.warn("No remote group association found for {}. It may have already been removed.", target.getId());
    } catch (Exception e) {
        log.error("Failed to swap srdf link {}", target.getSrdfParent().getURI(), e);
        error = getServiceError(e);
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) LinkStatus(com.emc.storageos.db.client.model.Volume.LinkStatus) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) ErrorOnEmptyFilter(com.emc.storageos.volumecontroller.impl.smis.srdf.collectors.ErrorOnEmptyFilter) CIMObjectPath(javax.cim.CIMObjectPath) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) WBEMException(javax.wbem.WBEMException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with RemoteGroupAssociationNotFoundException

use of com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException in project coprhd-controller by CoprHD.

the class SRDFOperations method performStop.

public void performStop(StorageSystem system, Volume target, TaskCompleter completer) {
    log.info("START performStop");
    checkTargetHasParentOrFail(target);
    AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(system);
    ServiceError error = null;
    try {
        List<Volume> volumes = utils.getAssociatedVolumes(system, target);
        Collection<Volume> srcVolumes = newArrayList(filter(volumes, utils.volumePersonalityPredicate(SOURCE)));
        Collection<Volume> tgtVolumes = newArrayList(filter(volumes, utils.volumePersonalityPredicate(TARGET)));
        ctxFactory.build(SRDFOperation.SUSPEND, target).perform();
        boolean isTargetCopyModeActive = target.getSrdfCopyMode() != null && target.getSrdfCopyMode().equals(Mode.ACTIVE.toString());
        if (isTargetCopyModeActive && !target.hasConsistencyGroup()) {
            Volume source = getSourceVolume(target);
            ((SRDFLinkStopCompleter) completer).setVolumes(Arrays.asList(source), Arrays.asList(target));
            log.info("Source: {}", source.getNativeId());
            log.info("Target: {}", target.getNativeId());
            // Remove the source and target from the list that will be stopped.
            // If tgtVolumes is not empty then after stop(deletepair) resume(establish) will be done
            // on rest of the volumes in the SRDF group.
            Iterator<Volume> srcIter = srcVolumes.iterator();
            while (srcIter.hasNext()) {
                if (srcIter.next().getId().equals(source.getId())) {
                    srcIter.remove();
                    break;
                }
            }
            Iterator<Volume> tgtIter = tgtVolumes.iterator();
            while (tgtIter.hasNext()) {
                if (tgtIter.next().getId().equals(target.getId())) {
                    tgtIter.remove();
                    break;
                }
            }
            // DELETE_PAIR will stop only one pair
            ctxFactory.build(SRDFOperation.DELETE_PAIR, target).perform();
            if (!tgtVolumes.isEmpty() && tgtVolumes.iterator().hasNext()) {
                // We need to get other pairs back in the original state.
                ctxFactory.build(SRDFOperation.ESTABLISH, tgtVolumes.iterator().next()).perform();
            }
            // If Active SRDF copy mode then refresh storage system and update volume properties
            // as target volume wwn changes after stop
            ArrayList<URI> volumeURIs = new ArrayList<URI>(Arrays.asList(target.getId()));
            refreshStorageSystem(system.getId());
            refreshVolumeProperties(system.getId(), volumeURIs);
        } else {
            ((SRDFLinkStopCompleter) completer).setVolumes(srcVolumes, tgtVolumes);
            log.info("Sources: {}", Joiner.on(", ").join(transform(srcVolumes, fctnBlockObjectToNativeGuid())));
            log.info("Targets: {}", Joiner.on(", ").join(transform(tgtVolumes, fctnBlockObjectToNativeGuid())));
            ctxFactory.build(SRDFOperation.DELETE_GROUP_PAIRS, target).perform();
            if (isTargetCopyModeActive) {
                // If Active SRDF copy mode then refresh storage system and update volume properties
                // as target volume wwn changes after stop
                ArrayList<URI> volumeURIs = new ArrayList<URI>(Arrays.asList(target.getId()));
                for (Volume tgtVolume : tgtVolumes) {
                    volumeURIs.add(tgtVolume.getId());
                }
                refreshStorageSystem(system.getId());
                refreshVolumeProperties(system.getId(), volumeURIs);
            }
        }
        if (target.hasConsistencyGroup()) {
            StorageSystem provider = findProviderWithGroup(target);
            cleanAllCgVolumesFromDeviceGroups(tgtVolumes, provider);
        }
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.warn("No remote group association found for {}.  It may have already been removed.", target.getId());
    } catch (Exception e) {
        log.error("Failed to stop srdf link {} {}", target.getSrdfParent().getURI(), e);
        StringBuffer sf = new StringBuffer();
        sf.append(e.getMessage());
        if (target.getSrdfCopyMode() != null && target.getSrdfCopyMode().equals(Mode.ACTIVE.toString()) && !target.hasConsistencyGroup()) {
            try {
                // Rollback to previous status in case of stop failure
                ctxFactory.build(SRDFOperation.ESTABLISH, target).perform();
            } catch (Exception e1) {
                log.error("Failed to resume srdf link during rollback {} {}", target.getSrdfParent().getURI(), e);
                sf.append("Rollback error: ").append(e1.getMessage());
            }
        }
        error = SmisException.errors.jobFailed(sf.toString());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkStopCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with RemoteGroupAssociationNotFoundException

use of com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException in project coprhd-controller by CoprHD.

the class SRDFOperations method performSuspend.

public void performSuspend(StorageSystem system, Volume target, boolean consExempt, boolean refreshVolumeProperties, TaskCompleter completer) {
    log.info("START performSuspend (consExempt={})", consExempt);
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        SRDFOperation op = consExempt ? SRDFOperation.SUSPEND_CONS_EXEMPT : SRDFOperation.SUSPEND;
        SRDFOperationContext suspendCtx = getContextFactory(system).build(op, target);
        suspendCtx.perform();
        if (refreshVolumeProperties) {
            refreshTargetVolumeProperties(system, target);
        }
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.warn("No remote group association found for {}.  It may have already been removed.", target.getId());
    } catch (Exception e) {
        log.error("Failed to suspend srdf link {}", target.getSrdfParent().getURI(), e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) SRDFOperation(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory.SRDFOperation) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)

Example 4 with RemoteGroupAssociationNotFoundException

use of com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException in project coprhd-controller by CoprHD.

the class SRDFOperations method performSplit.

public void performSplit(StorageSystem system, Volume target, TaskCompleter completer) {
    log.info("START performSplit");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        SRDFOperationContext splitCtx = getContextFactory(system).build(SRDFOperation.SPLIT, target);
        splitCtx.perform();
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.warn("No remote group association found for {}.  It may have already been removed.", target.getId());
    } catch (Exception e) {
        log.error("Failed to pause srdf link {}", target.getSrdfParent().getURI(), e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)

Example 5 with RemoteGroupAssociationNotFoundException

use of com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException in project coprhd-controller by CoprHD.

the class SRDFOperations method performDetach.

public void performDetach(StorageSystem system, Volume target, boolean onGroup, TaskCompleter completer) {
    log.info("START performDetach");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(system);
        SRDFOperation suspendOp = null;
        SRDFOperation detachOp = null;
        if (onGroup) {
            suspendOp = SRDFOperation.SUSPEND;
            detachOp = SRDFOperation.DELETE_GROUP_PAIRS;
        } else {
            if (target.getSrdfCopyMode() != null && target.getSrdfCopyMode().equals(Mode.ACTIVE.toString())) {
                suspendOp = SRDFOperation.SUSPEND;
            } else {
                suspendOp = SRDFOperation.SUSPEND_CONS_EXEMPT;
            }
            detachOp = SRDFOperation.DELETE_PAIR;
        }
        ctxFactory.build(suspendOp, target).perform();
        ctxFactory.build(detachOp, target).perform();
        utils.removeFromRemoteGroups(target);
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.info("SRDF link is already detached {}", target.getSrdfParent().getURI(), e);
        // If SRDF link is already detached then we won't find the association hence we can just move on
        // to the next step.This is added because of SMIS intermittent issue where during delete volume
        // detach works but then after detach there is failure then retry never work if we don't catch
        // this exception. This is added to so that user can retry to delete volume.
        completer.ready(dbClient);
    } catch (Exception e) {
        log.error("Failed to detach srdf link {}", target.getSrdfParent().getURI(), e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) SRDFOperation(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory.SRDFOperation) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 NoSynchronizationsFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)5 RemoteGroupAssociationNotFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException)5 WBEMException (javax.wbem.WBEMException)5 AbstractSRDFOperationContextFactory (com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory)3 SRDFOperationContext (com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 Volume (com.emc.storageos.db.client.model.Volume)2 SRDFOperation (com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory.SRDFOperation)2 URI (java.net.URI)2 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 LinkStatus (com.emc.storageos.db.client.model.Volume.LinkStatus)1 CustomQueryUtility.queryActiveResourcesByConstraint (com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint)1 SRDFLinkStopCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter)1 ErrorOnEmptyFilter (com.emc.storageos.volumecontroller.impl.smis.srdf.collectors.ErrorOnEmptyFilter)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 CIMInstance (javax.cim.CIMInstance)1