Search in sources :

Example 21 with TaskManager

use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.

the class VSphereDiskService method handlePatch.

@Override
public void handlePatch(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    DiskInstanceRequest request = op.getBody(DiskInstanceRequest.class);
    try {
        validateInputRequest(request);
    } catch (Exception e) {
        op.fail(e);
        return;
    }
    op.setStatusCode(Operation.STATUS_CODE_CREATED);
    op.complete();
    TaskManager taskManager = new TaskManager(this, request.taskReference, request.resourceLink());
    DiskContext.populateContextThen(this, createInitialContext(taskManager, request, op), ctx -> {
        switch(request.requestType) {
            case CREATE:
                handleCreateDisk(ctx);
                break;
            case DELETE:
                handleDeleteDisk(ctx);
                break;
            default:
                Throwable error = new IllegalStateException("Unsupported requestType " + request.requestType);
                ctx.fail(error);
        }
    });
}
Also used : TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) DiskInstanceRequest(com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest)

Aggregations

TaskManager (com.vmware.photon.controller.model.adapters.util.TaskManager)21 StatelessService (com.vmware.xenon.common.StatelessService)9 DeferredResult (com.vmware.xenon.common.DeferredResult)8 List (java.util.List)8 ComputeStatsRequest (com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest)7 Operation (com.vmware.xenon.common.Operation)7 URI (java.net.URI)7 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)6 ArrayList (java.util.ArrayList)6 Connection (com.vmware.photon.controller.model.adapters.vsphere.util.connection.Connection)4 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)4 ComputeStateWithDescription (com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription)4 PhotonModelUriUtils (com.vmware.photon.controller.model.util.PhotonModelUriUtils)4 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)4 TaskStage (com.vmware.xenon.common.TaskState.TaskStage)4 QueryTask (com.vmware.xenon.services.common.QueryTask)4 ComputeProperties (com.vmware.photon.controller.model.ComputeProperties)3 DatacenterLister (com.vmware.photon.controller.model.adapters.vsphere.util.finders.DatacenterLister)3 Element (com.vmware.photon.controller.model.adapters.vsphere.util.finders.Element)3 RpcException (com.vmware.photon.controller.model.adapters.vsphere.vapi.RpcException)3