Adding database sync for L2 Gateway service plugin
It includes unit test Change-Id: I9f36f66eeb7aba7f37bbd53245e795f51e7faa9f Signed-off-by: Ricardo Noriega <rnoriega@redhat.com>
This commit is contained in:
@@ -28,6 +28,11 @@
|
||||
# Must be in form: <service_type>:<name>:<driver>[:default]
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*sync_db*]
|
||||
# Whether 'l2gw-db-sync' should run to create and/or synchronize the
|
||||
# database with networking-l2gw specific tables.
|
||||
# Default to false
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (optional) Ensure state for package.
|
||||
# Defaults to 'present'.
|
||||
@@ -43,6 +48,7 @@ class neutron::services::l2gw (
|
||||
$quota_l2_gateway = $::os_service_default,
|
||||
$periodic_monitoring_interval = $::os_service_default,
|
||||
$service_providers = $::os_service_default,
|
||||
$sync_db = false,
|
||||
$package_ensure = 'present',
|
||||
$purge_config = false,
|
||||
) {
|
||||
@@ -71,4 +77,19 @@ class neutron::services::l2gw (
|
||||
'DEFAULT/periodic_monitoring_interval': value => $periodic_monitoring_interval;
|
||||
'service_providers/service_provider': value => $service_providers;
|
||||
}
|
||||
|
||||
if $sync_db {
|
||||
Package<| title == $::neutron::params::l2gw_package |> ~> Exec['l2gw-db-sync']
|
||||
exec { 'l2gw-db-sync':
|
||||
command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --subproject networking-l2gw upgrade head',
|
||||
path => '/usr/bin',
|
||||
subscribe => [
|
||||
Anchor['neutron::install::end'],
|
||||
Anchor['neutron::config::end'],
|
||||
Anchor['neutron::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['neutron::dbsync::end'],
|
||||
refreshonly => true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ describe 'neutron::services::l2gw' do
|
||||
end
|
||||
|
||||
shared_examples_for 'neutron l2gw service plugin' do
|
||||
context 'with default params' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
@@ -67,13 +68,15 @@ describe 'neutron::services::l2gw' do
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/quota_l2_gateway').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/periodic_monitoring_interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_service_config('service_providers/service_provider').with_value('<SERVICE DEFAULT>')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple service providers' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
{ :service_providers => ['provider1', 'provider2'] }
|
||||
{ :service_providers => ['provider1', 'provider2'],
|
||||
:sync_db => true,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -82,6 +85,19 @@ describe 'neutron::services::l2gw' do
|
||||
'service_providers/service_provider'
|
||||
).with_value(['provider1', 'provider2'])
|
||||
end
|
||||
|
||||
it 'runs neutron-db-sync' do
|
||||
is_expected.to contain_exec('l2gw-db-sync').with(
|
||||
:command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --subproject networking-l2gw upgrade head',
|
||||
:path => '/usr/bin',
|
||||
:subscribe => ['Anchor[neutron::install::end]',
|
||||
'Anchor[neutron::config::end]',
|
||||
'Anchor[neutron::dbsync::begin]'
|
||||
],
|
||||
:notify => 'Anchor[neutron::dbsync::end]',
|
||||
:refreshonly => 'true',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,5 +121,4 @@ describe 'neutron::services::l2gw' do
|
||||
it_configures 'neutron l2gw service plugin'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user