Search in sources :

Example 1 with BlockConsistencyGroupUpdateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method updateConsistencyGroup.

@Override
public void updateConsistencyGroup(URI storage, URI consistencyGroup, List<URI> addVolumesList, List<URI> removeVolumesList, String task) {
    TaskCompleter completer = new BlockConsistencyGroupUpdateCompleter(consistencyGroup, task);
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
        boolean srdfCG = false;
        // check if SRDF
        if (addVolumesList != null && !addVolumesList.isEmpty()) {
            URI volumeURI = addVolumesList.get(0);
            if (URIUtil.isType(volumeURI, Volume.class)) {
                Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
                if (volume.isSRDFSource()) {
                    srdfCG = true;
                    cg.getRequestedTypes().add(Types.SRDF.name());
                    _dbClient.updateObject(cg);
                }
            }
        }
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_CONSISTENCY_GROUP_WF_NAME, false, task);
        String waitFor = null;
        // check if cg is created, if not create it
        if (!cg.created()) {
            _log.info("Consistency group not created. Creating it");
            String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, cg, null, _dbClient);
            waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Creating consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), createConsistencyGroupMethod(storage, consistencyGroup, groupName), deleteConsistencyGroupMethod(storage, consistencyGroup, groupName, false, false, true), null);
        }
        if (addVolumesList != null && !addVolumesList.isEmpty()) {
            String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, cg, null, _dbClient);
            waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Adding volumes to consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), addToConsistencyGroupMethod(storage, consistencyGroup, groupName, addVolumesList), removeFromConsistencyGroupMethod(storage, consistencyGroup, addVolumesList, false), null);
            // call ReplicaDeviceController
            waitFor = _replicaDeviceController.addStepsForAddingSessionsToCG(workflow, waitFor, consistencyGroup, addVolumesList, groupName, task);
        }
        if (removeVolumesList != null && !removeVolumesList.isEmpty()) {
            Volume volume = _dbClient.queryObject(Volume.class, removeVolumesList.get(0));
            if (volume != null && !volume.getInactive()) {
                String groupName = volume.getReplicationGroupInstance();
                // call ReplicaDeviceController
                waitFor = _replicaDeviceController.addStepsForRemovingVolumesFromCG(workflow, waitFor, consistencyGroup, removeVolumesList, task);
                waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Removing volumes from consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), removeFromConsistencyGroupMethod(storage, consistencyGroup, removeVolumesList, false), addToConsistencyGroupMethod(storage, consistencyGroup, groupName, removeVolumesList), null);
                // remove replication group if the CG will become empty
                if ((addVolumesList == null || addVolumesList.isEmpty()) && ControllerUtils.cgHasNoOtherVolume(_dbClient, consistencyGroup, removeVolumesList)) {
                    waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Deleting replication group for consistency group %s", consistencyGroup), waitFor, storage, storageSystem.getSystemType(), this.getClass(), deleteConsistencyGroupMethod(storage, consistencyGroup, groupName, false, false, true), createConsistencyGroupMethod(storage, consistencyGroup, groupName), null);
                }
            }
        }
        // add target volumes to that target consistency group.
        if (srdfCG) {
            createTargetConsistencyGroup(cg, addVolumesList, workflow, waitFor, task);
        }
        // Finish up and execute the plan.
        _log.info("Executing workflow plan {}", UPDATE_CONSISTENCY_GROUP_STEP_GROUP);
        String successMessage = String.format("Update consistency group successful for %s", consistencyGroup);
        workflow.executePlan(completer, successMessage);
    } catch (Exception e) {
        _log.error("Error updating consistency group: {}", consistencyGroup, e);
        completer.error(_dbClient, DeviceControllerException.exceptions.failedToUpdateConsistencyGroup(e.getMessage()));
    }
}
Also used : BlockConsistencyGroupUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter) Volume(com.emc.storageos.db.client.model.Volume) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 2 with BlockConsistencyGroupUpdateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method removeFromReplicationGroup.

/**
 * Orchestration method for removing members from a replication group.
 *
 * @param storage
 * @param consistencyGroup
 * @param repGroupName
 * @param addVolumesList
 * @param opId
 * @return
 * @throws ControllerException
 */
public boolean removeFromReplicationGroup(URI storage, URI consistencyGroup, String repGroupName, List<URI> addVolumesList, String opId) throws ControllerException {
    TaskCompleter taskCompleter = new BlockConsistencyGroupUpdateCompleter(consistencyGroup, opId);
    try {
        List<String> lockKeys = new ArrayList<>();
        lockKeys.add(ControllerLockingUtil.getReplicationGroupStorageKey(_dbClient, repGroupName, storage));
        WorkflowService workflowService = _blockDeviceController.getWorkflowService();
        workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        _blockDeviceController.getDevice(storageSystem.getSystemType()).doRemoveFromReplicationGroup(storageSystem, consistencyGroup, repGroupName, addVolumesList, taskCompleter);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        return false;
    }
    return true;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockConsistencyGroupUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter) WorkflowService(com.emc.storageos.workflow.WorkflowService) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with BlockConsistencyGroupUpdateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter in project coprhd-controller by CoprHD.

the class BlockStorageDeviceTest method testRemoveFromConsistencyGroup.

@Test
public void testRemoveFromConsistencyGroup() {
    URI consistencyGroupId = getConsistencyGroup().getId();
    List<Volume> volumes = getVolumes(_storageSystem);
    List<URI> blockObjects = new ArrayList<URI>();
    for (Volume volume : volumes) {
        blockObjects.add(volume.getId());
    }
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    BlockConsistencyGroupUpdateCompleter taskCompleter = new BlockConsistencyGroupUpdateCompleter(consistencyGroupId, token);
    _deviceController.doRemoveFromConsistencyGroup(_storageSystem, consistencyGroupId, blockObjects, taskCompleter);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockConsistencyGroupUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 4 with BlockConsistencyGroupUpdateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter in project coprhd-controller by CoprHD.

the class BlockStorageDeviceTest method testAddToConsistencyGroup.

@Test
public void testAddToConsistencyGroup() {
    URI consistencyGroupId = getConsistencyGroup().getId();
    List<Volume> volumes = getVolumes(_storageSystem);
    List<URI> blockObjects = new ArrayList<URI>();
    for (Volume volume : volumes) {
        blockObjects.add(volume.getId());
    }
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    BlockConsistencyGroupUpdateCompleter taskCompleter = new BlockConsistencyGroupUpdateCompleter(consistencyGroupId, token);
    _deviceController.doAddToConsistencyGroup(_storageSystem, consistencyGroupId, getConsistencyGroup().getLabel(), blockObjects, taskCompleter);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockConsistencyGroupUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 5 with BlockConsistencyGroupUpdateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method addToReplicationGroup.

/**
 * Orchestration method for adding members to a replication group.
 *
 * @param storage
 * @param consistencyGroup
 * @param replicationGroupName
 * @param addVolumesList
 * @param opId
 * @return
 * @throws ControllerException
 */
public boolean addToReplicationGroup(URI storage, URI consistencyGroup, String replicationGroupName, List<URI> addVolumesList, String opId) throws ControllerException {
    WorkflowStepCompleter.stepExecuting(opId);
    TaskCompleter taskCompleter = null;
    try {
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getReplicationGroupStorageKey(_dbClient, replicationGroupName, storage));
        WorkflowService workflowService = _blockDeviceController.getWorkflowService();
        workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        taskCompleter = new BlockConsistencyGroupUpdateCompleter(consistencyGroup, opId);
        _blockDeviceController.getDevice(storageSystem.getSystemType()).doAddToReplicationGroup(storageSystem, consistencyGroup, replicationGroupName, addVolumesList, taskCompleter);
        WorkflowStepCompleter.stepSucceded(opId);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        return false;
    }
    return true;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) WorkflowService(com.emc.storageos.workflow.WorkflowService) BlockConsistencyGroupUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

BlockConsistencyGroupUpdateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupUpdateCompleter)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 ArrayList (java.util.ArrayList)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 Volume (com.emc.storageos.db.client.model.Volume)3 URI (java.net.URI)3 WorkflowService (com.emc.storageos.workflow.WorkflowService)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 Test (org.junit.Test)2 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ApplicationTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter)1