use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class VMAX3BlockSnapshotSessionApiImpl method deleteSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void deleteSnapshotSession(BlockSnapshotSession snapSession, BlockObject snapSessionSourceObj, String taskId, String deleteType) {
if (VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deleteType)) {
// Update the task status for the session.
// Note that we must get the session form the database to get the latest status map.
BlockSnapshotSession updatedSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSession.getId());
Operation op = updatedSession.getOpStatus().get(taskId);
op.ready("Snapshot session succesfully deleted from ViPR");
updatedSession.getOpStatus().updateTaskStatus(taskId, op);
_dbClient.updateObject(updatedSession);
// Mark the snapshot session for deletion.
_dbClient.markForDeletion(updatedSession);
} else {
// Invoke the BlockDeviceController to delete the snapshot session.
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
controller.deleteSnapshotSession(storageSystem.getId(), snapSession.getId(), taskId);
}
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class BlockServiceUtils method createFailedTaskOnCG.
/**
* Creates a Task on given CG with Error state
*
* @param opr the opr
* @param cg the consistency group
* @param sc the sc
* @return the failed task for cg
*/
public static TaskResourceRep createFailedTaskOnCG(DbClient dbClient, BlockConsistencyGroup cg, ResourceOperationTypeEnum opr, ServiceCoded sc) {
String taskId = UUID.randomUUID().toString();
Operation op = new Operation();
op.setResourceType(opr);
dbClient.createTaskOpStatus(BlockConsistencyGroup.class, cg.getId(), taskId, op);
cg = dbClient.queryObject(BlockConsistencyGroup.class, cg.getId());
op = cg.getOpStatus().get(taskId);
op.error(sc);
cg.getOpStatus().updateTaskStatus(taskId, op);
dbClient.updateObject(cg);
return TaskMapper.toTask(cg, taskId, op);
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class BlockServiceUtils method createFailedTaskOnVolume.
/**
* Creates a Task on given Volume with Error state
*
* @param opr the opr
* @param volume the volume
* @param sc the sc
* @return the failed task for volume
*/
public static TaskResourceRep createFailedTaskOnVolume(DbClient dbClient, Volume volume, ResourceOperationTypeEnum opr, ServiceCoded sc) {
String taskId = UUID.randomUUID().toString();
Operation op = new Operation();
op.setResourceType(opr);
dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, op);
volume = dbClient.queryObject(Volume.class, volume.getId());
op = volume.getOpStatus().get(taskId);
op.error(sc);
volume.getOpStatus().updateTaskStatus(taskId, op);
dbClient.updateObject(volume);
return TaskMapper.toTask(volume, taskId, op);
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class DiscoveredObjectTaskScheduler method scheduleAsyncTasks.
public TaskList scheduleAsyncTasks(List<AsyncTask> tasks) {
TaskList list = new TaskList();
for (AsyncTask task : tasks) {
if (task instanceof ArrayAffinityAsyncTask) {
List<URI> systemIds = ((ArrayAffinityAsyncTask) task).getSystemIds();
for (URI uri : systemIds) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, uri);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, uri, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
} else {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, task._id, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
try {
_taskExecutor.executeTasks(tasks.toArray(new AsyncTask[tasks.size()]));
} catch (ControllerException | APIException ex) {
for (AsyncTask task : tasks) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = _dbClient.error(task._clazz, task._id, task._opId, ex);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
return list;
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class VolumeService method createTaskList.
private TaskList createTaskList(long size, Project project, VirtualArray varray, VirtualPool vpool, String label, String task, Integer volumeCount) {
TaskList taskList = new TaskList();
// long lsize = SizeUtil.translateSize(size);
for (int i = 0; i < volumeCount; i++) {
Volume volume = StorageScheduler.prepareEmptyVolume(_dbClient, size, project, varray, vpool, label, i, volumeCount);
Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
volume.getOpStatus().put(task, op);
TaskResourceRep volumeTask = toTask(volume, task, op);
taskList.getTaskList().add(volumeTask);
_log.info(String.format("Volume and Task Pre-creation Objects [Init]-- Source Volume: %s, Task: %s, Op: %s", volume.getId(), volumeTask.getId(), task));
}
return taskList;
}
Aggregations