Skip to content

Commit ebe5d42

Browse files
committed
docs(grpc): document the LoadImage RPC
1 parent b8471fb commit ebe5d42

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

docs/grpc.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,31 @@ from hyper.grpc.v0 import hyper_pb2, hyper_pb2_grpc
5151
client = hyper_pb2_grpc.HyperStub(grpc.aio.insecure_channel("localhost:50051"))
5252
```
5353

54+
### Loading Images
55+
56+
Before you can create a VM you need an image in the cluster. `LoadImage` pulls an
57+
OCI image, builds its rootfs, and records it -- returning the `img_id` you pass to
58+
`CreateVm`. It blocks until the load finishes (this can take minutes), so set a
59+
generous deadline.
60+
61+
```python
62+
loaded = await client.LoadImage(
63+
hyper_pb2.LoadImageRequest(
64+
image_ref="docker.io/library/alpine:3.19",
65+
# label is optional; defaults to image_ref.
66+
)
67+
)
68+
print(loaded.img_id) # pass this to CreateVm
69+
```
70+
5471
### Creating VMs
5572

5673
You can create new VMs with the `CreateVm` RPC.
5774

5875
```python
5976
created = await client.CreateVm(
6077
hyper_pb2.CreateVmRequest(
61-
img_id="img-abc",
78+
img_id=loaded.img_id,
6279
instance_type=hyper_pb2.INSTANCE_TYPE_DECI,
6380
arch=hyper_pb2.ARCHITECTURE_X86_64,
6481
# boot_args is optional; omit it for the default kernel cmdline.

0 commit comments

Comments
 (0)