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);
}
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;
}
Aggregations