Commit dbdad4b0 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Give priority to command line os parameters

OS Parameters defined as command-line arguments should overwrite the
ones given in the variants file.

Many thanks to Brian Candler https://github.com/candlerb for the
suggestion and all the help.
parent 8a88d02d
...@@ -130,6 +130,7 @@ get_api20_arguments() { ...@@ -130,6 +130,7 @@ get_api20_arguments() {
if [ "$SCRIPT_NAME" = "create" ]; then if [ "$SCRIPT_NAME" = "create" ]; then
local osparams="IMG_ID IMG_FORMAT IMG_PASSWD IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL" local osparams="IMG_ID IMG_FORMAT IMG_PASSWD IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL"
local osp
# Store OSP_VAR in VAR # Store OSP_VAR in VAR
for param in $osparams; do for param in $osparams; do
...@@ -270,8 +271,8 @@ ganeti_os_main() { ...@@ -270,8 +271,8 @@ ganeti_os_main() {
exit 1 exit 1
fi fi
get_api20_arguments
source_variant source_variant
get_api20_arguments
} }
source_variant() { source_variant() {
......
...@@ -25,13 +25,19 @@ set -e ...@@ -25,13 +25,19 @@ set -e
check_required() { check_required() {
local required_params="IMG_ID IMG_FORMAT" local required_params="IMG_ID IMG_FORMAT"
local osparams="$required_params IMG_PASSWD IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL" local osparams="$required_params IMG_PASSWD IMG_PROPERTIES IMG_PERSONALITY CONFIG_URL"
local osp
source_variant
# Store OSP_VAR in VAR # Store OSP_VAR in VAR
for param in $osparams; do for param in $osparams; do
eval $param=\"\$OSP_$param\" # Only do the evaluation if OSP_$param is defined
osp="OSP_$param"
if [ -n "${!osp+dummy}" ]; then
eval $param=\"\$$osp\"
fi
done done
source_variant
for var in $required_params; do for var in $required_params; do
if [ -z "${!var}" ]; then if [ -z "${!var}" ]; then
......
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