From 3c25ada08e2fdf65163aecd28abe46bfe0853949 Mon Sep 17 00:00:00 2001 From: Rei Oliveira Date: Tue, 23 Aug 2022 18:32:36 -0300 Subject: [PATCH] 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 Change-Id: I3ea16f094b28900d9aa04227104888b918ccc4b7 --- .../20-barbican-data-migration.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 controllerconfig/controllerconfig/upgrade-scripts/20-barbican-data-migration.sh diff --git a/controllerconfig/controllerconfig/upgrade-scripts/20-barbican-data-migration.sh b/controllerconfig/controllerconfig/upgrade-scripts/20-barbican-data-migration.sh new file mode 100644 index 0000000000..be987ae4d3 --- /dev/null +++ b/controllerconfig/controllerconfig/upgrade-scripts/20-barbican-data-migration.sh @@ -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