From 2eb64fbc663bd534740a5a9cba08dea28fd7da46 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Mon, 10 Mar 2014 11:03:09 +0100 Subject: [PATCH 1/2] network/controller: execute db_sync after neutron config Bug #352 Signed-off-by: Emilien Macchi --- manifests/network/controller.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/network/controller.pp b/manifests/network/controller.pp index 35a7a6cc..28ceed4b 100644 --- a/manifests/network/controller.pp +++ b/manifests/network/controller.pp @@ -45,6 +45,7 @@ class cloud::network::controller( # Note(EmilienM): # We check if DB tables are created, if not we populate Neutron DB. # It's a hack to fit with our setup where we run MySQL/Galera + Neutron_config <| |> -> exec {'neutron_db_sync': command => '/usr/bin/neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head', unless => "/usr/bin/mysql neutron -h ${neutron_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" From f97a99c9f7b168a03b6b8c5a93e47420e09fcc42 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Mon, 10 Mar 2014 12:35:00 +0100 Subject: [PATCH 2/2] notify neutron-server when db-sync Signed-off-by: Emilien Macchi --- manifests/network/controller.pp | 6 ++++-- spec/classes/cloud_network_controller_spec.rb | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/manifests/network/controller.pp b/manifests/network/controller.pp index 28ceed4b..840ca6d1 100644 --- a/manifests/network/controller.pp +++ b/manifests/network/controller.pp @@ -45,10 +45,12 @@ class cloud::network::controller( # Note(EmilienM): # We check if DB tables are created, if not we populate Neutron DB. # It's a hack to fit with our setup where we run MySQL/Galera - Neutron_config <| |> -> + Neutron_config<| |> -> exec {'neutron_db_sync': command => '/usr/bin/neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head', - unless => "/usr/bin/mysql neutron -h ${neutron_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + unless => "/usr/bin/mysql neutron -h ${neutron_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables", + require => 'Neutron_config[DEFAULT/service_plugins]', + notify => Service['neutron-server'] } @@haproxy::balancermember{"${::fqdn}-neutron_api": diff --git a/spec/classes/cloud_network_controller_spec.rb b/spec/classes/cloud_network_controller_spec.rb index a8904938..e8a0ba9d 100644 --- a/spec/classes/cloud_network_controller_spec.rb +++ b/spec/classes/cloud_network_controller_spec.rb @@ -91,7 +91,9 @@ describe 'cloud::network::controller' do it 'checks if Neutron DB is populated' do should contain_exec('neutron_db_sync').with( :command => '/usr/bin/neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head', - :unless => '/usr/bin/mysql neutron -h 10.0.0.1 -u neutron -psecrete -e "show tables" | /bin/grep Tables' + :unless => '/usr/bin/mysql neutron -h 10.0.0.1 -u neutron -psecrete -e "show tables" | /bin/grep Tables', + :require => 'Neutron_config[DEFAULT/service_plugins]', + :notify => 'Service[neutron-server]' ) end