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 +