X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fcapture-instance-metadata.sh;h=c102d53c3ee67b3f2c0c3010c1d775fd365c89e4;hb=c8b9acd166fcbd88139a65f7721e522980a0e013;hp=cb0081fd84b7653f26746c984400babc285cc9f4;hpb=033c0923b0a2aada193cf24ea7ce8725413c9d7f;p=releng%2Fglobal-jjb.git diff --git a/shell/capture-instance-metadata.sh b/shell/capture-instance-metadata.sh index cb0081fd..c102d53c 100644 --- a/shell/capture-instance-metadata.sh +++ b/shell/capture-instance-metadata.sh @@ -12,17 +12,23 @@ echo "---> capture-instance-metadata.sh" # detect if we're in EC2 -if [ -z "${NOMAD_DC}" ]; then +if [ -n "${NOMAD_DC}" ]; then echo "INFO: Running in Nomad, no metadata" 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 +# 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"