Search in sources :

Example 96 with Operation

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);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockController(com.emc.storageos.volumecontroller.BlockController) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 97 with Operation

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);
}
Also used : Operation(com.emc.storageos.db.client.model.Operation) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 98 with Operation

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);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Operation(com.emc.storageos.db.client.model.Operation)

Example 99 with Operation

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;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ControllerException(com.emc.storageos.volumecontroller.ControllerException) TaskList(com.emc.storageos.model.TaskList) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI)

Example 100 with Operation

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;
}
Also used : CinderVolume(com.emc.storageos.cinder.model.CinderVolume) Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Aggregations

Operation (com.emc.storageos.db.client.model.Operation)272 URI (java.net.URI)114 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)105 Path (javax.ws.rs.Path)105 Produces (javax.ws.rs.Produces)103 Volume (com.emc.storageos.db.client.model.Volume)93 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)92 ArrayList (java.util.ArrayList)83 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)70 Consumes (javax.ws.rs.Consumes)70 NamedURI (com.emc.storageos.db.client.model.NamedURI)68 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)68 POST (javax.ws.rs.POST)67 TaskList (com.emc.storageos.model.TaskList)59 FileShare (com.emc.storageos.db.client.model.FileShare)56 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)49 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)40 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)36 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)35 ControllerException (com.emc.storageos.volumecontroller.ControllerException)35