From 712cdf8681e6caf293e6eca35f128fef8800e9fc Mon Sep 17 00:00:00 2001 From: "Christopher H. Laco" Date: Mon, 26 May 2014 18:04:26 -0400 Subject: [PATCH] Fix for Issue 941 Process is to stamp the DB and then make a revision note indicating this is an RCBOPS deployment which is then used to ensure that the DB is NOT stamped on subsequent chef runs. This commit adds new node attr hash to the ["neutron"]["db"]["stamp"] The DB stamp will only be attempted when the RCBOPS deployment $REVISION is not found in the neutron db history. This also fixes some syntax issues we had in addition to making the recipe more legible. Issue: rcbops/chef-cookbooks#941 (cherry picked from commit ddfc0e05eb6f144e26789a3c0ccb111fe9f1b478) --- attributes/default.rb | 5 ++++ recipes/neutron-server.rb | 62 +++++++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 5db1063..784c89a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -106,6 +106,11 @@ default["neutron"]["db"]["name"] = "neutron" default["neutron"]["db"]["username"] = "neutron" +# this is set for the DB Stamp, REQUIRED in later Havana and > +default["neutron"]["db"]["stamp"]["revision"] = "havana" +default["neutron"]["db"]["stamp"]["plugin"] = "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini" +default["neutron"]["db"]["stamp"]["config"] = "/etc/neutron/neutron.conf" + default["neutron"]["service_tenant_name"] = "service" default["neutron"]["service_user"] = "neutron" default["neutron"]["service_role"] = "admin" diff --git a/recipes/neutron-server.rb b/recipes/neutron-server.rb index 8c8c7fc..7543277 100644 --- a/recipes/neutron-server.rb +++ b/recipes/neutron-server.rb @@ -22,6 +22,16 @@ include_recipe "osops-utils" platform_options = node["neutron"]["platform"] +plugin = node["neutron"]["plugin"] + +if plugin == "ovs" + platform_options["neutron_#{plugin}_packages"].each do |pkg| + package pkg do + action node["osops"]["do_package_upgrades"] == true ? :upgrade : :install + options platform_options["package_options"] + end + end +end # If we're HA if get_role_count("nova-network-controller") > 1 @@ -34,18 +44,14 @@ node.set["neutron"]["neutron_metadata_proxy_shared_secret"] = neutron["neutron_metadata_proxy_shared_secret"] else # Make some stuff up - if node["developer_mode"] == true - node.set_unless["neutron"]["db"]["password"] = - "neutron" + if node["developer_mode"] + node.set_unless["neutron"]["db"]["password"] = "neutron" else - node.set_unless["neutron"]["db"]["password"] = - secure_password + node.set_unless["neutron"]["db"]["password"] = secure_password end - node.set_unless['neutron']['service_pass'] = - secure_password - node.set_unless["neutron"]["neutron_metadata_proxy_shared_secret"] = - secure_password + node.set_unless["neutron"]["service_pass"] = secure_password + node.set_unless["neutron"]["neutron_metadata_proxy_shared_secret"] = secure_password end unless Chef::Config[:solo] @@ -55,26 +61,20 @@ # Only do this setup once the db/service pass has been set. include_recipe "nova-network::neutron-common" -packages = platform_options["neutron_api_packages"] - platform_options["neutron_api_packages"].each do |pkg| package pkg do - action node["osops"]["do_package_upgrades"] == true ? :upgrade : :install + action node["osops"]["do_package_upgrades"] ? :upgrade : :install options platform_options["package_options"] end end -ks_admin_endpoint = - get_access_endpoint("keystone-api", "keystone", "admin-api") -ks_service_endpoint = - get_access_endpoint("keystone-api", "keystone", "service-api") -keystone = - get_settings_by_role("keystone-setup", "keystone") +ks_admin_endpoint = get_access_endpoint("keystone-api", "keystone", "admin-api") +keystone = get_settings_by_role("keystone-setup", "keystone") # Create db and user # return connection info # defined in osops-utils/libraries -mysql_info = create_db_and_user( +create_db_and_user( "mysql", node["neutron"]["db"]["name"], node["neutron"]["db"]["username"], @@ -84,16 +84,34 @@ api_endpoint = get_bind_endpoint("neutron", "api") access_endpoint = get_access_endpoint("nova-network-controller", "neutron", "api") +# Get stamp hash +stamp = node["neutron"]["db"]["stamp"] + +# Add a revision +execute 'add_revision' do + command "neutron-db-manage revision -m 'RCBOPS Deployment #{stamp["revision"]}'" + action :nothing +end + +# Stamp the DB +execute 'stamp_db' do + command "neutron-db-manage --config-file #{stamp["config"]} --config-file #{stamp["plugin"]} stamp #{stamp["revision"]}" + action :run + not_if "neutron-db-manage history | grep \"RCBOPS Deployment #{stamp["revision"]}\"" + notifies :run, 'execute[add_revision]', :delayed +end + + service "neutron-server" do service_name platform_options["neutron_api_service"] supports :status => true, :restart => true - unless api_endpoint["scheme"] == "https" + if api_endpoint["scheme"] == "https" + action [:disable, :stop] + else action :enable subscribes :restart, "template[/etc/neutron/neutron.conf]", :delayed subscribes :restart, "template[/etc/neutron/api-paste.ini]", :delayed subscribes :restart, "template[/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini]", :delayed - else - action [ :disable, :stop ] end end