Add barbican database migration script

This commit adds an upgrade script to perform the barbican data
migration. This migration command will run only in debian.

Test Plan:

PASS: Verify the DX upgrade from stx 22.06 to 22.12
PASS: Verify that the script for barbican db upgrade runs without error
PASS: Verify with a database dump that data is migrated successfully and
      only DDL changes are present.
PASS: Verify that barbican services are up and openstack barbican
      commands are working, such as openstack secret list, etc.
PASS: Verify that it's possible to create and retrieve new secrets
      after the upgrade

Story: 2009303
Task: 46106

Signed-off-by: Rei Oliveira <Reinildes.JoseMateusOliveira@windriver.com>
Change-Id: I3ea16f094b28900d9aa04227104888b918ccc4b7
This commit is contained in:
Rei Oliveira 2022-08-23 18:32:36 -03:00
parent 9024a2b4b5
commit 3c25ada08e
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#!/bin/bash
#
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script is used to perform barbican data-migration
NAME=$(basename $0)
# The migration scripts are passed these parameters:
FROM_RELEASE=$1
TO_RELEASE=$2
ACTION=$3
# Checks linux distro because barbican 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 barbican data migration from release $FROM_RELEASE to $TO_RELEASE with action $ACTION"
if [[ "${ACTION}" == "migrate" ]] && [[ "${TO_RELEASE}" == "22.12" ]] && [[ ${IS_DEBIAN} != 0 ]]; then
/usr/bin/barbican-db-manage upgrade
log "$NAME: Barbican 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