From cfa3d1121b3614506b54f74f170f5c13b983c244 Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Thu, 8 Mar 2018 01:32:07 +0100 Subject: [PATCH] devstack-heat: Make parameters overridable Up until now, if you wanted to change the defaults in the parameters, you had to go and edit the hot/parameters.yml file. This was inconvenient because it would then show up in git diff and prevent git review from normal operation. This patch makes it so that now you can pass the parameters just like if it was the openstack-cli. For example: ./devstack-heat stack \ --parameter \ "public_net=fbf9bcc6-cbaa-4c24-8d56-8010915a6494" \ --parameter \ "image=CentOS-7-x86_64-GenericCloud-1801-01" Change-Id: Icf4fb124d03f56c8cf383971c5161520a1734d94 Signed-off-by: Antoni Segura Puimedon --- .gitignore | 3 ++ contrib/devstack-heat/devstack-heat | 43 ++++++++++++++++++++++-- contrib/devstack-heat/hot/parameters.yml | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 39e5fd122..6bd90a35a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,9 @@ contrib/vagrant/user_local.conf # Log files *.log +# devstack-heat +*.pem + # Binaries from docker images builds kuryr-cni-bin kuryr-cni diff --git a/contrib/devstack-heat/devstack-heat b/contrib/devstack-heat/devstack-heat index 8e37e8b1c..8b392f671 100755 --- a/contrib/devstack-heat/devstack-heat +++ b/contrib/devstack-heat/devstack-heat @@ -7,14 +7,53 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "${CURR_DIR}/lib/devstack-heat" function sub_stack() { - local deployment=${1:-master_} + local deployment + local environment + local key + local parameters + local positional + + parameters=() + positional=() + while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -e|--environment) + environment="$2" + shift + shift + ;; + --parameter) + parameters+=("$key") + parameters+=("$2") + shift + shift + ;; + *) + positional+=("$1") + shift + ;; + esac + done + if [[ ${#positional[@]} -eq 0 ]]; then + deployment=master_ + else + deployment="${positional[0]}" + fi deployment=$(_generate_deployment_name "${deployment}") + if [[ -z "$environment" ]]; then + environment="hot/parameters.yml" + fi + # create stack _confirm_or_exit "Deploying the stack ${deployment}" echo "Starting..." - openstack stack create -e hot/parameters.yml -t hot/devstack_heat_template.yml "$deployment" + set -- "${parameters[@]}" + set -x + openstack stack create -e "$environment" -t hot/devstack_heat_template.yml "$@" "$deployment" + set +x sub_show "$deployment" } diff --git a/contrib/devstack-heat/hot/parameters.yml b/contrib/devstack-heat/hot/parameters.yml index bd5d361ac..f2aba49d2 100644 --- a/contrib/devstack-heat/hot/parameters.yml +++ b/contrib/devstack-heat/hot/parameters.yml @@ -1,4 +1,4 @@ -parameters: +parameter_defaults: image: centos7 flavor: m1.medium public_net: public