Use templating for nova cell database_connection

Nova now allows use of templated urls in the database and mq
connections which will allow static configuration elements to be
applied to the urls read from the database per-node. This should
be a simpler and less obscure method of configuring things like
the per-node bind_address necessary for director's HA arrangement.

This patch addresses the templated DB urls as part 1.

Nova support added here:
https://review.openstack.org/#/c/578163/

Related-Bug: 1808134

Co-Authored-By: Martin Schuppert <mschuppert@redhat.com>

Change-Id: If30b4647bca210663a22fd653e752d4d57345bdd
This commit is contained in:
Oliver Walsh 2018-10-17 18:37:38 +01:00 committed by Martin Schuppert
parent 834a3d8335
commit 7288062676
4 changed files with 115 additions and 21 deletions

View File

@ -62,11 +62,20 @@ parameters:
description: The password for the nova service and db account description: The password for the nova service and db account
type: string type: string
hidden: true hidden: true
MysqlIPv6:
default: false
description: Enable IPv6 in MySQL
type: boolean
conditions: conditions:
internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]} internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
mysql_ipv6_use_ip_address:
and:
- {equals: [{get_param: MysqlIPv6}, true]}
- {equals: [{get_param: EnableInternalTLS}, false]}
resources: resources:
ContainersCommon: ContainersCommon:
@ -195,16 +204,37 @@ outputs:
nova_api_ensure_default_cell.sh: nova_api_ensure_default_cell.sh:
mode: "0700" mode: "0700"
content: | content:
#!/bin/bash str_replace:
DEFID=$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}') template: |
if [ "$DEFID" ]; then #!/bin/bash
echo "(cellv2) Updating default cell_v2 cell $DEFID" DEFID=$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}')
su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 update_cell --cell_uuid $DEFID --name=default" if [ "$DEFID" ]; then
else echo "(cellv2) Updating default cell_v2 cell $DEFID"
echo "(cellv2) Creating default cell_v2 cell" su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 update_cell --cell_uuid $DEFID --name=default --database_connection='CELLDB'"
su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 create_cell --name=default" else
fi echo "(cellv2) Creating default cell_v2 cell"
su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 create_cell --name=default --database_connection='CELLDB'"
fi
params:
CELLDB:
list_join:
- ''
- - '{scheme}'
- '://'
- '{username}'
- ':'
- '{password}'
- '@'
-
if:
- mysql_ipv6_use_ip_address
- '[{hostname}]'
- '{hostname}'
- '/'
- 'nova'
- '?'
- '{query}'
docker_config: docker_config:
step_2: step_2:
get_attr: [NovaApiLogging, docker_config, step_2] get_attr: [NovaApiLogging, docker_config, step_2]
@ -230,7 +260,28 @@ outputs:
detach: false detach: false
user: root user: root
volumes: *nova_api_bootstrap_volumes volumes: *nova_api_bootstrap_volumes
command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'" command:
str_replace:
template: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0 --database_connection=\"CELL0DB\"'"
params:
CELL0DB:
list_join:
- ''
- - '{scheme}'
- '://'
- '{username}'
- ':'
- '{password}'
- '@'
-
if:
- mysql_ipv6_use_ip_address
- '[{hostname}]'
- '{hostname}'
- '/'
- 'nova_cell0'
- '?'
- '{query}'
nova_api_ensure_default_cell: nova_api_ensure_default_cell:
start_order: 2 start_order: 2
image: *nova_api_image image: *nova_api_image
@ -477,19 +528,50 @@ outputs:
- name: Setup cell_v2 (map cell0) - name: Setup cell_v2 (map cell0)
shell: shell:
str_replace: str_replace:
template: nova-manage cell_v2 map_cell0 --database_connection=CELL template: nova-manage cell_v2 map_cell0 --database_connection='CELL0DB'
params: params:
CELL: CELL0DB:
make_url: list_join:
scheme: {get_param: [EndpointMap, MysqlInternal, protocol]} - ''
username: nova - - '{scheme}'
password: {get_param: NovaPassword} - '://'
host: {get_param: [EndpointMap, MysqlInternal, host]} - '{username}'
path: /nova_cell0 - ':'
- '{password}'
- '@'
-
if:
- mysql_ipv6_use_ip_address
- '[{hostname}]'
- '{hostname}'
- '/'
- 'nova_cell0'
- '?'
- '{query}'
- name: Setup cell_v2 (create default cell) - name: Setup cell_v2 (create default cell)
# (owalsh) puppet-nova expects the cell name 'default' # (owalsh) puppet-nova expects the cell name 'default'
# (owalsh) pass the db uri explicitly to avoid https://bugs.launchpad.net/tripleo/+bug/1662344 shell:
shell: nova-manage cell_v2 create_cell --name='default' --database_connection=$(hiera nova::database_connection) str_replace:
template: nova-manage cell_v2 create_cell --name='default' --database_connection='CELLDB'
params:
CELLDB:
list_join:
- ''
- - '{scheme}'
- '://'
- '{username}'
- ':'
- '{password}'
- '@'
-
if:
- mysql_ipv6_use_ip_address
- '[{hostname}]'
- '{hostname}'
- '/'
- 'nova'
- '?'
- '{query}'
register: nova_api_create_cell register: nova_api_create_cell
failed_when: nova_api_create_cell.rc not in [0,2] failed_when: nova_api_create_cell.rc not in [0,2]
changed_when: nova_api_create_cell.rc == 0 changed_when: nova_api_create_cell.rc == 0

View File

@ -0,0 +1,10 @@
---
features:
- |
Nova now allows use of templated urls in the database and mq
connections which will allow static configuration elements to be
applied to the urls read from the database per-node. This should
be a simpler and less obscure method of configuring things like
the per-node bind_address necessary for director's HA arrangement.
This patch addresses the templated DB urls as part 1.
Nova support added here - https://review.openstack.org/578163

View File

@ -65,6 +65,7 @@
- OS::TripleO::Services::MistralEventEngine - OS::TripleO::Services::MistralEventEngine
- OS::TripleO::Services::MistralExecutor - OS::TripleO::Services::MistralExecutor
- OS::TripleO::Services::MySQL - OS::TripleO::Services::MySQL
- OS::TripleO::Services::MySQLClient
- OS::TripleO::Services::NeutronApi - OS::TripleO::Services::NeutronApi
- OS::TripleO::Services::NeutronCorePlugin - OS::TripleO::Services::NeutronCorePlugin
- OS::TripleO::Services::NeutronDhcpAgent - OS::TripleO::Services::NeutronDhcpAgent

View File

@ -68,6 +68,7 @@
- OS::TripleO::Services::MistralEventEngine - OS::TripleO::Services::MistralEventEngine
- OS::TripleO::Services::MistralExecutor - OS::TripleO::Services::MistralExecutor
- OS::TripleO::Services::MySQL - OS::TripleO::Services::MySQL
- OS::TripleO::Services::MySQLClient
- OS::TripleO::Services::NeutronApi - OS::TripleO::Services::NeutronApi
- OS::TripleO::Services::NeutronCorePlugin - OS::TripleO::Services::NeutronCorePlugin
- OS::TripleO::Services::NeutronDhcpAgent - OS::TripleO::Services::NeutronDhcpAgent