From e6fcbef0cd34fa20bf7d554d7a035b41d998ec28 Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Thu, 21 Nov 2024 22:11:18 +0530 Subject: [PATCH] feat: adds option for virtual device expiry --- riocli/device/util.py | 1 + riocli/hwil/create.py | 10 ++++++++++ riocli/jsonschema/schemas/device-schema.yaml | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/riocli/device/util.py b/riocli/device/util.py index 172447e8..70e4f2be 100644 --- a/riocli/device/util.py +++ b/riocli/device/util.py @@ -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): diff --git a/riocli/hwil/create.py b/riocli/hwil/create.py index ab369862..0fa7bcf5 100644 --- a/riocli/hwil/create.py +++ b/riocli/hwil/create.py @@ -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 @@ -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. @@ -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( diff --git a/riocli/jsonschema/schemas/device-schema.yaml b/riocli/jsonschema/schemas/device-schema.yaml index dee79ade..45f9433a 100644 --- a/riocli/jsonschema/schemas/device-schema.yaml +++ b/riocli/jsonschema/schemas/device-schema.yaml @@ -100,6 +100,10 @@ definitions: highperf: type: boolean default: False + expireAfter: + type: string + format: duration + default: 12h required: - enabled - product