use of com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest in project photon-model by vmware.
the class AWSDiskService 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);
if (request.resourceReference == null) {
op.fail(new IllegalArgumentException("Disk description cannot be empty"));
return;
}
// initialize context
AWSDiskContext ctx = new AWSDiskContext(this, request);
op.complete();
handleStages(ctx, AwsDiskStage.DISK_STATE);
}
use of com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest in project photon-model by vmware.
the class ProvisionDiskTaskService method doSubStageDiskOperation.
private void doSubStageDiskOperation(ProvisionDiskTaskState updatedState, ProvisionDiskTaskState.SubStage nextStage, DiskInstanceRequest.DiskRequestType diskRequestType) {
Operation.CompletionHandler c = (o, e) -> {
if (e != null) {
failTask(e);
return;
}
DiskInstanceRequest cr = new DiskInstanceRequest();
cr.resourceReference = createInventoryUri(this.getHost(), updatedState.diskLink);
cr.requestType = diskRequestType;
ServiceDocument subTask = o.getBody(ServiceDocument.class);
cr.taskReference = UriUtils.buildUri(this.getHost(), subTask.documentSelfLink);
cr.isMockRequest = updatedState.isMockRequest;
sendHostServiceRequest(cr, updatedState.diskAdapterReference);
};
// after setting boot order and rebooting, we want the sub
// task to patch us, the main task, to the "next" state
createSubTask(c, nextStage, updatedState);
}
use of com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest 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);
}
});
}
Aggregations