From 1a4f02505769813c962870bfbc8a21c7c0d17e0b Mon Sep 17 00:00:00 2001 From: "Christopher H. Laco" Date: Fri, 23 May 2014 16:30:23 -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 --- attributes/default.rb | 5 ++++ recipes/neutron-server.rb | 53 +++++++++++++++++++++++---------------- 2 files changed, 36 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..27fb696 100644 --- a/recipes/neutron-server.rb +++ b/recipes/neutron-server.rb @@ -20,6 +20,7 @@ include_recipe "mysql::client" include_recipe "mysql::ruby" include_recipe "osops-utils" +include_recipe "nova-network::neutron-plugin" platform_options = node["neutron"]["platform"] @@ -34,18 +35,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 +52,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 +75,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]', :immediately +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