use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method updateApplication.
/**
* Adding/removing volumes to/from an application is ViPR DB only operation (no controller side involved),
* except for adding VNX volumes to an application, if the VNX volumes are in a real replication group.
*
* 1. remove volumes from replication group, keep volume's replicationGroupInstance unchanged
* 2. delete the replication group from array, keep CG's systemConsistencyGroup unchanged
* 3. change CG's arrayConsistency to false, update volume's volumeGroupIds, update clone's fullCopySetName
* (performed in the completer class)
*/
@Override
public void updateApplication(URI storage, ApplicationAddVolumeList addVolList, URI application, String opId) throws ControllerException {
TaskCompleter completer = null;
String waitFor = null;
try {
// Generate the Workflow.
Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_VOLUMES_FOR_APPLICATION_WS_NAME, false, opId);
List<URI> volumesToAdd = null;
if (addVolList != null) {
volumesToAdd = addVolList.getVolumes();
}
if (volumesToAdd != null && !volumesToAdd.isEmpty()) {
Map<URI, List<URI>> addVolsMap = new HashMap<URI, List<URI>>();
for (URI voluri : volumesToAdd) {
Volume vol = _dbClient.queryObject(Volume.class, voluri);
if (vol != null && !vol.getInactive()) {
if (ControllerUtils.isVnxVolume(vol, _dbClient) && vol.isInCG() && !ControllerUtils.isNotInRealVNXRG(vol, _dbClient)) {
URI cguri = vol.getConsistencyGroup();
List<URI> vols = addVolsMap.get(cguri);
if (vols == null) {
vols = new ArrayList<URI>();
}
vols.add(voluri);
addVolsMap.put(cguri, vols);
}
}
}
List<URI> cgs = new ArrayList<URI>(addVolsMap.keySet());
completer = new ApplicationTaskCompleter(application, volumesToAdd, null, cgs, opId);
for (Map.Entry<URI, List<URI>> entry : addVolsMap.entrySet()) {
_log.info("Creating workflows for adding CG volumes to application");
URI cguri = entry.getKey();
List<URI> cgVolsToAdd = entry.getValue();
URI voluri = cgVolsToAdd.get(0);
Volume vol = _dbClient.queryObject(Volume.class, voluri);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, vol.getStorageController());
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cguri);
String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, cguri, vol.getReplicationGroupInstance(), _dbClient);
// remove volumes from array replication group, and delete the group, but keep volumes reference
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Removing volumes from consistency group %s", cg.getLabel()), waitFor, storage, storageSystem.getSystemType(), this.getClass(), removeFromConsistencyGroupMethod(storage, cguri, cgVolsToAdd, true), rollbackMethodNullMethod(), null);
// remove replication group
waitFor = workflow.createStep(UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Deleting replication group for consistency group %s", cg.getLabel()), waitFor, storage, storageSystem.getSystemType(), this.getClass(), deleteConsistencyGroupMethod(storage, cguri, groupName, true, false, false), rollbackMethodNullMethod(), null);
}
}
// Finish up and execute the plan.
_log.info("Executing workflow plan {}", UPDATE_VOLUMES_FOR_APPLICATION_WS_NAME);
String successMessage = String.format("Update application successful for %s", application.toString());
workflow.executePlan(completer, successMessage);
} catch (Exception e) {
_log.error("Exception while updating the application", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.exceptions.failedToUpdateVolumesFromAppication(application.toString(), e.getMessage()));
}
}
}
Aggregations