Skip to content

Commit

Permalink
feat: adds option for virtual device expiry (#387)
Browse files Browse the repository at this point in the history
Fixes AB#39668
  • Loading branch information
pallabpain authored Nov 22, 2024
1 parent ee17ae8 commit b10301a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions riocli/apply/manifests/device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ spec:
codename: "focal" # Options: ["bionic", "focal" (default), "jammy", "bullseye"]
highperf: False # Optional [True, False (default)]
wait: True # Optional [True, False (default)] Wait until the device is ready.
expireAfter: '12h' # Optional ["s", "m", "h", "d"] Expire after set duration.
docker:
enabled: True # Required
rosbagMountPath: "/opt/rapyuta/volumes/rosbag"
Expand Down
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
18 changes: 14 additions & 4 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. Example: 12h, 1d, 600s, 10m",
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 All @@ -78,11 +86,11 @@ def create_device(
Create a new device with the name 'my-device' and the default
$ rio hwil create my-device
$ rio hwil create my-device
Create a new device with the name 'my-device' and custom
parameters for example, arm64 architecture, debian OS and
bullseye codename.
Create a new device with the name 'my-device' and custom
parameters for example, arm64 architecture, debian OS and
bullseye codename.
$ rio hwil create my-device --arch arm64 --os debian --codename bullseye
Expand All @@ -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 b10301a

Please sign in to comment.