Migrate network database

Migrate network database like other cookbooks do (openstack-identity,
openstack-nova,openstack-image etc.). The database migration will
make the OpenStack upgrade using the cookbooks easier.

The patch passes the template_file from common.rb to server.rb using
node['openstack']['network']['plugin_config_file'].

Change-Id: I5e4ded912eaa4087714f9cb68088caf29b90b9c4
This commit is contained in:
jufeng 2014-01-17 11:44:04 +08:00
parent 66bfd98651
commit 1d9969a339
4 changed files with 23 additions and 1 deletions

View File

@ -2,6 +2,9 @@
This file is used to list changes made in each version of cookbook-openstack-network.
## 8.0.1:
* Add network database migration
## 8.0.0:
* Support neutron deployment by search and replace quantum with neutron

View File

@ -5,7 +5,7 @@ maintainer 'Jay Pipes <jaypipes@gmail.com>'
license 'Apache 2.0'
description 'Installs and configures the OpenStack Network API Service and various agents and plugins'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '8.0.0'
version '8.0.1'
recipe 'openstack-network::server', 'Installs packages required for a OpenStack Network server'
recipe 'openstack-network::openvswitch', 'Installs packages required for OVS'
recipe 'openstack-network::metadata_agent', 'Installs packages required for a OpenStack Network Metadata Agent'

View File

@ -370,6 +370,8 @@ when 'ryu'
end
node.set['openstack']['network']['plugin_config_file'] = template_file
template '/etc/default/neutron-server' do
source 'neutron-server.erb'
owner 'root'

View File

@ -40,6 +40,23 @@ platform_options['neutron_server_packages'].each do |pkg|
end
end
# Migrate network database
# If the database has never migrated, make the current version of alembic_version to havana,
# else migrate the database to latest version.
bash "migrate network database" do
plugin_config_file = node['openstack']['network']['plugin_config_file']
migrate_command = "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file #{plugin_config_file}"
code <<-EOF
current_version_line=`#{migrate_command} current 2>&1 | tail -n 1`
# determine if the $current_version_line ends with ": None"
if [[ $current_version_line == *:\\ None ]]; then
#{migrate_command} stamp havana
else
#{migrate_command} upgrade head
fi
EOF
end
service 'neutron-server' do
service_name platform_options['neutron_server_service']
supports status: true, restart: true