Code Review
/
releng
/
global-jjb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Skip Metadata Capture on unsupported Clouds
[releng/global-jjb.git]
/
shell
/
capture-instance-metadata.sh
diff --git
a/shell/capture-instance-metadata.sh
b/shell/capture-instance-metadata.sh
index
23a9f2b
..
c102d53
100644
(file)
--- a/
shell/capture-instance-metadata.sh
+++ b/
shell/capture-instance-metadata.sh
@@
-17,12
+17,18
@@
if [ -n "${NOMAD_DC}" ]; then
exit 0
fi
exit 0
fi
-# detect if we're in AWS
-if grep -qi amazon /sys/devices/virtual/dmi/id/bios_vendor ; then
- echo "INFO: Running in AWS, not capturing instance metadata"
+if [[ ! -f /run/cloud-init/result.json ]]; then
+ echo "INFO: Running in unsupported cloud, no metadata"
exit 0
fi
exit 0
fi
+# AWS not supported, exit
+cloudtype="$(jq -r .v1.datasource /run/cloud-init/result.json)"
+if [[ $cloudtype == "DataSourceEc2Local" ]]; then
+ echo "INFO: Running in AWS, not capturing instance metadata"
+ exit 0
+fi
+
# Retrive OpenStack instace metadata APIs at this IP.
# The instance id and other metadata is useful for debugging VM.
echo "INFO: Running in OpenStack, capturing instance metadata"
# Retrive OpenStack instace metadata APIs at this IP.
# The instance id and other metadata is useful for debugging VM.
echo "INFO: Running in OpenStack, capturing instance metadata"