ovn migration: Support stack name

The heat stack name is variable. This patch adds a new environment
variable to support migrating stacks that are different name than
overcloud.

Change-Id: I6fd72bf83def28ae633d720b8495888cea3ac0a3
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
(cherry picked from commit afd63d0b36)
This commit is contained in:
Jakub Libosvar 2020-07-14 14:36:14 +02:00
parent 66bcfcf692
commit 20b9e7759f
2 changed files with 18 additions and 1 deletions

View File

@ -107,6 +107,11 @@ Perform the following steps in the undercloud
step 1. step 1.
Default: ~/overcloud-deploy-ovn.sh Default: ~/overcloud-deploy-ovn.sh
* STACK_NAME - Name or ID of the heat stack
Default: 'overcloud'
If the stack that is migrated differs from the default, please set this
environment variable to the stack name or ID.
* PUBLIC_NETWORK_NAME - Name of your public network. * PUBLIC_NETWORK_NAME - Name of your public network.
Default: 'public'. Default: 'public'.
To support migration validation, this network must have available To support migration validation, this network must have available

View File

@ -30,6 +30,7 @@ LANG=C
: ${OVERCLOUD_OVN_DEPLOY_SCRIPT:=~/overcloud-deploy-ovn.sh} : ${OVERCLOUD_OVN_DEPLOY_SCRIPT:=~/overcloud-deploy-ovn.sh}
: ${OPT_WORKDIR:=$PWD} : ${OPT_WORKDIR:=$PWD}
: ${STACK_NAME:=overcloud}
: ${PUBLIC_NETWORK_NAME:=public} : ${PUBLIC_NETWORK_NAME:=public}
: ${IMAGE_NAME:=cirros} : ${IMAGE_NAME:=cirros}
: ${SERVER_USER_NAME:=cirros} : ${SERVER_USER_NAME:=cirros}
@ -127,7 +128,7 @@ generate_ansible_inventory_file() {
echo "[ovn-dbs]" > hosts_for_migration echo "[ovn-dbs]" > hosts_for_migration
ovn_central=True ovn_central=True
inventory_file=$(mktemp --tmpdir ansible-inventory-XXXXXXXX.yaml) inventory_file=$(mktemp --tmpdir ansible-inventory-XXXXXXXX.yaml)
/usr/bin/tripleo-ansible-inventory --static-yaml-inventory "$inventory_file" /usr/bin/tripleo-ansible-inventory --stack $STACK_NAME --static-yaml-inventory "$inventory_file"
# We want to run ovn_dbs where neutron_api is running # We want to run ovn_dbs where neutron_api is running
OVN_DBS=$(get_group_hosts "$inventory_file" neutron_api) OVN_DBS=$(get_group_hosts "$inventory_file" neutron_api)
for node_name in $OVN_DBS; do for node_name in $OVN_DBS; do
@ -190,6 +191,16 @@ EOF
echo "Please review the file before running the next command - setup-mtu-t1" echo "Please review the file before running the next command - setup-mtu-t1"
} }
# Check if the stack exists
function check_stack {
source $STACKRC_FILE
openstack stack show $STACK_NAME 1> /dev/null || {
echo "ERROR: STACK_NAME=${STACK_NAME} does not exist. Please provide the stack name or its ID "
echo " via STACK_NAME environment variable."
exit 1
}
}
# Check if the public network exists, and if it has floating ips available # Check if the public network exists, and if it has floating ips available
oc_check_public_network() { oc_check_public_network() {
@ -307,6 +318,7 @@ command=$1
ret_val=0 ret_val=0
case $command in case $command in
generate-inventory) generate-inventory)
check_stack
oc_check_public_network oc_check_public_network
generate_ansible_inventory_file generate_ansible_inventory_file
generate_ansible_config_file generate_ansible_config_file