Commit 565d0c9f authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Make img_passwd os parameter optional

If the parameter is not defined then the ChangePassword task will not
run at all.

This resolves #34
parent 5437afa4
......@@ -153,8 +153,9 @@ if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
fi
if [ -z "$SNF_IMAGE_PASSWORD" ]; then
log_error "Password is missing"
if [ -z "${SNF_IMAGE_PASSWORD+dummy}" ]; then
warn "Task ${PROGNAME:2} will not run. Password is not set"
exit 0
fi
#trim users var
......
......@@ -133,7 +133,13 @@ get_api20_arguments() {
# Store OSP_VAR in VAR
for param in $osparams; do
eval $param=\"\$OSP_$param\"
# This is black magic. Only execute the eval command if the "param"
# variable is set. This way we can distinguish between variables
# with value "" and variables that have not been set at all
osp="OSP_$param"
if [ -n "${!osp+dummy}" ]; then
eval $param=\"\$$osp\"
fi
done
if [ -n "$CONFIG_URL" ]; then
......@@ -147,7 +153,7 @@ get_api20_arguments() {
}
parameter_check() {
local required_osparams="IMG_ID IMG_FORMAT IMG_PASSWD"
local required_osparams="IMG_ID IMG_FORMAT"
for var in $required_osparams; do
if [ -z "${!var}" ]; then
......
......@@ -180,8 +180,12 @@ floppy=$(mktemp --tmpdir floppy.XXXXXX)
add_cleanup rm "$floppy"
snf_export_TYPE="$IMG_FORMAT"
snf_export_PASSWORD="$IMG_PASSWD"
snf_export_HOSTNAME="$instance"
if [ -n "${IMG_PASSWD+dummy}" ]; then
snf_export_PASSWORD="$IMG_PASSWD"
fi
if [ -n "$IMG_PROPERTIES" ]; then
snf_export_PROPERTIES="$IMG_PROPERTIES"
fi
......
......@@ -23,8 +23,8 @@ set -e
check_required() {
local required_params="IMG_ID IMG_FORMAT IMG_PASSWD"
local osparams="$required_params IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL"
local required_params="IMG_ID IMG_FORMAT"
local osparams="$required_params IMG_PASSWD IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL"
# Store OSP_VAR in VAR
for param in $osparams; do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment