From c5efe3b056558d4ad24e021f7efaed7a78885cab Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Wed, 10 Feb 2021 13:08:00 -0700 Subject: [PATCH] convert device id or project from spot to on demand --- eqx-market-convert-spot | 46 +++++++++++++++++++++++++++++++++ eqx-market-convert-spot-project | 37 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 eqx-market-convert-spot create mode 100755 eqx-market-convert-spot-project diff --git a/eqx-market-convert-spot b/eqx-market-convert-spot new file mode 100755 index 0000000..550b727 --- /dev/null +++ b/eqx-market-convert-spot @@ -0,0 +1,46 @@ +#!/bin/bash +# eqx-market-convert-spot +# Convert a "spot" server into "on demand" server +# +# Usage: +# eqx-market-convert-spot [device id] +# Example: +# eqx-market-convert-spot 00000001-2000-3000-4000-500000000000 + +EQXTOKEN=`cat ~/.packet-cli.json | jq ".token" --raw-output` +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 + +EQXFACILITY=`eqx-get-deviceid-facility $EQXDEVICEID` +generate_post_data() +{ + cat </dev/null 2>/dev/null + +echo "Is spot? `eqx-market-deviceid-spot $EQXDEVICEID`" + diff --git a/eqx-market-convert-spot-project b/eqx-market-convert-spot-project new file mode 100755 index 0000000..34480db --- /dev/null +++ b/eqx-market-convert-spot-project @@ -0,0 +1,37 @@ +#!/bin/bash +# eqx-market-convert-spot-project +# Convert all the devices in a project from spot to on demand pricing. +# +# Usage: +# eqx-market-convert-spot-project [project name] +# Example: +# eqx-market-convert-spot-project fooproject + +EQXPROJECT="$1" + +if [[ $1 == "" ]] + then \ + echo -e "Need project name, such as:\n" + eqx-get-project-names + echo + exit +fi + +EQXPROJECTID=`eqx-get-project-uuid $EQXPROJECT` + +EQXDEVICEIDS=`packet \ + device \ + get \ + --json \ + --project-id \ + $EQXPROJECTID \ + 2>/dev/null \ + | jq '.[].id' | \ + sed -e 's/"//g'` + +for i in $EQXDEVICEIDS +do \ + echo "Converting $i ..." + eqx-market-convert-spot $i +done +