aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-agl-get-cost.sh
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-02-20 21:39:25 +0100
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-02-20 21:50:47 +0100
commit1933ef9d1c4f632edfb24137f9b6630a382c9d3f (patch)
tree0a3eec1a0d231c7995b09e1e4fa856d55e356e69 /jjb/common/include-agl-get-cost.sh
parentd0be42c102083fdad729685ebc41a258fc99654a (diff)
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 <jsmoeller@linuxfoundation.org> Change-Id: I7ea96ccabc76550989aa0dcb97b3806f0dd2e047
Diffstat (limited to 'jjb/common/include-agl-get-cost.sh')
-rw-r--r--jjb/common/include-agl-get-cost.sh17
1 files changed, 17 insertions, 0 deletions
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) ############"