Search in sources :

Example 41 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class SRDFOperations method getDeviceGroup.

private Set<CIMObjectPath> getDeviceGroup(final StorageSystem system, final StorageSystem forProvider, final Volume volume) {
    CloseableIterator<CIMObjectPath> names = null;
    Set<CIMObjectPath> deviceGroups = new HashSet<>();
    try {
        CIMObjectPath path = cimPath.getBlockObjectPath(system, volume);
        names = helper.getAssociatorNames(forProvider, path, null, SE_REPLICATION_GROUP, null, null);
        while (names.hasNext()) {
            deviceGroups.add(names.next());
        }
    } catch (WBEMException e) {
        log.warn("Failed to acquire replication groups associated with Volume {}", volume.getId(), e);
    } finally {
        if (null != names) {
            names.close();
        }
    }
    return deviceGroups;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) HashSet(java.util.HashSet)

Example 42 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class SRDFOperations method createSRDFMirror.

public void createSRDFMirror(final StorageSystem systemWithCg, final List<Volume> srcVolumes, final List<Volume> targetVolumes, final boolean storSyncAvailable, final TaskCompleter completer) {
    log.info("START createSRDFMirror");
    CIMObjectPath srcCGPath = null;
    CIMObjectPath tgtCGPath = null;
    try {
        Volume firstSource = srcVolumes.iterator().next();
        Volume firstTarget = targetVolumes.iterator().next();
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
        StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
        int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
        CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(systemWithCg);
        srcCGPath = createDeviceGroup(sourceSystem, systemWithCg, srcVolumes, dbClient);
        String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Source Volumes placed into replication group: {}", srcCGPath);
        // Note: We switch to the appropriate targetSystem but use sourceSystem for the provider call
        tgtCGPath = createDeviceGroup(targetSystem, systemWithCg, targetVolumes, dbClient);
        String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Target Volumes placed into replication group: {}", tgtCGPath);
        // FALSE being passed, because the source volume will have data when /continuous-copies/START API is invoked.
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(systemWithCg, modeValue, true, false);
        CIMArgument[] inArgs = null;
        CIMArgument[] outArgs = new CIMArgument[5];
        if (completer instanceof SRDFLinkStartCompleter) {
            ((SRDFLinkStartCompleter) completer).setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
        }
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
        if (storSyncAvailable) {
            log.info("Creating Group synchronization between source volume group and target volume group");
            // there are storage synchronizations available for these pairs
            Collection<CIMObjectPath> elementSynchronizations = utils.getSynchronizations(systemWithCg, firstSource, firstTarget);
            inArgs = helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(srcCGPath, tgtCGPath, elementSynchronizations, groupName);
            helper.invokeMethod(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
            // No Job returned
            completer.ready(dbClient);
        } else {
            CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(systemWithCg, group);
            inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
            helper.invokeMethodSynchronously(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, systemWithCg.getId(), completer));
            completer.ready(dbClient);
        }
    } catch (WBEMException wbeme) {
        log.error("SMI-S error creating mirror group synchronization", wbeme);
        // check whether synchronization really succeeds in Array
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
            completer.ready(dbClient);
        } else {
            ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    } catch (Exception e) {
        log.error("Error creating mirror group synchronization", e);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
            completer.ready(dbClient);
        } else {
            if (e.getMessage().contains("Replication Control Succeeded")) {
                log.info("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation.", e);
                completer.ready(dbClient);
                return;
            }
            ServiceError error = SmisException.errors.jobFailed(e.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SRDFLinkStartCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) 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) SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 43 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class SRDFOperations method createSRDFCgPairs.

public void createSRDFCgPairs(final StorageSystem sourceSystem, List<URI> sourceURIs, List<URI> targetURIs, SRDFMirrorCreateCompleter completer) {
    List<Volume> sourceVolumes = dbClient.queryObject(Volume.class, sourceURIs);
    List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetURIs);
    Volume firstSource = sourceVolumes.get(0);
    Volume firstTarget = targetVolumes.get(0);
    int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
    RemoteDirectorGroup raGroup = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, raGroup.getRemoteStorageSystemUri());
    CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(sourceSystem);
    CIMObjectPath srcCGPath = null;
    CIMObjectPath tgtCGPath = null;
    try {
        log.info("Creating sources group with: {}", firstSource.getNativeId());
        srcCGPath = createDeviceGroup(sourceSystem, sourceSystem, sourceVolumes, dbClient);
        String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Source volumes placed into replication group: {}", srcCGPath);
        log.info("Creating targets group with: {}", targetVolumes.get(0).getNativeId());
        tgtCGPath = createDeviceGroup(targetSystem, sourceSystem, targetVolumes, dbClient);
        String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Target volumes placed into replication group: {}", tgtCGPath);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            log.info("SRDF Link already established.");
            return;
        }
        CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(sourceSystem, raGroup);
        // look for existing volumes, if found then use AddSyncPair
        boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(sourceSystem, modeValue, true, formatVolumeFlagNeeded);
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
        CIMArgument[] inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
        CIMArgument[] outArgs = new CIMArgument[5];
        completer.setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
        helper.invokeMethodSynchronously(sourceSystem, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, sourceSystem.getId(), completer));
        completer.ready(dbClient);
    } catch (WBEMException wbeme) {
        String msg = format("SMI-S error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
        log.error(msg, wbeme);
        // check whether synchronization really succeeds in Array
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            completer.ready(dbClient);
        } else {
            ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    } catch (Exception e) {
        String msg = format("Error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
        log.error(msg, e);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            completer.ready(dbClient);
        } else {
            if (e.getMessage().contains("Replication Control Succeeded")) {
                String dbMsg = format("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation. for Sources:%s Targets:%s", sourceURIs, targetURIs);
                log.info(dbMsg, e);
                completer.ready(dbClient);
                return;
            }
            ServiceError error = SmisException.errors.jobFailed(e.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) 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) SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 44 with WBEMException

use of javax.wbem.WBEMException 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 45 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class SmisCommandHelper method checkExists.

/**
 * This method is a wrapper for the getInstance. If the object is not found, it returns a null
 * value instead of throwing an exception.
 *
 * @param storage
 *            [required] - StorageSystem object to which an SMI-S connection would be made
 * @param objectPath
 *            [required]
 * @param propagated
 *            [required]
 * @param includeClassOrigin
 *            [required]
 * @return CIMInstance object that represents the existing object
 * @throws Exception
 */
public CIMInstance checkExists(StorageSystem storage, CIMObjectPath objectPath, boolean propagated, boolean includeClassOrigin) throws Exception {
    CIMInstance instance = null;
    try {
        if (objectPath != null && !objectPath.equals(NULL_CIM_OBJECT_PATH)) {
            _log.debug(String.format("checkExists(storage=%s, objectPath=%s, propagated=%s, includeClassOrigin=%s)", storage.getSerialNumber(), objectPath.toString(), String.valueOf(propagated), String.valueOf(includeClassOrigin)));
            instance = getInstance(storage, objectPath, propagated, includeClassOrigin, null);
        }
    } catch (WBEMException e) {
        // it's okay, we want to return null for this method
        if (e.getID() != WBEMException.CIM_ERR_NOT_FOUND) {
            throw e;
        }
    } catch (Exception e) {
        _log.error("checkExists call encountered an exception", e);
        throw e;
    }
    return instance;
}
Also used : WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Aggregations

WBEMException (javax.wbem.WBEMException)122 CIMObjectPath (javax.cim.CIMObjectPath)90 CIMInstance (javax.cim.CIMInstance)63 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 CIMArgument (javax.cim.CIMArgument)52 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)38 ArrayList (java.util.ArrayList)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)27 Volume (com.emc.storageos.db.client.model.Volume)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 WBEMClient (javax.wbem.client.WBEMClient)19 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 HashSet (java.util.HashSet)15 URI (java.net.URI)13 HashMap (java.util.HashMap)13 BlockObject (com.emc.storageos.db.client.model.BlockObject)10 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)9 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)8