Add cell_v2 simple_cell_setup

As part of Ocata, nova has made the cell_v2 setup manditory for the
nova-api db sync process. This change adds a simple cell_v2 setup with a
cell0 and an execution of the 'nova-manage cell_v2 simple_cell_setup' as
part of the nova-api db setup and sync process.

Change-Id: Idfc369e9e17f7d5a30ce4ff52beb604dd4a6ac23
Closes-Bug: #1649341
(cherry picked from commit 4234ce3df4)
This commit is contained in:
Alex Schultz 2016-12-12 14:52:57 -07:00
parent 5a00cee24a
commit 53e6f7a64e
9 changed files with 185 additions and 15 deletions

View File

@ -31,6 +31,11 @@
# (optional) Additional hosts that are allowed to access this DB
# Defaults to undef
#
# [*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
#
class nova::db::mysql_api(
$password,
$dbname = 'nova_api',
@ -39,6 +44,7 @@ class nova::db::mysql_api(
$charset = 'utf8',
$collate = 'utf8_general_ci',
$allowed_hosts = undef,
$setup_cell0 = false,
) {
include ::nova::deps
@ -53,6 +59,20 @@ class nova::db::mysql_api(
allowed_hosts => $allowed_hosts,
}
if $setup_cell0 {
# need for cell_v2
::openstacklib::db::mysql { 'nova_api_cell0':
user => $user,
password_hash => mysql_password($password),
dbname => "${dbname}_cell0",
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
create_user => false,
}
}
Anchor['nova::db::begin']
~> Class['nova::db::mysql_api']
~> Anchor['nova::db::end']

View File

@ -9,8 +9,15 @@
# the command line between 'nova-manage' and 'db sync'.
# Defaults to undef
#
# [*cellv2_setup*]
# (optional) This flag toggles if we run the cell_v2 simple_cell_setup action
# with nova-manage. This flag will be set to true in Ocata when the cell v2
# setup is mandatory.
# Defaults to false.
#
class nova::db::sync_api(
$extra_params = undef,
$cellv2_setup = false,
) {
include ::nova::deps
@ -29,4 +36,8 @@ class nova::db::sync_api(
],
notify => Anchor['nova::dbsync_api::end'],
}
if $cellv2_setup {
include ::nova::db::sync_cell_v2
}
}

View File

@ -0,0 +1,46 @@
#
# Class to execute nova cell_v2 setup
#
# ==Parameters
#
# [*extra_params*]
# (optional) String of extra command line parameters to append
# to the nova-manage db sync command. These will be inserted in
# the command line between 'nova-manage' and 'db sync'.
# Defaults to ''
#
# [*transport_url*]
# (optional) This is the transport url to use for the simple cell setup.
# By default the command should look for the DEFAULT/transport_url from
# the nova configuration. If not available, you need to provide the
# transport url via the parameters. Prior to Ocata, the transport-url
# was a required parameter.
# Defaults to undef.
#
class nova::db::sync_cell_v2 (
$extra_params = '',
$transport_url = undef,
) {
include ::nova::deps
if $transport_url {
$transport_url_real = "--transport-url=${transport_url}"
} else {
$transport_url_real = ''
}
exec { 'nova-cell_v2-simple-cell-setup':
command => "/usr/bin/nova-manage ${extra_params} cell_v2 simple_cell_setup ${transport_url_real}",
refreshonly => true,
try_sleep => 5,
tries => 10,
logoutput => on_failure,
subscribe => [
Anchor['nova::install::end'],
Anchor['nova::config::end'],
Anchor['nova::dbsync_api::end'],
Anchor['nova::cell_v2::begin']
],
notify => Anchor['nova::cell_v2::end'],
}
}

View File

@ -22,6 +22,8 @@ class nova::deps {
-> anchor { 'nova::dbsync::end': }
~> anchor { 'nova::dbsync_api::begin': }
-> anchor { 'nova::dbsync_api::end': }
~> anchor { 'nova::cell_v2::begin': }
-> anchor { 'nova::cell_v2::end': }
~> anchor { 'nova::service::begin': }
~> Service<| tag == 'nova-service' |>
~> anchor { 'nova::service::end': }

View File

@ -0,0 +1,5 @@
---
features:
- Adds cell_v2 simple_cell_setup as part of the nova-api database setup.
upgrade:
- The cell_v2 setup will become mandatory in Ocata.

View File

@ -50,6 +50,10 @@ describe 'basic nova' do
class { '::nova::keystone::authtoken':
password => 'a_big_secret',
}
# TODO(aschultz): remove this once https://review.openstack.org/#/c/409970/ lands
class { '::nova::db::sync_cell_v2':
transport_url => 'rabbit://nova:an_even_bigger_secret@127.0.0.1:5672/',
}
class { '::nova::api':
service_name => 'httpd',
}

View File

@ -22,6 +22,8 @@ describe 'nova::db::mysql_api' do
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
it { is_expected.to_not contain_openstacklib__db__mysql('nova_api_cell0') }
end
context 'overriding allowed_hosts param to array' do
@ -68,6 +70,20 @@ describe 'nova::db::mysql_api' do
)}
end
context 'when enabling cell0 setup' do
let :params do
{ :setup_cell0 => true }.merge(required_params)
end
it { is_expected.to contain_openstacklib__db__mysql('nova_api_cell0').with(
:user => 'nova_api',
:password_hash => '*AA1420F182E88B9E5F874F6FBE7459291E8F4601',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:create_user => false,
)}
end
end
on_supported_os({

View File

@ -3,19 +3,26 @@ require 'spec_helper'
describe 'nova::db::sync_api' do
shared_examples_for 'nova-dbsync-api' do
it 'runs nova-db-sync-api' do
is_expected.to contain_exec('nova-db-sync-api').with(
:command => '/usr/bin/nova-manage api_db sync',
:refreshonly => 'true',
:logoutput => 'on_failure'
)
context 'with defaults' do
it {
is_expected.to contain_exec('nova-db-sync-api').with(
:command => '/usr/bin/nova-manage api_db sync',
:refreshonly => 'true',
:logoutput => 'on_failure',
:subscribe => ['Anchor[nova::install::end]',
'Anchor[nova::config::end]',
'Anchor[nova::dbsync_api::begin]'],
:notify => 'Anchor[nova::dbsync_api::end]',
)
}
it { is_expected.to_not contain_class('nova::db::sync_cell_v2') }
end
describe "overriding extra_params" do
context "overriding extra_params" do
let :params do
{
:extra_params => '--config-file /etc/nova/nova.conf',
:cellv2_setup => true
}
end
@ -25,9 +32,9 @@ describe 'nova::db::sync_api' do
:refreshonly => 'true',
:logoutput => 'on_failure'
)
}
end
}
it { is_expected.to contain_class('nova::db::sync_cell_v2') }
end
end
@ -36,10 +43,7 @@ describe 'nova::db::sync_api' do
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({
:processorcount => 8,
:concat_basedir => '/var/lib/puppet/concat'
}))
facts.merge(OSDefaults.get_facts())
end
it_configures 'nova-dbsync-api'

View File

@ -0,0 +1,62 @@
require 'spec_helper'
describe 'nova::db::sync_cell_v2' do
shared_examples_for 'nova-db-sync-cell_v2' do
context 'with defaults' do
it {
is_expected.to contain_exec('nova-cell_v2-simple-cell-setup').with(
:command => '/usr/bin/nova-manage cell_v2 simple_cell_setup ',
:refreshonly => 'true',
:try_sleep => 5,
:tries => 10,
:logoutput => 'on_failure',
:subscribe => ['Anchor[nova::install::end]',
'Anchor[nova::config::end]',
'Anchor[nova::dbsync_api::end]',
'Anchor[nova::cell_v2::begin]'],
:notify => 'Anchor[nova::cell_v2::end]',
)
}
end
context "overriding extra_params" do
let :params do
{
:extra_params => '--config-file /etc/nova/nova.conf',
:transport_url => 'rabbit://user:pass@host:1234/virt'
}
end
it {
is_expected.to contain_exec('nova-cell_v2-simple-cell-setup').with(
:command => '/usr/bin/nova-manage --config-file /etc/nova/nova.conf cell_v2 simple_cell_setup --transport-url=rabbit://user:pass@host:1234/virt',
:refreshonly => 'true',
:try_sleep => 5,
:tries => 10,
:logoutput => 'on_failure',
:subscribe => ['Anchor[nova::install::end]',
'Anchor[nova::config::end]',
'Anchor[nova::dbsync_api::end]',
'Anchor[nova::cell_v2::begin]'],
:notify => 'Anchor[nova::cell_v2::end]',
)
}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
it_configures 'nova-db-sync-cell_v2'
end
end
end