Support standalone services

* Do not include main plugin in server recipe and
everywhere else, so that we can manage services
with roles on independent servers
* Support an independent quantum api server not running
any of the agents or packages required by plugin
* Fix ordering issues with openvswitch-agent install.
* Try to unify platform_options names across
distributions.
* Introduce a common.rb for setting up templates
required by nearly everything, like quantum.conf.
* Plugin recipes now serve to only install any
additional components required

Change-Id: Ieb7c357baf882c9078dbdd577f53448af863c931
This commit is contained in:
Alan Meadows 2013-07-28 12:27:19 -07:00
parent 4b1920ab62
commit a45270f9fe
24 changed files with 555 additions and 454 deletions

View File

@ -234,7 +234,7 @@ default["openstack"]["network"]["openvswitch"]["tenant_network_type"] = 'local'
# All physical networks listed are available for flat and VLAN provider network
# creation. Specified ranges of VLAN IDs are available for tenant network
# allocation if tenant_network_type is 'vlan'. If empty, only gre and local
# networks may be created.
# networks may be created
#
# Example: network_vlan_ranges = physnet1:1000:2999
default["openstack"]["network"]["openvswitch"]["network_vlan_ranges"] = nil
@ -255,13 +255,12 @@ default["openstack"]["network"]["openvswitch"]["tunnel_id_ranges"] = nil
# This is the name of the OVS integration bridge. There is one per hypervisor.
# The integration bridge acts as a virtual "patch bay". All VM VIFs are
# attached to this bridge and then "patched" according to their network
# connectivity (nil uses default)
default["openstack"]["network"]["openvswitch"]["integration_bridge"] = nil
# connectivity
default["openstack"]["network"]["openvswitch"]["integration_bridge"] = 'br-int'
# Only used for the agent if tunnel_id_ranges (above) is not empty for
# the server. In most cases, the default value should be fine (nil
# uses default)
default["openstack"]["network"]["openvswitch"]["tunnel_bridge"] = nil
# the server. In most cases, the default value should be fine
default["openstack"]["network"]["openvswitch"]["tunnel_bridge"] = "br-tun"
# Peer patch port in integration bridge for tunnel bridge (nil uses default)
default["openstack"]["network"]["openvswitch"]["int_peer_patch_port"] = nil
@ -665,14 +664,19 @@ when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won't fix this
"nova_network_packages" => [ "openstack-nova-network" ],
"quantum_packages" => [ "openstack-quantum" ],
"quantum_dhcp_packages" => [ "openstack-quantum" ],
"quantum_metadata_agent_packages" => [ "quantum-metadata-agent" ],
"quantum_dhcp_build_packages" => [],
"quantum_l3_packages" => [ "quantum-l3-agent" ],
"quantum_openvswitch_packages" => ["openvswitch"],
"quantum_openvswitch_agent_packages" => ["openstack-quantum-openvswitch-agent"],
"quantum_metadata_agent_packages" => [],
"quantum_plugin_package" => "openstack-quantum-%plugin%",
"quantum_server_service" => "quantum-server",
"quantum_server_packages" => [],
"quantum_dhcp_agent_service" => "quantum-dhcp-agent",
"quantum_l3_agent_service" => "quantum-l3-agent",
"quantum_metadata_agent_service" => "quantum-metadata-agent",
"quantum_openvswitch_service" => "openvswitch",
"quantum_openvswitch_agent_service" => "openstack-quantum-openvswitch-agent",
"quantum_server_service" => "quantum-server",
"package_overrides" => ""
}
when "suse"
@ -686,14 +690,19 @@ when "suse"
"quantum_dhcp_packages" => ["openstack-quantum-dhcp-agent"],
"quantum_dhcp_build_packages" => [],
"quantum_l3_packages" => ["openstack-quantum-l3-agent"],
"quantum_plugin_package" => "openstack-quantum-%plugin%",
"quantum_openvswitch_packages" => ["openstack-quantum-openvswitch-agent"],
"quantum_metadata_agent_packages" => ["openstack-quantum-metadata-agent"],
"quantum_server_service" => "openstack-quantum",
"quantum_openvswitch_service" => "openstack-quantum-openvswitch-agent",
"quantum_openvswitch_packages" => ["openvswitch-switch"],
"quantum_openvswitch_agent_packages" => ["openstack-quantum-openvswitch-agent"],
"quantum_metadata_agent_packages" => ["openstack-quantum-metadata-agent"],
"quantum_plugin_package" => "openstack-quantum-%plugin%",
"quantum_server_packages" => [],
"quantum_dhcp_agent_service" => "openstack-quantum-dhcp-agent",
"quantum_l3_agent_service" => "openstack-quantum-l3-agent",
"quantum_metadata_agent_service" => "openstack-quantum-metadata-agent"
"quantum_metadata_agent_service" => "openstack-quantum-metadata-agent",
"quantum_openvswitch_service" => "openvswitch",
"quantum_openvswitch_agent_service" => "openstack-quantum-openvswitch-agent",
"quantum_server_service" => "openstack-quantum",
"package_overrides" => ""
}
when "ubuntu"
default["openstack"]["network"]["platform"] = {
@ -702,19 +711,23 @@ when "ubuntu"
"mysql_python_packages" => [ "python-mysqldb" ],
"postgresql_python_packages" => [ "python-psycopg2" ],
"nova_network_packages" => [ "nova-network" ],
"quantum_packages" => [ "quantum-server", "python-quantumclient", "python-pyparsing", "python-cliff" ],
"quantum_lb_packages" => ["quantum-lbaas-agent", "haproxy"],
"quantum_packages" => [ "quantum-common", "python-quantumclient", "python-pyparsing", "python-cliff" ],
"quantum_dhcp_packages" => [ "quantum-dhcp-agent" ],
"quantum_dhcp_build_packages" => [ "build-essential", "pkg-config", "libidn11-dev", "libdbus-1-dev", "libnetfilter-conntrack-dev", "gettext" ],
"quantum_l3_packages" => [ "quantum-l3-agent" ],
"quantum_plugin_package" => "quantum-plugin-%plugin%",
"quantum_openvswitch_packages" => [ "openvswitch-switch", "openvswitch-datapath-dkms", "bridge-utils" ],
"quantum_openvswitch_agent_packages" => [ "quantum-plugin-openvswitch", "quantum-plugin-openvswitch-agent" ],
"quantum_metadata_agent_packages" => [ "quantum-metadata-agent" ],
"quantum_openvswitch_service" => "openvswitch-switch",
"quantum_server_service" => "quantum-server",
"quantum_plugin_package" => "quantum-plugin-%plugin%",
"quantum_server_packages" => ["quantum-server"],
"quantum_dhcp_agent_service" => "openstack-quantum-dhcp-agent",
"quantum_dhcp_agent_service" => "quantum-dhcp-agent",
"quantum_l3_agent_service" => "quantum-l3-agent",
"quantum_metadata_agent_service" => "quantum-metadata-agent",
"quantum_openvswitch_service" => "openvswitch-switch",
"quantum_openvswitch_agent_service" => "quantum-plugin-openvswitch-agent",
"quantum_server_service" => "quantum-server",
"package_overrides" => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
}
end

View File

@ -5,6 +5,7 @@ description "Installs and configures the OpenStack Network API Service and
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "7.0.0"
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"
recipe "openstack-network::identity_registration", "Registers OpenStack Network endpoints and service user with Keystone"
@ -16,3 +17,4 @@ depends "openstack-identity", "~> 7.0"
depends "openstack-common", "~> 0.4.0"
depends "mysql"
depends "postgresql"
depends "python"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/bigswitch/restproxy.ini" do
source "plugins/bigswitch/restproxy.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/brocade/brocade.ini" do
source "plugins/brocade/brocade.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/cisco/cisco_plugins.ini" do
source "plugins/cisco/cisco_plugins.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

390
recipes/common.rb Normal file
View File

@ -0,0 +1,390 @@
#
# Cookbook Name:: openstack-network
# Recipe:: common
#
# Copyright 2013, AT&T
# Copyright 2013, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require "uri"
class ::Chef::Recipe
include ::Openstack
end
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
core_plugin = node["openstack"]["network"]["core_plugin"]
if node["openstack"]["network"]["syslog"]["use"]
include_recipe "openstack-common::logging"
end
platform_options["nova_network_packages"].each do |pkg|
package pkg do
action :purge
end
end
platform_options["quantum_packages"].each do |pkg|
package pkg do
action :install
end
end
directory "/etc/quantum/plugins" do
recursive true
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
action :create
end
directory "/var/cache/quantum" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
action :create
end
directory ::File.dirname node["openstack"]["network"]["api"]["auth"]["cache_dir"] do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
only_if { node["openstack"]["auth"]["strategy"] == "pki" }
end
# This will copy recursively all the files in
# /files/default/etc/quantum/rootwrap.d
remote_directory "/etc/quantum/rootwrap.d" do
source "etc/quantum/rootwrap.d"
files_owner node["openstack"]["network"]["platform"]["user"]
files_group node["openstack"]["network"]["platform"]["group"]
files_mode 00700
end
template "/etc/quantum/rootwrap.conf" do
source "rootwrap.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
end
template "/etc/quantum/policy.json" do
source "policy.json.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
notifies :restart, "service[quantum-server]", :delayed
end
rabbit_server_role = node["openstack"]["network"]["rabbit_server_chef_role"]
if node["openstack"]["network"]["rabbit"]["ha"]
rabbit_hosts = rabbit_servers
end
rabbit_pass = user_password node["openstack"]["network"]["rabbit"]["username"]
identity_endpoint = endpoint "identity-api"
auth_uri = ::URI.decode identity_endpoint.to_s
db_user = node["openstack"]["network"]["db"]["username"]
db_pass = db_password "quantum"
sql_connection = db_uri("network", db_user, db_pass)
api_endpoint = endpoint "network-api"
service_pass = service_password "openstack-network"
service_tenant_name = node["openstack"]["network"]["service_tenant_name"]
service_user = node["openstack"]["network"]["service_user"]
if node["openstack"]["network"]["api"]["bind_interface"].nil?
bind_address = api_endpoint.host
bind_port = api_endpoint.port
else
bind_address = address_for node["openstack"]["network"]["api"]["bind_interface"]
bind_port = node["openstack"]["network"]["api"]["bind_port"]
end
# retrieve the local interface for tunnels
if node["openstack"]["network"]["openvswitch"]["local_ip_interface"].nil?
local_ip = node["openstack"]["network"]["openvswitch"]["local_ip"]
else
local_ip = address_for node["openstack"]["network"]["openvswitch"]["local_ip_interface"]
end
# https://bugs.launchpad.net/neutron/+bug/1111572
package platform_options["quantum_python_package"] do
action :install
options platform_options["package_overrides"]
notifies :upgrade, "python_pip[python-quantumclient]", :immediately
end
if platform?("ubuntu", "debian")
include_recipe "python::pip"
end
python_pip "python-quantumclient" do
action :nothing
only_if { platform?("ubuntu", "debian") }
end
# all recipes include common.rb, and some servers
# may just be running a subset of agents (like l3_agent)
# and not the api server components, so we ignore restart
# failures here as there may be no quantum-server process
service "quantum-server" do
service_name platform_options["quantum_server_service"]
supports :status => true, :restart => true
ignore_failure true
action :nothing
end
template "/etc/quantum/quantum.conf" do
source "quantum.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:bind_address => bind_address,
:bind_port => bind_port,
:rabbit_hosts => rabbit_hosts,
:rabbit_pass => rabbit_pass,
:core_plugin => core_plugin,
:identity_endpoint => identity_endpoint,
:service_pass => service_pass
)
notifies :restart, "service[quantum-server]", :delayed
end
template "/etc/quantum/api-paste.ini" do
source "api-paste.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
"identity_endpoint" => identity_endpoint,
"service_pass" => service_pass
)
notifies :restart, "service[quantum-server]", :delayed
end
directory "/etc/quantum/plugins/#{main_plugin}" do
recursive true
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end
# For several plugins, the plugin configuration
# is required by both the quantum-server and
# ancillary services that may be on different
# physical servers like the l3 agent, so we assume
# the plugin configuration is a "common" file
template_file = nil
case main_plugin
when "bigswitch"
template_file = "/etc/quantum/plugins/bigswitch/restproxy.ini"
template "/etc/quantum/plugins/bigswitch/restproxy.ini" do
source "plugins/bigswitch/restproxy.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "brocade"
template_file = "/etc/quantum/plugins/brocade/brocade.ini"
template "/etc/quantum/plugins/brocade/brocade.ini" do
source "plugins/brocade/brocade.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "cisco"
template_file = "/etc/quantum/plugins/cisco/cisco_plugins.ini"
template "/etc/quantum/plugins/cisco/cisco_plugins.ini" do
source "plugins/cisco/cisco_plugins.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "hyperv"
template_file = "/etc/quantum/plugins/hyperv/hyperv_quantum_plugin.ini.erb"
template "/etc/quantum/plugins/hyperv/hyperv_quantum_plugin.ini.erb" do
source "plugins/hyperv/hyperv_quantum_plugin.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "linuxbridge"
template_file = "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini"
template "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini" do
source "plugins/linuxbridge/linuxbridge_conf.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "midonet"
template_file = "/etc/quantum/plugins/metaplugin/metaplugin.ini"
template "/etc/quantum/plugins/metaplugin/metaplugin.ini" do
source "plugins/metaplugin/metaplugin.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "nec"
template_file = "/etc/quantum/plugins/nec/nec.ini"
template "/etc/quantum/plugins/nec/nec.ini" do
source "plugins/nec/nec.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "nicira"
template_file = "/etc/quantum/plugins/nicira/nvp.ini"
template "/etc/quantum/plugins/nicira/nvp.ini" do
source "plugins/nicira/nvp.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "openvswitch"
template_file = "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"
service "quantum-plugin-openvswitch-agent" do
service_name platform_options["quantum_openvswitch_agent_service"]
action :nothing
end
template "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini" do
source "plugins/openvswitch/ovs_quantum_plugin.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection,
:local_ip => local_ip
)
notifies :restart, "service[quantum-server]", :delayed
notifies :restart, "service[quantum-plugin-openvswitch-agent]", :delayed
end
when "plumgrid"
template_file = "/etc/quantum/plugins/plumgrid/plumgrid.ini"
template "/etc/quantum/plugins/plumgrid/plumgrid.ini" do
source "plugins/plumgrid/plumgrid.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
when "ryu"
template_file = "/etc/quantum/plugins/ryu/ryu.ini"
template "/etc/quantum/plugins/ryu/ryu.ini" do
source "plugins/ryu/ryu.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :delayed
end
end
template "/etc/default/quantum-server" do
source "quantum-server.erb"
owner "root"
group "root"
mode 00644
variables(
:plugin_config => template_file
)
only_if {
node.run_list.expand(node.chef_environment).recipes.include?("openstack-network::server")
platform?(%w{ubuntu debian})
}
end

View File

@ -17,25 +17,12 @@
# limitations under the License.
#
include_recipe "openstack-network::common"
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
# This will copy recursively all the files in
# /files/default/etc/quantum/rootwrap.d
remote_directory "/etc/quantum/rootwrap.d" do
source "etc/quantum/rootwrap.d"
files_owner node["openstack"]["network"]["platform"]["user"]
files_group node["openstack"]["network"]["platform"]["group"]
files_mode 00700
end
directory "/etc/quantum/plugins" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end
platform_options["quantum_dhcp_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
@ -57,8 +44,6 @@ package platform_options["quantum_plugin_package"].gsub("%plugin%", main_plugin)
action :install
end
include_recipe "openstack-network::#{main_plugin}"
execute "quantum-dhcp-setup --plugin #{main_plugin}" do
only_if { platform?(%w(fedora redhat centos)) } # :pragma-foodcritic: ~FC024 - won't fix this
end

View File

@ -17,16 +17,4 @@
# limitations under the License.
#
#(alanmeadows) TODO
#FC033: Missing template: .cookbooks/openstack-network/recipes/hyperv.rb:20
#template "/etc/quantum/plugins/hyperv/hyperv_quantum_plugin.ini" do
# source "plugins/hyperv/hyperv_quantum__plugin.ini.erb"
# owner node["openstack"]["network"]["platform"]["user"]
# group node["openstack"]["network"]["platform"]["group"]
# mode 00644
# variables(
# :sql_connection => sql_connection
# )
#
# notifies :restart, "service[quantum-server]", :immediately
#end
include_recipe "openstack-network::common"

View File

@ -17,24 +17,12 @@
# limitations under the License.
#
include_recipe "openstack-network::common"
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
# This will copy recursively all the files in
# /files/default/etc/quantum/rootwrap.d
remote_directory "/etc/quantum/rootwrap.d" do
files_owner node["openstack"]["network"]["platform"]["user"]
files_group node["openstack"]["network"]["platform"]["group"]
files_mode 00700
end
directory "/etc/quantum/plugins" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end
platform_options["quantum_l3_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
@ -51,13 +39,6 @@ service "quantum-l3-agent" do
action :enable
end
package platform_options["quantum_plugin_package"].gsub("%plugin%", main_plugin) do
options platform_options["package_overrides"]
action :install
end
include_recipe "openstack-network::#{main_plugin}"
execute "quantum-l3-setup --plugin #{main_plugin}" do
only_if {
platform?(%w(fedora redhat centos)) and not # :pragma-foodcritic: ~FC024 - won't fix this

View File

@ -17,39 +17,4 @@
# limitations under the License.
#
db_user = node["openstack"]["network"]["db"]["username"]
db_pass = db_password "quantum"
sql_connection = db_uri("network", db_user, db_pass)
service "quantum-server" do
service_name node["openstack"]["network"]["platform"]["quantum_server_service"]
supports :status => true, :restart => true
action :nothing
end
template "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini" do
source "plugins/linuxbridge/linuxbridge_conf.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
# Ubuntu packaging currently does not update the quantum init script to point to
# linuxbridge config file. Manual update /etc/default/quantum-server is required.
template "/etc/default/quantum-server" do
source "quantum-server.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00600
variables(
:plugin_config => "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini"
)
notifies :restart, "service[quantum-server]", :immediately
only_if { platform? %w{ubuntu debian} }
end
include_recipe "openstack-network::common"

View File

@ -17,25 +17,12 @@
# limitations under the License.
#
include_recipe "openstack-network::common"
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
# This will copy recursively all the files in
# /files/default/etc/quantum/rootwrap.d
remote_directory "/etc/quantum/rootwrap.d" do
files_owner node["openstack"]["network"]["platform"]["user"]
files_group node["openstack"]["network"]["platform"]["group"]
files_mode 00700
action :nothing
end
directory "/etc/quantum/plugins" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end
identity_endpoint = endpoint "identity-api"
service_pass = service_password "openstack-network"
metadata_secret = secret "secrets", node["openstack"]["network"]["metadata"]["secret_name"]

View File

@ -17,16 +17,4 @@
# limitations under the License.
#
# (alanmeadows): TODO
# FC033: Missing template: .cookbooks/openstack-network/recipes/metaplugin.rb:20
# template "/etc/quantum/plugins/metaplugin/metaplugin_plugins.ini" do
# source "plugins/metaplugin/metaplugin_plugins.ini.erb"
# owner node["openstack"]["network"]["platform"]["user"]
# group node["openstack"]["network"]["platform"]["group"]
# mode 00644
# variables(
# :sql_connection => sql_connection
# )
#
# notifies :restart, "service[quantum-server]", :immediately
# end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/midonet/midonet.ini" do
source "plugins/midonet/midonet.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/nec/nec.ini" do
source "plugins/nec/nec.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/nicira/nvp.ini" do
source "plugins/nicira/nvp.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -23,12 +23,12 @@ class ::Chef::Recipe
include ::Openstack
end
platform_options = node["openstack"]["network"]["platform"]
include_recipe "openstack-network::common"
# discover database attributes
db_user = node["openstack"]["network"]["db"]["username"]
db_pass = db_password "quantum"
sql_connection = db_uri("network", db_user, db_pass)
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
core_plugin = node["openstack"]["network"]["core_plugin"]
if platform?("ubuntu", "debian")
@ -54,33 +54,48 @@ service "quantum-openvswitch-switch" do
action :enable
end
execute "quantum-node-setup --plugin openvswitch" do
only_if { platform?(%w(fedora redhat centos)) } # :pragma-foodcritic: ~FC024 - won't fix this
end
# retrieve the local interface for tunnels
if node["openstack"]["network"]["openvswitch"]["local_ip_interface"]
local_ip = address_for node["openstack"]["network"]["openvswitch"]["local_ip_interface"]
else
local_ip = node["openstack"]["network"]["openvswitch"]["local_ip"]
end
service "quantum-server" do
service_name platform_options["quantum_server_service"]
supports :status => true, :restart => true
ignore_failure true
action :nothing
end
template "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini" do
source "plugins/openvswitch/ovs_quantum_plugin.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection,
:local_ip => local_ip
)
notifies :restart, "service[quantum-server]", :immediately
platform_options["quantum_openvswitch_agent_packages"].each do |pkg|
package pkg do
action :install
options platform_options["package_overrides"]
end
end
service "quantum-plugin-openvswitch-agent" do
service_name platform_options["quantum_openvswitch_agent_service"]
supports :status => true, :restart => true
action :enable
end
execute "quantum-node-setup --plugin openvswitch" do
only_if { platform?(%w(fedora redhat centos)) } # :pragma-foodcritic: ~FC024 - won't fix this
end
if not ["nicira", "plumgrid", "bigswitch"].include?(main_plugin)
int_bridge = node["openstack"]["network"]["openvswitch"]["integration_bridge"]
execute "create internal network bridge" do
ignore_failure true
command "ovs-vsctl add-br #{int_bridge}"
action :run
not_if "ovs-vsctl show | grep 'Bridge #{int_bridge}'"
notifies :restart, "service[quantum-plugin-openvswitch-agent]", :delayed
end
end
if not ["nicira", "plumgrid", "bigswitch"].include?(main_plugin)
tun_bridge = node["openstack"]["network"]["openvswitch"]["tunnel_bridge"]
execute "create tunnel network bridge" do
ignore_failure true
command "ovs-vsctl add-br #{tun_bridge}"
action :run
not_if "ovs-vsctl show | grep 'Bridge #{tun_bridge}'"
notifies :restart, "service[quantum-plugin-openvswitch-agent]", :delayed
end
end

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/plumgrid/plumgrid.ini" do
source "plugins/plumgrid/plumgrid.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -17,14 +17,4 @@
# limitations under the License.
#
template "/etc/quantum/plugins/ryu/ryu.ini" do
source "plugins/ryu/ryu.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:sql_connection => sql_connection
)
notifies :restart, "service[quantum-server]", :immediately
end
include_recipe "openstack-network::common"

View File

@ -18,56 +18,22 @@
# limitations under the License.
#
require "uri"
class ::Chef::Recipe
include ::Openstack
end
include_recipe "openstack-network::common"
platform_options = node["openstack"]["network"]["platform"]
driver_name = node["openstack"]["network"]["interface_driver"].split('.').last.downcase
main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name]
core_plugin = node["openstack"]["network"]["core_plugin"]
if node["openstack"]["network"]["syslog"]["use"]
include_recipe "openstack-common::logging"
end
platform_options = node["openstack"]["network"]["platform"]
platform_options["nova_network_packages"].each do |pkg|
package pkg do
action :purge
end
end
db_type = node["openstack"]["db"]["network"]["db_type"]
platform_options["#{db_type}_python_packages"].each do |pkg|
package pkg do
action :install
end
end
platform_options["quantum_packages"].each do |pkg|
package pkg do
action :install
end
end
platform_options["quantum_l3_packages"].each do |pkg|
package pkg do
action :install
end
end
platform_options["quantum_dhcp_packages"].each do |pkg|
package pkg do
action :install
end
end
platform_options["quantum_metadata_agent_packages"].each do |pkg|
platform_options["quantum_server_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
action :install
end
end
@ -75,144 +41,5 @@ end
service "quantum-server" do
service_name platform_options["quantum_server_service"]
supports :status => true, :restart => true
action :enable
end
service "quantum-l3-agent" do
service_name platform_options["quantum_l3_agent_service"]
supports :status => true, :restart => true
# The providers below do not use the generic L3 agent...
not_if { ["nicira", "plumgrid", "bigswitch"].include?(main_plugin) }
action :enable
end
service "quantum-dhcp-agent" do
service_name platform_options["quantum_dhcp_agent_service"]
supports :status => true, :restart => true
action :enable
end
service "quantum-metadata-agent" do
service_name platform_options["quantum_metadata_agent_service"]
supports :status => true, :restart => true
action :enable
end
# This will copy recursively all the files in
# /files/default/etc/quantum/rootwrap.d
remote_directory "/etc/quantum/rootwrap.d" do
source "etc/quantum/rootwrap.d"
files_owner node["openstack"]["network"]["platform"]["user"]
files_group node["openstack"]["network"]["platform"]["group"]
files_mode 00700
end
directory "/etc/quantum/plugins" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end
directory ::File.dirname node["openstack"]["network"]["api"]["auth"]["cache_dir"] do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
only_if { node["openstack"]["auth"]["strategy"] == "pki" }
end
template "/etc/quantum/policy.json" do
source "policy.json.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
notifies :restart, "service[quantum-server]", :immediately
end
rabbit_server_role = node["openstack"]["network"]["rabbit_server_chef_role"]
if node["openstack"]["network"]["rabbit"]["ha"]
rabbit_hosts = rabbit_servers
end
rabbit_pass = user_password node["openstack"]["network"]["rabbit"]["username"]
identity_endpoint = endpoint "identity-api"
auth_uri = ::URI.decode identity_endpoint.to_s
db_user = node["openstack"]["network"]["db"]["username"]
db_pass = db_password "quantum"
sql_connection = db_uri("network", db_user, db_pass)
api_endpoint = endpoint "network-api"
service_pass = service_password "openstack-network"
service_tenant_name = node["openstack"]["network"]["service_tenant_name"]
service_user = node["openstack"]["network"]["service_user"]
if node["openstack"]["network"]["api"]["bind_interface"].nil?
bind_address = api_endpoint.host
bind_port = api_endpoint.port
else
bind_address = address_for node["openstack"]["network"]["api"]["bind_interface"]
bind_port = node["openstack"]["network"]["api"]["bind_port"]
end
# Here is where we set up the appropriate plugin INI files
# for the L2 and L3 drivers...
# Install the plugin's Python package
node["openstack"]["network"]["plugins"].each do |pkg|
plugin_fmt = platform_options["quantum_plugin_package"]
pkg = plugin_fmt.gsub("%plugin%", pkg)
package pkg do
action :install
# on SUSE, all plugins get installed by default with the main
# openstack-quantum package
not_if { platform_family? "suse" }
end
end
begin
include_recipe "openstack-network::#{main_plugin}"
rescue Chef::Exceptions::RecipeNotFound
Chef::Log.warn "Could not find recipe openstack-network::#{main_plugin} for inclusion"
end
template "/etc/quantum/quantum.conf" do
source "quantum.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:bind_address => bind_address,
:bind_port => bind_port,
:rabbit_pass => rabbit_pass,
:rabbit_hosts => rabbit_hosts,
:core_plugin => core_plugin,
:identity_endpoint => identity_endpoint,
:service_pass => service_pass
)
notifies :restart, "service[quantum-server]", :immediately
end
template "/etc/quantum/api-paste.ini" do
source "api-paste.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00644
variables(
:identity_endpoint => identity_endpoint,
:service_pass => service_pass
)
notifies :restart, "service[quantum-server]", :immediately
end
directory "/var/cache/quantum" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
mode 00700
end

View File

@ -5,7 +5,9 @@ describe 'openstack-network::linuxbridge' do
describe "ubuntu" do
before do
quantum_stubs
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["network"]["interface_driver"] = "quantum.agent.linux.interface.BridgeInterfaceDriver"
end
@chef_run.converge "openstack-network::linuxbridge"
end
@ -28,25 +30,5 @@ describe 'openstack-network::linuxbridge' do
@file.name, "mysql://quantum:quantum-pass@127.0.0.1:3306/quantum")
end
end
describe "/etc/default/quantum-server" do
before do
@file = @chef_run.template(
"/etc/default/quantum-server")
end
it "has proper owner" do
expect(@file).to be_owned_by "quantum", "quantum"
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "600"
end
it "has a correct plugin config path" do
expect(@chef_run).to create_file_with_content(
@file.name, "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini")
end
end
end
end

View File

@ -25,6 +25,12 @@ describe 'openstack-network::openvswitch' do
it "sets the openvswitch service to start on boot" do
expect(@chef_run).to set_service_to_start_on_boot 'openvswitch-switch'
end
it "installs openvswitch agent" do
expect(@chef_run).to install_package "quantum-plugin-openvswitch-agent"
end
it "sets the openvswitch service to start on boot" do
expect(@chef_run).to set_service_to_start_on_boot "quantum-plugin-openvswitch-agent"
end
describe "ovs_quantum_plugin.ini" do
@ -49,12 +55,12 @@ describe 'openstack-network::openvswitch' do
/^tunnel_id_ranges =/
end
it "uses default integration_bridge" do
expect(@chef_run).not_to create_file_with_content @file.name,
/^integration_bridge =/
expect(@chef_run).to create_file_with_content @file.name,
"integration_bridge = br-int"
end
it "uses default tunnel bridge" do
expect(@chef_run).not_to create_file_with_content @file.name,
/^tunnel_bridge =/
expect(@chef_run).to create_file_with_content @file.name,
"tunnel_bridge = br-tun"
end
it "uses default int_peer_patch_port" do
expect(@chef_run).not_to create_file_with_content @file.name,

View File

@ -0,0 +1,28 @@
require_relative "spec_helper"
describe 'openstack-network::server' do
describe "redhat" do
before do
quantum_stubs
@chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS
@node = @chef_run.node
@chef_run.converge "openstack-network::server"
end
it "installs openstack-quantum packages" do
expect(@chef_run).to install_package "openstack-quantum"
end
it "enables openstack-quantum server service" do
expect(@chef_run).to enable_service "quantum-server"
end
it "does not install openvswitch package" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.converge "openstack-network::server"
expect(chef_run).not_to install_package "openvswitch"
expect(chef_run).not_to enable_service "openstack-quantum-openvswitch-agent"
end
end
end

View File

@ -11,18 +11,20 @@ describe 'openstack-network::server' do
@chef_run.converge "openstack-network::server"
end
describe "package and servicess" do
describe "package and services" do
it "installs quantum packages" do
expect(@chef_run).to install_package "quantum-server"
end
it "installs metadata packages" do
expect(@chef_run).to install_package "quantum-metadata-agent"
it "starts server service" do
expect(@chef_run).to enable_service "quantum-server"
end
it "starts metadata service" do
expect(@chef_run).to enable_service "quantum-metadata-agent"
it "does not install openvswitch package or the agent" do
expect(@chef_run).not_to install_package "openvswitch"
expect(@chef_run).not_to install_package "quantum-plugin-openvswitch-agent"
expect(@chef_run).not_to enable_service "quantum-plugin-openvswitch-agent"
end
end
@ -156,5 +158,26 @@ describe 'openstack-network::server' do
"rabbit_port=5672"
end
end
describe "/etc/default/quantum-server" do
before do
@file = @chef_run.template(
"/etc/default/quantum-server")
end
it "has proper owner" do
expect(@file).to be_owned_by "root", "root"
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
end
it "has a correct plugin config path" do
expect(@chef_run).to create_file_with_content(
@file.name, "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini")
end
end
end
end

View File

@ -1,3 +1,4 @@
<%= node["openstack"]["network"]["custom_template_banner"] %>
# defaults for quantum-server
# path to config file corresponding to the core_plugin specified in