config/controllerconfig/controllerconfig/upgrade-scripts/21-keystone-data-migration.sh
Rei Oliveira 5e7c958466 Add keystone database migration script
This commit adds an upgrade script to perform the keystone data
migration. This the migration command will run only if the distro
is debian.

Test Plan:

PASS: Verify the DX upgrade from stx 22.06 to 22.12
PASS: Verify that the script for keystone data-migration runs without
      error
PASS: Verify with a database dump that data is migrated successfully and
      only DDL changes are present.
PASS: Verify that keystone services are up and openstack keystone
      commands are working, such as openstack user list, etc.
PASS: Verify that it's possible to change a user's password using
      keystone and verify that it's possible to log back with that user

Story: 2009303
Task: 46075
Depends-On: https://review.opendev.org/c/starlingx/integ/+/854246

Signed-off-by: Rei Oliveira <Reinildes.JoseMateusOliveira@windriver.com>
Change-Id: I9e9496ea6ce19adaac60105f637a29c278951314
2022-08-25 17:11:04 -03:00

39 lines
1.0 KiB
Bash

#!/bin/bash
#
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script is used to perform keystone data-migration
NAME=$(basename $0)
# The migration scripts are passed these parameters:
FROM_RELEASE=$1
TO_RELEASE=$2
ACTION=$3
# Checks linux distro because keystone is not upgraded in centos
IS_DEBIAN=$(grep -c "ID=debian" /etc/os-release)
# This will log to /var/log/platform.log
function log {
logger -p local1.info $1
}
# Script start
log "$NAME: Starting keystone data migration from release $FROM_RELEASE to $TO_RELEASE with action $ACTION"
if [[ "${ACTION}" == "migrate" ]] && [[ "${TO_RELEASE}" == "22.12" ]] && [[ ${IS_DEBIAN} != 0 ]]; then
touch /var/log/keystone/keystone.log
chown keystone:keystone /var/log/keystone/keystone.log
/usr/bin/keystone-manage db_sync
log "$NAME: Keystone data migration finished successfully from $FROM_RELEASE to $TO_RELEASE"
else
log "$NAME: No actions required for from release $FROM_RELEASE to $TO_RELEASE with action $ACTION"
fi
exit 0