From 4d88c6cfde3ae977704e6b9a8a770c3dac2edd7f Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Fri, 24 Jan 2014 17:03:44 +0200 Subject: [PATCH] Fix bug in import/export regarding some API params Fix a bug where API params like CONFIG_URL or IMG_PASSWORD where checked and used by scripts other that `create' (e.g. `import' and `export'). This may lead to errors. The CONFIG_URL may not be valid after the image creation --- snf-image-host/common.sh.in | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/snf-image-host/common.sh.in b/snf-image-host/common.sh.in index a2dc933..a16c8c7 100644 --- a/snf-image-host/common.sh.in +++ b/snf-image-host/common.sh.in @@ -162,28 +162,30 @@ get_api10_arguments() { get_api20_arguments() { get_api10_arguments - local required_osparams="IMG_ID IMG_FORMAT IMG_PASSWD" - local osparams="$required_osparams IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL" + if [ "$SCRIPT_NAME" = "create" ]; then + local required_osparams="IMG_ID IMG_FORMAT IMG_PASSWD" + local osparams="$required_osparams IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL" - # Store OSP_VAR in VAR - for param in $osparams; do - eval $param=\"\$OSP_$param\" - done - - if [ -n "$CONFIG_URL" ]; then - local config config_params - echo "Downloading configuration parameters from: \`$CONFIG_URL'" >&2 - config=$($CURL -f "$CONFIG_URL") - config_params=$(./decode-config.py $osparams <<< "$config") - eval "$config_params" - fi + # Store OSP_VAR in VAR + for param in $osparams; do + eval $param=\"\$OSP_$param\" + done - for var in $required_osparams; do - if [ -z "${!var}" ]; then - log_error "Missing OS API Parameter: ${var}" - exit 1 + if [ -n "$CONFIG_URL" ]; then + local config config_params + echo "Downloading configuration parameters from: \`$CONFIG_URL'" >&2 + config=$($CURL -f "$CONFIG_URL") + config_params=$(./decode-config.py $osparams <<< "$config") + eval "$config_params" fi - done + + for var in $required_osparams; do + if [ -z "${!var}" ]; then + log_error "Missing OS API Parameter: ${var}" + exit 1 + fi + done + fi } map_disk0() { -- 1.7.10.4