From fed4992cd5459f7af133aac77308709474405db3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 18 Aug 2016 09:53:25 +0200 Subject: [PATCH] gh-51: move EC2 context check to the last position --- base/usr/sbin/one-contextd | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/base/usr/sbin/one-contextd b/base/usr/sbin/one-contextd index 2d98e30..511fe7c 100755 --- a/base/usr/sbin/one-contextd +++ b/base/usr/sbin/one-contextd @@ -41,6 +41,16 @@ function execute_scripts { done } +function vmware_context { + if type vmtoolsd ; then + if vmtoolsd --cmd 'info-get guestinfo.opennebula.context' >/dev/null 2>&1 ; then + return 0 + fi + fi + + return 1 +} + function get_new_context { CONTEXT_DEV=`blkid -l -t LABEL="CONTEXT" -o device` if [ -e "$CONTEXT_DEV" ]; then @@ -50,11 +60,11 @@ function get_new_context { fi echo "umount /mnt" > ${END_CONTEXT} - elif curl -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data ; then - echo -n "" - elif type vmtoolsd ; then + elif vmware_context ; then vmtoolsd --cmd 'info-get guestinfo.opennebula.context' | \ openssl base64 -d > ${CONTEXT_NEW} + elif curl -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data ; then + echo -n "" fi }