Search in sources :

Example 46 with ServiceDocument

use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.

the class ProvisionComputeTaskService method doSubStageCreateHost.

private void doSubStageCreateHost(ProvisionComputeTaskState updatedState, ProvisionComputeTaskState.SubStage nextStage) {
    CompletionHandler c = (o, e) -> {
        if (e != null) {
            failTask(e);
            return;
        }
        ComputeInstanceRequest cr = new ComputeInstanceRequest();
        cr.resourceReference = createInventoryUri(this.getHost(), updatedState.computeLink);
        cr.endpointLinkReference = createInventoryUri(this.getHost(), updatedState.endpointLink);
        cr.requestType = InstanceRequestType.CREATE;
        // the first reboot needs to be from the network, and the bare metal
        // services
        // will provide the image reference (retrieved from the computeReference)
        ServiceDocument subTask = o.getBody(ServiceDocument.class);
        cr.taskReference = UriUtils.buildUri(this.getHost(), subTask.documentSelfLink);
        cr.isMockRequest = updatedState.isMockRequest;
        sendHostServiceRequest(cr, updatedState.instanceAdapterReference);
    };
    // 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 : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ComputeBootRequest(com.vmware.photon.controller.model.adapterapi.ComputeBootRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) Operation(com.vmware.xenon.common.Operation) ServiceDocument(com.vmware.xenon.common.ServiceDocument) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest.InstanceRequestType) BootDevice(com.vmware.photon.controller.model.resources.ComputeService.BootDevice) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) ComputeInstanceRequest(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Utils(com.vmware.xenon.common.Utils) UriPaths(com.vmware.photon.controller.model.UriPaths) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) InetAddressValidator(org.apache.commons.validator.routines.InetAddressValidator) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) 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) SubStage(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage) ComputeInstanceRequest(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) ServiceDocument(com.vmware.xenon.common.ServiceDocument)

Example 47 with ServiceDocument

use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.

the class TestUtils method doPatch.

/**
 * Generic doPatch.
 *
 * @param host VerificationHost
 * @param state Body to PATCH
 * @param type Body type to return
 * @param uri URI to post to
 * @param <T> type
 * @return State of service after PATCH
 * @throws Throwable
 */
public static <T extends ServiceDocument, B extends ServiceDocument> B doPatch(VerificationHost host, T state, Class<B> type, URI uri) throws Throwable {
    final ServiceDocument[] doc = { null };
    host.testStart(1);
    Operation patch = Operation.createPatch(uri).setBody(state).setCompletion((o, e) -> {
        if (e != null) {
            host.failIteration(e);
            return;
        }
        doc[0] = o.getBody(ServiceDocument.class);
        host.completeIteration();
    });
    host.send(patch);
    host.testWait();
    host.logThroughput();
    B outState = host.getServiceState(null, type, UriUtils.buildUri(uri.getHost(), uri.getPort(), doc[0].documentSelfLink, null));
    return outState;
}
Also used : ServiceDocument(com.vmware.xenon.common.ServiceDocument) Operation(com.vmware.xenon.common.Operation)

Aggregations

ServiceDocument (com.vmware.xenon.common.ServiceDocument)47 Operation (com.vmware.xenon.common.Operation)11 URI (java.net.URI)6 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)5 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)5 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)5 EndpointAllocationTaskState (com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState)5 PhotonModelUriUtils.createInventoryUri (com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri)5 CompletionHandler (com.vmware.xenon.common.Operation.CompletionHandler)5 UriUtils (com.vmware.xenon.common.UriUtils)5 List (java.util.List)5 UriPaths (com.vmware.photon.controller.model.UriPaths)4 ServiceTypeCluster (com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster)4 TaskState (com.vmware.xenon.common.TaskState)4 TaskStage (com.vmware.xenon.common.TaskState.TaskStage)4 Utils (com.vmware.xenon.common.Utils)4 TaskService (com.vmware.xenon.services.common.TaskService)4 TimeUnit (java.util.concurrent.TimeUnit)4 ComputeDescriptionService (com.vmware.photon.controller.model.resources.ComputeDescriptionService)3 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)3