From 75dc7d45eac638d3c4846f35f05a0b3390520ac1 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Wed, 10 Feb 2021 12:28:17 -0700 Subject: [PATCH] scriptlet to see if device id is spot price or not --- eqx-get-deviceid-spot | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 eqx-get-deviceid-spot diff --git a/eqx-get-deviceid-spot b/eqx-get-deviceid-spot new file mode 100755 index 0000000..1d9015c --- /dev/null +++ b/eqx-get-deviceid-spot @@ -0,0 +1,26 @@ +#!/bin/bash +# eqx-get-deviceid-spot +# +# Give a device ID, check if it is spot or not. +# null = not spot +# true = spot + +EQXDEVICEID="$1" + +if [[ $1 == "" ]] + then \ + echo -e "Need device ID" + echo -e "To get device IDs in a project, run:" + echo -e "eqx-get-project-devices [project name]" + echo + exit +fi + +packet \ + device get \ + --json \ + --id $EQXDEVICEID \ + 2>/dev/null | \ + jq '.spot_instance' | \ + sed -e 's/"//g' +