openstack-helm/nova/templates/bin/_db-sync.sh.tpl
Andrii Ostapenko 3ac3caa013 Add support for Victoria and Wallaby
Defines compute kit and cinder jobs for new releases with
corresponding values overrides.

Disables compute agent list test for Wallaby since related API
is removed [0].

Since Wallaby with switch of osc to sdk '--id auto' is no longer
treated specially in 'openstack flavor create'. The same behavior
can be achieved w/o specifying --id flag for flavor creation [1].

Starting Wallaby 'nova-manage api_db version' returns init version
for empty database greater than 0 [2]. _db-sync.sh.tpl logic prior to
this commit does not work due to this. We need to either remove
(done in current commit) or justify and alter previous logic.

[0] https://review.opendev.org/749309
[1] https://review.opendev.org/750151
[2] https://opendev.org/openstack/nova/src/branch/stable/wallaby/nova/db/sqlalchemy/migration.py#L32

Change-Id: I361431d9aa8c1a06c5d59f479fb161ecd87e2ee2
Signed-off-by: Andrii Ostapenko <andrii.ostapenko@att.com>
2021-08-02 15:46:07 +00:00

69 lines
2.4 KiB
Smarty

#!/bin/bash
{{/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
set -ex
NOVA_VERSION=$(nova-manage --version 2>&1 | grep -Eo '[0-9]+[.][0-9]+[.][0-9]+')
function manage_cells () {
# NOTE(portdirect): check if nova fully supports cells v2, and manage
# accordingly. Support was complete in ocata (V14.x.x).
if [ "${NOVA_VERSION%%.*}" -gt "14" ]; then
nova-manage cell_v2 map_cell0
nova-manage cell_v2 list_cells | grep -q " cell1 " || \
nova-manage cell_v2 create_cell --name=cell1 --verbose
CELL0_ID=$(nova-manage cell_v2 list_cells | awk -F '|' '/ cell0 / { print $3 }' | tr -d ' ')
CELL1_ID=$(nova-manage cell_v2 list_cells | awk -F '|' '/ cell1 / { print $3 }' | tr -d ' ')
set +x
CELL0_TRANSPORT=$(nova-manage cell_v2 list_cells | awk -F '|' '/ cell0 / { print $4 }' | tr -d ' ')
if [ -z "${DB_CONNECTION_CELL0}" ]; then
echo "ERROR: missing DB_CONNECTION_CELL0"
exit 1
fi
nova-manage cell_v2 update_cell \
--cell_uuid="${CELL0_ID}" \
--name="cell0" \
--transport-url="${CELL0_TRANSPORT}" \
--database_connection="${DB_CONNECTION_CELL0}"
for VAR in TRANSPORT_URL DB_CONNECTION; do
if [ -z "${!VAR}" ]; then
echo "ERROR: missing $VAR variable"
exit 1
fi
done
nova-manage cell_v2 update_cell \
--cell_uuid="${CELL1_ID}" \
--name="cell1" \
--transport-url="${TRANSPORT_URL}" \
--database_connection="${DB_CONNECTION}"
set -x
fi
}
# NOTE(aostapenko) Starting Wallaby nova-manage api_db version returns init version for empty database
# greater than 0 # https://opendev.org/openstack/nova/src/branch/stable/wallaby/nova/db/sqlalchemy/migration.py#L32
# thus logic prior to this commit does not work. We need to either remove or justify and alter previous logic.
nova-manage api_db sync
manage_cells
nova-manage db sync
nova-manage db online_data_migrations
echo 'Finished DB migrations'