prices, ipxe

master
root 4 years ago
parent 51bf754234
commit 11a6eafe60

@ -16,13 +16,16 @@
#set -x #set -x
# Set static variables here # Set static variables here
EQXSPOTMAX="0.18"
EQXFACILITY="da11" EQXFACILITY="da11"
EQXOS="debian_10" EQXOS="debian_10"
EQXPLAN="c3.small.x86" EQXPLAN="c3.small.x86"
EQXTAGS="cluster" EQXTAGS="cluster"
EQXSPOTOVER=".02"
# Probably leave these variables alone # Probably leave these variables alone
# Set max price at current spot plus EQXSPOTOVER from above
EQXSPOT="`eqx-market-spot-prices`"
EQXSPOTMAX=`echo "$EQXSPOT + $EQXSPOTOVER" | bc -l | xargs printf "%1.2f"`
EQXPROJECT="$1" EQXPROJECT="$1"
if [[ $1 == "" ]] if [[ $1 == "" ]]
then EQXPROJECT=`eqx-create-project` then EQXPROJECT=`eqx-create-project`
@ -32,6 +35,7 @@ fi
EQXHOSTNAME=`dd bs=12 count=1 if=/dev/random 2>/dev/null | base64 | tr [:upper:] [:lower:] | tr -dc [:alpha:]` EQXHOSTNAME=`dd bs=12 count=1 if=/dev/random 2>/dev/null | base64 | tr [:upper:] [:lower:] | tr -dc [:alpha:]`
EQXPROJECTID=`eqx-get-project-uuid $EQXPROJECT` EQXPROJECTID=`eqx-get-project-uuid $EQXPROJECT`
echo "Spot: $EQXSPOT"
echo "Spot Max: $EQXSPOTMAX" echo "Spot Max: $EQXSPOTMAX"
echo "Project: $EQXPROJECT" echo "Project: $EQXPROJECT"
echo "ProjectID: $EQXPROJECTID" echo "ProjectID: $EQXPROJECTID"
@ -41,7 +45,6 @@ echo "Hostname: $EQXHOSTNAME"
echo "OS: $EQXOS" echo "OS: $EQXOS"
echo "Tag: $EQXTAGS" echo "Tag: $EQXTAGS"
#cat >> tmpfoo <<EOF
packet device create \ packet device create \
--plan "$EQXPLAN" \ --plan "$EQXPLAN" \
--spot-instance \ --spot-instance \
@ -51,7 +54,6 @@ packet device create \
--hostname "$EQXHOSTNAME" \ --hostname "$EQXHOSTNAME" \
--operating-system "$EQXOS" \ --operating-system "$EQXOS" \
--tags "$EQXTAGS" --tags "$EQXTAGS"
#EOF
exit exit
-c, --customdata string Custom data -c, --customdata string Custom data

@ -0,0 +1,13 @@
#!/bin/bash
# eqx-market-spot-prices
EQXTOKEN=`cat ~/.packet-cli.json | jq ".token" --raw-output`
curl \
--silent \
-X GET \
--header 'Accept: application/json' \
--header "X-Auth-Token: ${EQXTOKEN}" \
'https://api.equinix.com/metal/v1/market/spot/prices' | \
jq '.spot_market_prices.da11."c3.small.x86".price'

@ -0,0 +1,6 @@
#!ipxe
kernel https://boot.netboot.xyz/memdisk iso raw
initrd https://gemmei.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso
boot
Loading…
Cancel
Save