Skip to content

Commit

Permalink
feat: adds option for virtual device expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabpain committed Nov 21, 2024
1 parent ee17ae8 commit e6fcbef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions riocli/device/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def make_hwil_labels(spec: dict, device_name: str) -> typing.Dict:
"project": data["project_id"],
"product": spec["product"],
"rapyuta_device_name": device_name,
"expiry_after": spec["expireAfter"],
}

if spec.get("highperf", False):
Expand Down
10 changes: 10 additions & 0 deletions riocli/hwil/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
type=click.Choice(["bionic", "focal", "jammy", "bullseye"]),
default="focal",
)
@click.option(
"--expire-after",
"expire_after",
help="Duration after which the device will expire",
type=str,
default="12h",
)
@click.argument("device-name", type=str)
@with_spinner(text="Creating device...")
@click.pass_context
Expand All @@ -58,6 +65,7 @@ def create_device(
arch: str,
os: str,
codename: str,
expire_after: str,
spinner: Yaspin = None,
) -> None:
"""Create a new hardware-in-the-loop device.
Expand Down Expand Up @@ -98,6 +106,8 @@ def create_device(
client = new_hwil_client()
labels = prepare_device_labels_from_context(ctx)

labels["expiry_after"] = expire_after

try:
client.create_device(device_name, arch, os, codename, labels)
spinner.text = click.style(
Expand Down
4 changes: 4 additions & 0 deletions riocli/jsonschema/schemas/device-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ definitions:
highperf:
type: boolean
default: False
expireAfter:
type: string
format: duration
default: 12h
required:
- enabled
- product
Expand Down

0 comments on commit e6fcbef

Please sign in to comment.