From 1933ef9d1c4f632edfb24137f9b6630a382c9d3f Mon Sep 17 00:00:00 2001 From: Jan-Simon Moeller Date: Thu, 20 Feb 2020 21:39:25 +0100 Subject: Print estimate of build job cost Retrieve the approximate cost of the build job. There is no api call for our instance flavour, so use close match. Signed-off-by: Jan-Simon Moeller Change-Id: I7ea96ccabc76550989aa0dcb97b3806f0dd2e047 --- jjb/common/include-agl-get-cost.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 jjb/common/include-agl-get-cost.sh (limited to 'jjb/common/include-agl-get-cost.sh') diff --git a/jjb/common/include-agl-get-cost.sh b/jjb/common/include-agl-get-cost.sh new file mode 100644 index 00000000..d9ca9725 --- /dev/null +++ b/jjb/common/include-agl-get-cost.sh @@ -0,0 +1,17 @@ +echo "########## Job cost (estimate) ############" + +set +e +#set -x +# Retrieve the current uptime (in seconds) +uptime=$(awk '{print $1}' /proc/uptime) +# Convert to integer by truncating fractional part' and round up by one +((uptime=${uptime%\.*}+1)) +instance_type=$(curl -s http://169.254.169.254/latest/meta-data/instance-type | sed -e "s#-iops##g") +#echo "INFO: Retrieving Pricing Info for: $instance_type" +url="https://pricing.vexxhost.net/v1/pricing/$instance_type/cost?seconds=$uptime" +#echo "url=$url" +json_block=$(curl -s "$url") +echo "$json_block" + +set -e +echo "########## Job cost (estimate) ############" -- cgit 1.2.3-korg