Merge "Tidy up upgrade scripts"

This commit is contained in:
Jenkins 2017-03-09 16:51:15 +00:00 committed by Gerrit Code Review
commit e6577fd0ac
3 changed files with 32 additions and 16 deletions

View File

@ -19,13 +19,29 @@
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v set -e -u -v
## Vars ----------------------------------------------------------------------
# The path from which this script is being run
export SCRIPTS_PATH="$(dirname "$(readlink -f "${0}")")" export SCRIPTS_PATH="$(dirname "$(readlink -f "${0}")")"
# The git checkout root path
export MAIN_PATH="$(dirname "${SCRIPTS_PATH}")" export MAIN_PATH="$(dirname "${SCRIPTS_PATH}")"
# The path to find all the upgrade playbooks
export UPGRADE_PLAYBOOKS="${SCRIPTS_PATH}/upgrade-utilities/playbooks" export UPGRADE_PLAYBOOKS="${SCRIPTS_PATH}/upgrade-utilities/playbooks"
# The toggle which guards against using this script prematurely
export I_REALLY_KNOW_WHAT_I_AM_DOING=${I_REALLY_KNOW_WHAT_I_AM_DOING:-"false"} export I_REALLY_KNOW_WHAT_I_AM_DOING=${I_REALLY_KNOW_WHAT_I_AM_DOING:-"false"}
# The expected source series name
export SOURCE_SERIES="ocata"
# The expected target series name
export TARGET_SERIES="pike"
## Functions ----------------------------------------------------------------- ## Functions -----------------------------------------------------------------
function run_lock { function run_lock {
@ -44,12 +60,12 @@ function run_lock {
fi fi
done done
if [ ! -d "/etc/openstack_deploy/upgrade-newton" ]; then if [ ! -d "/etc/openstack_deploy/upgrade-${TARGET_SERIES}" ]; then
mkdir -p "/etc/openstack_deploy/upgrade-newton" mkdir -p "/etc/openstack_deploy/upgrade-${TARGET_SERIES}"
fi fi
upgrade_marker_file=$(basename ${file_part} .yml) upgrade_marker_file=$(basename ${file_part} .yml)
upgrade_marker="/etc/openstack_deploy/upgrade-newton/$upgrade_marker_file.complete" upgrade_marker="/etc/openstack_deploy/upgrade-${TARGET_SERIES}/$upgrade_marker_file.complete"
if [ ! -f "$upgrade_marker" ];then if [ ! -f "$upgrade_marker" ];then
# note(sigmavirus24): use eval so that we properly turn strings like # note(sigmavirus24): use eval so that we properly turn strings like
@ -110,13 +126,12 @@ function pre_flight {
# Notify the user. # Notify the user.
echo -e " echo -e "
This script will perform a v13.x to v14.x upgrade. This script will perform a ${SOURCE_SERIES^} to ${TARGET_SERIES^} upgrade.
Once you start the upgrade there's no going back. Once you start the upgrade there's no going back.
Note, this is an online upgrade and while the Note that the upgrade targets impacting the data
in progress running VMs will not be impacted. plane as little as possible, but assumes that the
However, you can expect some hiccups with OpenStack control plane can experience some down time.
API services while the upgrade is running.
Are you ready to perform this upgrade now? Are you ready to perform this upgrade now?
" "
@ -124,7 +139,7 @@ function pre_flight {
# Confirm the user is ready to upgrade. # Confirm the user is ready to upgrade.
read -p 'Enter "YES" to continue or anything else to quit: ' UPGRADE read -p 'Enter "YES" to continue or anything else to quit: ' UPGRADE
if [ "${UPGRADE}" == "YES" ]; then if [ "${UPGRADE}" == "YES" ]; then
echo "Running Upgrade from v13.x to v14.x" echo "Running Upgrade from ${SOURCE_SERIES^} to ${TARGET_SERIES^}"
else else
exit 99 exit 99
fi fi

View File

@ -18,11 +18,15 @@
connection: local connection: local
gather_facts: false gather_facts: false
user: root user: root
vars:
upgrade_scripts: "{{ playbook_dir }}/../scripts"
repo_root_dir: "{{ playbook_dir }}/../../../"
source_series: "ocata"
tasks: tasks:
- name: Create an old copy of openstack_deploy - name: Create an old copy of openstack_deploy
copy: copy:
src: "/etc/openstack_deploy/" src: "/etc/openstack_deploy/"
dest: "/etc/openstack_deploy.OCATA/" dest: "/etc/openstack_deploy.{{ source_series | upper }}/"
force: no force: no
- name: Check if there is a user-space env.d directory - name: Check if there is a user-space env.d directory
@ -55,7 +59,7 @@
- name: Update OpenStack variable names - name: Update OpenStack variable names
command: "{{ upgrade_scripts }}/migrate_openstack_vars.py {{ item }} {{ (item | basename)[:-4] }}" command: "{{ upgrade_scripts }}/migrate_openstack_vars.py {{ item }} {{ (item | basename)[:-4] }}"
args: args:
creates: "/etc/openstack_deploy.NEWTON/VARS_MIGRATED_{{ (item | basename)[:-4] }}" creates: "/etc/openstack_deploy.{{ source_series | upper }}/VARS_MIGRATED_{{ (item | basename)[:-4] }}"
with_fileglob: with_fileglob:
- "/etc/openstack_deploy/user_*.yml" - "/etc/openstack_deploy/user_*.yml"
@ -68,6 +72,3 @@
with_items: with_items:
- key: "default_bind_mount_logs" - key: "default_bind_mount_logs"
value: false value: false
vars:
upgrade_scripts: "{{ playbook_dir }}/../scripts"
repo_root_dir: "{{ playbook_dir }}/../../../"

View File

@ -65,6 +65,6 @@ if __name__ == '__main__':
flag_ref = sys.argv[2] flag_ref = sys.argv[2]
main(filename) main(filename)
flag_file = '/etc/openstack_deploy.NEWTON/VARS_MIGRATED_%s' % flag_ref flag_file = '/etc/openstack_deploy.OCATA/VARS_MIGRATED_%s' % flag_ref
with open(flag_file, 'w') as f: with open(flag_file, 'w') as f:
f.write('OpenStack Newton variables migrated.') f.write('OpenStack-Ansible variables migrated.')