XenAPI: add support to use local.conf
XenServer install with devstack doesn't support local.conf, this fix
is to add support for using local.conf and backward-compatibility of
localrc
Change-Id: Ie494e01f8f1ecb8720e14392ef3f12d5a5a01dcd
Closes-Bug: #1528520
diff --git a/inc/meta-config b/inc/meta-config
index b6fe437..6eb7a00 100644
--- a/inc/meta-config
+++ b/inc/meta-config
@@ -195,6 +195,25 @@
done
}
+function extract_localrc_section {
+ local configfile=$1 # top_dir/local.conf
+ local localrcfile=$2 # top_dir/localrc
+ local localautofile=$3 # top_dir/.localrc.auto
+
+ if [[ -r $configfile ]]; then
+ LRC=$(get_meta_section_files $configfile local)
+ for lfile in $LRC; do
+ if [[ "$lfile" == "localrc" ]]; then
+ if [[ -r $localrcfile ]]; then
+ echo "localrc and local.conf:[[local]] both exist, using localrc"
+ else
+ echo "# Generated file, do not edit" >$localautofile
+ get_meta_section $configfile local $lfile >>$localautofile
+ fi
+ fi
+ done
+ fi
+}
# Restore xtrace
$_XTRACE_INC_META
diff --git a/stack.sh b/stack.sh
index 09ab474..df893da 100755
--- a/stack.sh
+++ b/stack.sh
@@ -149,19 +149,7 @@
# Phase: local
rm -f $TOP_DIR/.localrc.auto
-if [[ -r $TOP_DIR/local.conf ]]; then
- LRC=$(get_meta_section_files $TOP_DIR/local.conf local)
- for lfile in $LRC; do
- if [[ "$lfile" == "localrc" ]]; then
- if [[ -r $TOP_DIR/localrc ]]; then
- warn $LINENO "localrc and local.conf:[[local]] both exist, using localrc"
- else
- echo "# Generated file, do not edit" >$TOP_DIR/.localrc.auto
- get_meta_section $TOP_DIR/local.conf local $lfile >>$TOP_DIR/.localrc.auto
- fi
- fi
- done
-fi
+extract_localrc_section $TOP_DIR/local.conf $TOP_DIR/localrc $TOP_DIR/.localrc.auto
# ``stack.sh`` is customizable by setting environment variables. Override a
# default setting via export::
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index e24d9ed..46ff0b6 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -12,13 +12,6 @@
export LC_ALL=C
-# Abort if localrc is not set
-if [ ! -e ../../localrc ]; then
- echo "You must have a localrc with ALL necessary passwords defined before proceeding."
- echo "See the xen README for required passwords."
- exit 1
-fi
-
# This directory
THIS_DIR=$(cd $(dirname "$0") && pwd)
@@ -31,6 +24,10 @@
#
# Get Settings
#
+TOP_DIR=$(cd $THIS_DIR/../../ && pwd)
+source $TOP_DIR/inc/meta-config
+rm -f $TOP_DIR/.localrc.auto
+extract_localrc_section $TOP_DIR/local.conf $TOP_DIR/localrc $TOP_DIR/.localrc.auto
# Source params - override xenrc params in your localrc to suit your taste
source $THIS_DIR/xenrc