From 9171b9b8b7214f42fa6e9f1bd52a10279da3d7c4 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Mon, 19 Nov 2018 13:54:54 +0100 Subject: [PATCH] Add cell0 database creation in postgresql Add cell0 database creation like stx patched in [1]. Also fixes an faulty comment in the same resource for mysql. [1] https://git.starlingx.io/cgit/stx-integ/tree/config/puppet-modules/openstack/puppet-nova-11.4.0/centos/patches/0003-Create-nova_cell0-database.patch Change-Id: I4183ed4417c9beeccf8b7355ac217088302d0160 --- manifests/db/mysql.pp | 2 +- manifests/db/postgresql.pp | 25 +++++++++++++++--- ...-cell0-db-postgresql-8bb48f15e4e77554.yaml | 8 ++++++ spec/classes/nova_db_postgresql_spec.rb | 26 ++++++++++++++++--- 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/add-cell0-db-postgresql-8bb48f15e4e77554.yaml diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index df142e09b..038b40b04 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -34,7 +34,7 @@ # [*setup_cell0*] # (Optional) Setup a cell0 for the cell_v2 functionality. This option will # be set to true by default in Ocata when the cell v2 setup is mandatory. -# Defaults to false +# Defaults to true # class nova::db::mysql( diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index c037886f1..9d11e1067 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -24,12 +24,18 @@ # (Optional) Privileges given to the database user. # Default to 'ALL' # +# [*setup_cell0*] +# (Optional) Setup a cell0 for the cell_v2 functionality. This option will +# be set to true by default in Ocata when the cell v2 setup is mandatory. +# Defaults to true +# class nova::db::postgresql( $password, - $dbname = 'nova', - $user = 'nova', - $encoding = undef, - $privileges = 'ALL', + $dbname = 'nova', + $user = 'nova', + $encoding = undef, + $privileges = 'ALL', + $setup_cell0 = true, ) { include ::nova::deps @@ -42,6 +48,17 @@ class nova::db::postgresql( privileges => $privileges, } + if $setup_cell0 { + # need for cell_v2 + ::openstacklib::db::postgresql { 'nova_cell0': + password_hash => postgresql_password($user, $password), + dbname => "${dbname}_cell0", + user => $user, + encoding => $encoding, + privileges => $privileges, + } + } + Anchor['nova::db::begin'] ~> Class['nova::db::postgresql'] ~> Anchor['nova::db::end'] diff --git a/releasenotes/notes/add-cell0-db-postgresql-8bb48f15e4e77554.yaml b/releasenotes/notes/add-cell0-db-postgresql-8bb48f15e4e77554.yaml new file mode 100644 index 000000000..bad254419 --- /dev/null +++ b/releasenotes/notes/add-cell0-db-postgresql-8bb48f15e4e77554.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + nova::db::postgresql now creates the nova_cell0 database +upgrade: + - | + nova::db::postgresql now creates the nova_cell0 database, you can disable + this behaviour by setting setup_cell0 to false. diff --git a/spec/classes/nova_db_postgresql_spec.rb b/spec/classes/nova_db_postgresql_spec.rb index 3a08b1daf..a920b3d16 100644 --- a/spec/classes/nova_db_postgresql_spec.rb +++ b/spec/classes/nova_db_postgresql_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'nova::db::postgresql' do - shared_examples_for 'nova::db::postgresql' do + shared_examples 'nova::db::postgresql' do let :req_params do { :password => 'pw' } end @@ -16,12 +16,30 @@ describe 'nova::db::postgresql' do req_params end - it { is_expected.to contain_postgresql__server__db('nova').with( - :user => 'nova', - :password => 'md557ae0608fad632bf0155cb9502a6b454' + it { should contain_openstacklib__db__postgresql('nova').with( + :password_hash => 'md557ae0608fad632bf0155cb9502a6b454', + :dbname => 'nova', + :user => 'nova', + :encoding => nil, + :privileges => 'ALL', + )} + + it { should contain_openstacklib__db__postgresql('nova_cell0').with( + :password_hash => 'md557ae0608fad632bf0155cb9502a6b454', + :dbname => 'nova_cell0', + :user => 'nova', + :encoding => nil, + :privileges => 'ALL', )} end + context 'when disabling cell0 setup' do + let :params do + { :setup_cell0 => false}.merge(req_params) + end + + it { is_expected.to_not contain_openstacklib__db__postgresql('nova_cell0') } + end end on_supported_os({