Search in sources :

Example 16 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class VolumeIngestionUtil method setupMirrorParentRelations.

/**
 * Setup relationships between a mirror and its parent BlockObject.
 *
 * @param mirror the mirror BlockObject
 * @param parentVolume the mirror's parent BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupMirrorParentRelations(BlockObject mirror, BlockObject parent, DbClient dbClient) {
    _logger.info("Setting up relationship between mirror {} ({}) and parent {} ({})", new Object[] { mirror.getLabel(), mirror.getId(), parent.getLabel(), parent.getId() });
    ((BlockMirror) mirror).setSource(new NamedURI(parent.getId(), parent.getLabel()));
    if (parent instanceof Volume) {
        StringSet mirrors = ((Volume) parent).getMirrors();
        if (mirrors == null) {
            mirrors = new StringSet();
        }
        mirrors.add(mirror.getId().toString());
        ((Volume) parent).setMirrors(mirrors);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 17 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockDeviceController method createMirror.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMirrorMethod just above (except
 * opId).
 */
@Override
public void createMirror(URI storage, List<URI> mirrorList, Boolean isCG, Boolean createInactive, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        if (!isCG && mirrorList.size() == 1) {
            completer = new BlockMirrorCreateCompleter(mirrorList.get(0), opId);
            getDevice(storageObj.getSystemType()).doCreateMirror(storageObj, mirrorList.get(0), createInactive, completer);
        } else {
            boolean isListReplicaFlow = false;
            BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
            Volume sourceVolume = _dbClient.queryObject(Volume.class, mirrorObj.getSource().getURI());
            /**
             * VPLEX/RP CG volumes may not be having back end Array Group.
             * In this case we should create element replica using createListReplica.
             * We should not use createGroup replica as backend cg will not be available in this case.
             */
            isListReplicaFlow = isListReplicaFlow(sourceVolume);
            completer = new BlockMirrorCreateCompleter(mirrorList, opId);
            if (!isListReplicaFlow) {
                getDevice(storageObj.getSystemType()).doCreateGroupMirrors(storageObj, mirrorList, createInactive, completer);
            } else {
                // List Replica
                getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, mirrorList, createInactive, completer);
            }
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        if (completer != null) {
            completer.error(_dbClient, serviceError);
        }
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockDeviceController method pauseNativeContinuousCopies.

@Override
public void pauseNativeContinuousCopies(URI storage, List<URI> mirrors, Boolean sync, String opId) throws ControllerException {
    _log.info("START pause continuous copies workflow");
    boolean isCG = isCGMirror(mirrors.get(0), _dbClient);
    if (mirrors.size() == 1 || isCG) {
        fractureMirror(storage, mirrors, isCG, sync, opId);
        return;
    }
    Workflow workflow = _workflowService.getNewWorkflow(this, PAUSE_MIRRORS_WF_NAME, false, opId);
    TaskCompleter taskCompleter = null;
    BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrors.get(0));
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    try {
        for (URI mirrorUri : mirrors) {
            BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, mirrorUri);
            if (!mirrorIsPausable(asList(blockMirror))) {
                String errorMsg = format("Can not pause continuous copy %s with synchronization state %s for volume %s", blockMirror.getId(), blockMirror.getSyncState(), blockMirror.getSource().getURI());
                _log.error(errorMsg);
                String opName = ResourceOperationTypeEnum.PAUSE_NATIVE_CONTINUOUS_COPIES.getName();
                ServiceError serviceError = DeviceControllerException.errors.jobFailedOp(opName);
                WorkflowStepCompleter.stepFailed(opId, serviceError);
                throw new IllegalStateException(errorMsg);
            }
            workflow.createStep("pauseMirror", "pause mirror", null, storage, storageObj.getSystemType(), this.getClass(), fractureMirrorMethod(storage, asList(mirrorUri), isCG, sync), null, null);
        }
        taskCompleter = new BlockMirrorTaskCompleter(Volume.class, asList(mirror.getSource().getURI()), opId);
        workflow.executePlan(taskCompleter, "Successfully paused continuous copies");
    } catch (Exception e) {
        String msg = String.format("Failed to execute pause continuous copies workflow for volume %s", mirror.getSource().getURI());
        _log.error(msg, e);
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            taskCompleter.error(_dbClient, serviceError);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockDeviceController method isCGMirror.

private boolean isCGMirror(URI mirrorURI, DbClient dbClient) {
    BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorURI);
    Volume sourceVolume = dbClient.queryObject(Volume.class, mirror.getSource());
    return sourceVolume.isInCG();
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume)

Example 20 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockDeviceController method addStepsForPromoteMirrors.

/**
 * Adds the additional steps necessary to promote mirrors to regular block volumes
 *
 * @param workflow
 * @param waitFor
 * @param descriptors
 * @param promotees
 * @return
 * @throws ControllerException
 */
public String addStepsForPromoteMirrors(Workflow workflow, String waitFor, List<URI> mirrorList, List<URI> promotees) throws ControllerException {
    boolean isCG = isCGMirror(mirrorList.get(0), _dbClient);
    List<Volume> promotedVolumes = _dbClient.queryObject(Volume.class, promotees);
    if (!isCG) {
        List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        for (BlockMirror mirror : mirrors) {
            URI controller = mirror.getStorageController();
            // Add steps for detaching the mirror
            String stepId = addStepsForDetachMirror(workflow, waitFor, PROMOTE_MIRROR_STEP_GROUP, mirrorList, isCG);
            // Find the volume this mirror will be promoted to
            URI promotedVolumeForMirror = findPromotedVolumeForMirror(mirror.getId(), promotedVolumes);
            // Create a step for promoting the mirror.
            stepId = workflow.createStep(PROMOTE_MIRROR_STEP_GROUP, String.format("Promote mirror: %s", mirror.getId()), stepId, controller, getDeviceType(controller), this.getClass(), promoteMirrorMethod(asList(mirror.getId()), asList(promotedVolumeForMirror), isCG), null, null);
        }
    } else {
        BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
        URI controller = mirror.getStorageController();
        // Add steps for detaching the mirror
        String stepId = addStepsForDetachMirror(workflow, waitFor, PROMOTE_MIRROR_STEP_GROUP, mirrorList, isCG);
        // Find the volumes this set of mirrors will be promoted to
        List<URI> promotedVolumesForMirrors = findPromotedVolumesForMirrors(mirrorList, promotedVolumes);
        // Create a step for promoting the mirrors.
        stepId = workflow.createStep(PROMOTE_MIRROR_STEP_GROUP, String.format("Promote mirrors: %s", Joiner.on("\t").join(mirrorList)), stepId, controller, getDeviceType(controller), this.getClass(), promoteMirrorMethod(mirrorList, promotedVolumesForMirrors, isCG), null, null);
    }
    return PROMOTE_MIRROR_STEP_GROUP;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9