From cc6af3fc94ea56b0f081eabcb65404b0fa3716fe Mon Sep 17 00:00:00 2001 From: Huan Xie Date: Wed, 23 Dec 2015 02:17:01 +0000 Subject: [PATCH] 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 --- inc/meta-config | 19 +++++++++++++++++++ stack.sh | 14 +------------- tools/xen/install_os_domU.sh | 11 ++++------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/inc/meta-config b/inc/meta-config index b6fe437802..6eb7a00f69 100644 --- a/inc/meta-config +++ b/inc/meta-config @@ -195,6 +195,25 @@ function merge_config_group { 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 09ab4747f1..df893da57a 100755 --- a/stack.sh +++ b/stack.sh @@ -149,19 +149,7 @@ GetDistro # 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 e24d9ed0b9..46ff0b6fda 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -12,13 +12,6 @@ set -o xtrace 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 @@ THIS_DIR=$(cd $(dirname "$0") && pwd) # # 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