diff --git a/docker/services/database/mysql.yaml b/docker/services/database/mysql.yaml index 87c3936e0f..a5bf1cfe2a 100644 --- a/docker/services/database/mysql.yaml +++ b/docker/services/database/mysql.yaml @@ -48,6 +48,10 @@ parameters: type: string description: Specifies the default CA cert to use if TLS is used for services in the internal network. + MigrateLegacyNeutronDb: + type: boolean + description: Used to rename the undercloud database from neutron to ovs_neutron. + default: false conditions: @@ -233,6 +237,31 @@ outputs: Log files from mysql containers can be found under /var/log/containers/mysql. ignore_errors: true + # https://bugs.launchpad.net/tripleo/+bug/1753247 + - name: Rename old neutron database to ovs_neutron + shell: > + if [ -d /var/lib/mysql/neutron ] ; then + mysql -e "CREATE DATABASE IF NOT EXISTS \`ovs_neutron\`;" + for table in `mysql -B -N -e "SHOW TABLES;" neutron` + do + mysql -e "RENAME TABLE \`neutron\`.\`$table\` to \`ovs_neutron\`.\`$table\`" + done + mysql -e "DROP DATABASE \`neutron\`;" + fi + become: true + when: {get_param: MigrateLegacyNeutronDb} + register: neutron_db_migration + - name: Check if mysql service is deployed + command: systemctl is-enabled --quiet mariadb + ignore_errors: True + register: mariadb_enabled + when: {get_param: MigrateLegacyNeutronDb} + - name: Stop and disable mysql service when undercloud is containerized + when: + - {get_param: MigrateLegacyNeutronDb} + - mariadb_enabled.rc == 0 + - neutron_db_migration.rc == 0 + service: name=mariadb state=stopped enabled=no upgrade_tasks: - name: Check if mysql service is deployed command: systemctl is-enabled --quiet mariadb diff --git a/environments/undercloud.yaml b/environments/undercloud.yaml index 3ae119bcaf..9613ce427d 100644 --- a/environments/undercloud.yaml +++ b/environments/undercloud.yaml @@ -70,3 +70,4 @@ parameter_defaults: NeutronTypeDrivers: ['local','flat','vlan','gre','vxlan'] NeutronVniRanges: '10:100' NeutronPortQuota: '-1' + MigrateLegacyNeutronDb: true diff --git a/releasenotes/notes/neutron_db_rename-bbfbce1c58cadc84.yaml b/releasenotes/notes/neutron_db_rename-bbfbce1c58cadc84.yaml new file mode 100644 index 0000000000..7ccb05456b --- /dev/null +++ b/releasenotes/notes/neutron_db_rename-bbfbce1c58cadc84.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + When the undercloud was not containerized, the neutron database name was called neutron. + When we upgrade to a containerized undercloud, the database name is called ovs_neutron. + We introduced MigrateLegacyNeutronDb (false by default in the service but true when + the undercloud is containerized) that will rename the database during host_prep_tasks.