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()));
}
}
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;
}
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);
}
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);
}
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;
}
Aggregations