Skip to content

Commit

Permalink
Fix for Issue 941
Browse files Browse the repository at this point in the history
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
  • Loading branch information
claco committed May 23, 2014
1 parent 811687e commit 1a4f025
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
5 changes: 5 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
53 changes: 31 additions & 22 deletions recipes/neutron-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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]
Expand All @@ -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"],
Expand All @@ -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

Expand Down

0 comments on commit 1a4f025

Please sign in to comment.