120 lines
4.5 KiB
YAML
120 lines
4.5 KiB
YAML
parameters:
|
|
- $ref: ../components/parameters.yml#/LabId
|
|
put:
|
|
operationId: CreateLab
|
|
summary: Create a lab from a template and a variant seed.
|
|
description: |-
|
|
Idempotent by `lab_id`:
|
|
|
|
- a new ID that fits the capacity reserves it, stores the lab, and answers 202 with `state: provisioning`; the nodes are cloned and booted in the background;
|
|
- the same ID with the same payload answers 200 with the current state of that lab, including `deleted` or `failed`, and never creates a second one;
|
|
- the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing;
|
|
- a new ID that does not fit the memory budget or the lab limit, or arrives while the provisioner is draining, answers 503 `lab_pool_busy` with Retry-After; nothing is stored, so the caller retries with the same ID.
|
|
|
|
Payloads are compared by a SHA-256 fingerprint of the decoded request.
|
|
An unknown template or template version, or a lifetime above the
|
|
configured maximum, answers 400 `validation_failed` with a pointer such
|
|
as `/template_id` or `/ttl_seconds`.
|
|
|
|
The lab is deleted at `expires_at` = creation time + `ttl_seconds`, also
|
|
when it is still provisioning. A lab that fails to provision or does not
|
|
answer within the provisioning timeout becomes `failed` and its
|
|
resources are deleted; its capacity returns when they are gone.
|
|
|
|
A record of a deleted or failed lab is kept for a bounded retention time;
|
|
after it, the ID is unknown again and a CreateLab with it starts a new
|
|
lab.
|
|
tags:
|
|
- labs
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabCreateRequest
|
|
examples:
|
|
two_routers:
|
|
summary: A lab of a networking template for one attempt item
|
|
value:
|
|
template_id: mikrotik-ospf-pair
|
|
template_version: 1
|
|
seed: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
|
ttl_seconds: 3600
|
|
responses:
|
|
"200":
|
|
description: A lab with this ID and the same payload already exists.
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabStatus
|
|
"202":
|
|
description: The lab was accepted and is provisioning.
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabStatus
|
|
examples:
|
|
provisioning:
|
|
summary: A lab that is being cloned and booted
|
|
value:
|
|
lab_id: 2f1c7a52-0d3e-4b8e-9b61-3c7b1f2e9a40
|
|
state: provisioning
|
|
template_id: mikrotik-ospf-pair
|
|
template_version: 1
|
|
created_at: "2026-10-11T09:00:00Z"
|
|
expires_at: "2026-10-11T10:00:00Z"
|
|
nodes:
|
|
- name: r1
|
|
kind: mikrotik
|
|
- name: r2
|
|
kind: mikrotik
|
|
"503":
|
|
$ref: ../components/responses.yml#/LabPoolBusy
|
|
default:
|
|
$ref: ../components/responses.yml#/Problem
|
|
get:
|
|
operationId: GetLab
|
|
summary: Read the state of a lab.
|
|
description: >-
|
|
Answers 404 `not_found` for an ID the provisioner does not hold,
|
|
including a lab whose `deleted` record outlived its retention time. The
|
|
response never contains an address, a key, or an LXD object name.
|
|
tags:
|
|
- labs
|
|
responses:
|
|
"200":
|
|
description: The current state of the lab.
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabStatus
|
|
default:
|
|
$ref: ../components/responses.yml#/Problem
|
|
delete:
|
|
operationId: DeleteLab
|
|
summary: Delete a lab before its timer.
|
|
description: >-
|
|
Marks the lab for deletion and answers 202 with `state: deleting`; the
|
|
provisioner removes its instances and bridges in the background and
|
|
retries until LXD confirms that they are gone, also across its own
|
|
restarts. Deleting a lab that is already `deleting` or `deleted`
|
|
answers 200 with its state and changes nothing. An unknown ID answers
|
|
404 `not_found`.
|
|
tags:
|
|
- labs
|
|
responses:
|
|
"200":
|
|
description: The lab was already being deleted or is deleted.
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabStatus
|
|
"202":
|
|
description: The lab is being deleted.
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas.yml#/LabStatus
|
|
default:
|
|
$ref: ../components/responses.yml#/Problem
|