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]
|
# Must be in form: <service_type>:<name>:<driver>[:default]
|
||||||
# Defaults to $::os_service_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*]
|
# [*package_ensure*]
|
||||||
# (optional) Ensure state for package.
|
# (optional) Ensure state for package.
|
||||||
# Defaults to 'present'.
|
# Defaults to 'present'.
|
||||||
@@ -43,6 +48,7 @@ class neutron::services::l2gw (
|
|||||||
$quota_l2_gateway = $::os_service_default,
|
$quota_l2_gateway = $::os_service_default,
|
||||||
$periodic_monitoring_interval = $::os_service_default,
|
$periodic_monitoring_interval = $::os_service_default,
|
||||||
$service_providers = $::os_service_default,
|
$service_providers = $::os_service_default,
|
||||||
|
$sync_db = false,
|
||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
$purge_config = false,
|
$purge_config = false,
|
||||||
) {
|
) {
|
||||||
@@ -71,4 +77,19 @@ class neutron::services::l2gw (
|
|||||||
'DEFAULT/periodic_monitoring_interval': value => $periodic_monitoring_interval;
|
'DEFAULT/periodic_monitoring_interval': value => $periodic_monitoring_interval;
|
||||||
'service_providers/service_provider': value => $service_providers;
|
'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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'neutron::services::l2gw' do
|
describe 'neutron::services::l2gw' do
|
||||||
|
|
||||||
let :pre_condition do
|
let :pre_condition do
|
||||||
"class { '::neutron::keystone::authtoken':
|
"class { '::neutron::keystone::authtoken':
|
||||||
password => 'passw0rd',
|
password => 'passw0rd',
|
||||||
}
|
}
|
||||||
@@ -43,37 +43,40 @@ describe 'neutron::services::l2gw' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'neutron l2gw service plugin' do
|
shared_examples_for 'neutron l2gw service plugin' do
|
||||||
let :p do
|
context 'with default params' do
|
||||||
default_params.merge(params)
|
let :p do
|
||||||
end
|
default_params.merge(params)
|
||||||
|
end
|
||||||
|
|
||||||
it 'passes purge to resource' do
|
it 'passes purge to resource' do
|
||||||
is_expected.to contain_resources('neutron_l2gw_service_config').with({
|
is_expected.to contain_resources('neutron_l2gw_service_config').with({
|
||||||
:purge => false
|
:purge => false
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should contain python-networking-l2gw package' do
|
it 'should contain python-networking-l2gw package' do
|
||||||
is_expected.to contain_package('python-networking-l2gw').with({ :ensure => 'present' })
|
is_expected.to contain_package('python-networking-l2gw').with({ :ensure => 'present' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'services_provider with default parameter' do
|
it 'services_provider with default parameter' do
|
||||||
is_expected.to contain_neutron_l2gw_service_config('service_providers/service_provider').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_neutron_l2gw_service_config('service_providers/service_provider').with_value('<SERVICE DEFAULT>')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures l2gw_plugin.ini' do
|
|
||||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_interface_name').with_value(p[:default_interface_name])
|
|
||||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_device_name').with_value('<SERVICE DEFAULT>')
|
|
||||||
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>')
|
|
||||||
|
|
||||||
|
it 'configures l2gw_plugin.ini' do
|
||||||
|
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_interface_name').with_value(p[:default_interface_name])
|
||||||
|
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_device_name').with_value('<SERVICE DEFAULT>')
|
||||||
|
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
|
end
|
||||||
|
|
||||||
context 'with multiple service providers' do
|
context 'with multiple service providers' do
|
||||||
before :each do
|
before :each do
|
||||||
params.merge!(
|
params.merge!(
|
||||||
{ :service_providers => ['provider1', 'provider2'] }
|
{ :service_providers => ['provider1', 'provider2'],
|
||||||
|
:sync_db => true,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,6 +85,19 @@ describe 'neutron::services::l2gw' do
|
|||||||
'service_providers/service_provider'
|
'service_providers/service_provider'
|
||||||
).with_value(['provider1', 'provider2'])
|
).with_value(['provider1', 'provider2'])
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -105,5 +121,4 @@ describe 'neutron::services::l2gw' do
|
|||||||
it_configures 'neutron l2gw service plugin'
|
it_configures 'neutron l2gw service plugin'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user