Search in sources :

Example 6 with ProvisionDiskTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState 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);
}
Also used : ProvisionDiskTaskState(com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState) Operation(com.vmware.xenon.common.Operation) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) ServiceDocument(com.vmware.xenon.common.ServiceDocument) DiskInstanceRequest(com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Utils(com.vmware.xenon.common.Utils) UriPaths(com.vmware.photon.controller.model.UriPaths) SubStage(com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState.SubStage) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) UriUtils(com.vmware.xenon.common.UriUtils) TaskState(com.vmware.xenon.common.TaskState) URI(java.net.URI) TaskService(com.vmware.xenon.services.common.TaskService) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Operation(com.vmware.xenon.common.Operation) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) DiskInstanceRequest(com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest)

Example 7 with ProvisionDiskTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState in project photon-model by vmware.

the class AzureComputeDiskDay2ServiceTest method kickOffDiskProvisioning.

private void kickOffDiskProvisioning() throws Throwable {
    // start provision task to do the actual disk creation
    ProvisionDiskTaskState provisionDiskTaskState = new ProvisionDiskTaskState();
    provisionDiskTaskState.taskSubStage = ProvisionDiskTaskState.SubStage.CREATING_DISK;
    provisionDiskTaskState.diskLink = this.diskState.documentSelfLink;
    provisionDiskTaskState.isMockRequest = this.isMock;
    provisionDiskTaskState.documentExpirationTimeMicros = Utils.getNowMicrosUtc() + TimeUnit.MINUTES.toMicros(20);
    provisionDiskTaskState.tenantLinks = this.endpointState.tenantLinks;
    provisionDiskTaskState = TestUtils.doPost(this.host, provisionDiskTaskState, ProvisionDiskTaskState.class, UriUtils.buildUri(this.host, ProvisionDiskTaskService.FACTORY_LINK));
    this.host.waitForFinishedTask(ProvisionDiskTaskState.class, provisionDiskTaskState.documentSelfLink);
}
Also used : ProvisionDiskTaskState(com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState)

Aggregations

ProvisionDiskTaskState (com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState)7 TaskState (com.vmware.xenon.common.TaskState)4 Operation (com.vmware.xenon.common.Operation)3 UriPaths (com.vmware.photon.controller.model.UriPaths)2 DiskInstanceRequest (com.vmware.photon.controller.model.adapterapi.DiskInstanceRequest)2 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)2 SubStage (com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService.ProvisionDiskTaskState.SubStage)2 PhotonModelUriUtils.createInventoryUri (com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri)2 CompletionHandler (com.vmware.xenon.common.Operation.CompletionHandler)2 ServiceDocument (com.vmware.xenon.common.ServiceDocument)2 TaskStage (com.vmware.xenon.common.TaskState.TaskStage)2 UriUtils (com.vmware.xenon.common.UriUtils)2 Utils (com.vmware.xenon.common.Utils)2 TaskService (com.vmware.xenon.services.common.TaskService)2 URI (java.net.URI)2 List (java.util.List)2 TimeUnit (java.util.concurrent.TimeUnit)2