rubocop compliance

all cops now pass except for the following
(which are silenced in .rubocop.yml )

* LineLength, MethodLength: not sure if we care about these
* WordArray: I prefer [] vs %w{} for readability.

Conflicts:
	metadata.rb
	recipes/common.rb
	recipes/openvswitch.rb
	spec/openvswitch_spec.rb

Change-Id: I92996b5db9f292e9ba93c7619ca727ffa92ddd71
This commit is contained in:
Paul Czarkowski 2014-01-13 13:43:47 -06:00
parent 83284ac63d
commit 61d2267d75
43 changed files with 1373 additions and 1411 deletions

View File

@ -1,81 +0,0 @@
# This configuration was generated by `rubocop --auto-gen-config`.
# The point is for the user to remove these configuration records
# one by one as the offences are removed from the code base.
AndOr:
Enabled: false
BlockAlignment:
Enabled: false
Blocks:
Enabled: false
BracesAroundHashParameters:
Enabled: false
Documentation:
Enabled: false
DotPosition:
Enabled: false
EmptyLines:
Enabled: false
EmptyLinesAroundBody:
Enabled: false
EmptyLiteral:
Enabled: false
Encoding:
Enabled: false
FavorUnlessOverNegatedIf:
Enabled: false
HashSyntax:
Enabled: false
IfUnlessModifier:
Enabled: false
IndentationWidth:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Enabled: false
Not:
Enabled: false
NumericLiterals:
Enabled: false
RegexpLiteral:
Enabled: false
SpaceAfterComma:
Enabled: false
SpaceInsideBrackets:
Enabled: false
SpaceInsideHashLiteralBraces:
Enabled: false
StringLiterals:
Enabled: false
UselessAssignment:
Enabled: false
Void:
Enabled: false
WordArray:
Enabled: false

View File

@ -1,3 +1,8 @@
AllCops:
Includes:
- Gemfile
- metadata.rb
# UTF-8 headers not generally in these files
Encoding:
Enabled: false
@ -5,3 +10,11 @@ Encoding:
# ignore long lines
LineLength:
Enabled: false
# ignore long methods
MethodLength:
Enabled: false
# ignore word arrays
WordArray:
Enabled: false

View File

@ -23,7 +23,7 @@
"locked_version": "3.3.4"
},
"apt": {
"locked_version": "2.3.0"
"locked_version": "2.3.4"
},
"build-essential": {
"locked_version": "1.4.2"

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
# Encoding: utf-8
name 'openstack-network'
maintainer 'Jay Pipes <jaypipes@gmail.com>'
license 'Apache 2.0'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: balancer
@ -20,31 +21,31 @@
# This recipe should be placed in the run_list of the node that
# runs the network server or network controller server.
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
platform_options = node["openstack"]["network"]["platform"]
platform_options = node['openstack']['network']['platform']
service "neutron-server" do
service_name platform_options["neutron_server_service"]
supports :status => true, :restart => true
service 'neutron-server' do
service_name platform_options['neutron_server_service']
supports status: true, restart: true
action :nothing
end
platform_options["neutron_lb_packages"].each do |pkg|
package pkg do
action :install
end
platform_options['neutron_lb_packages'].each do |pkg|
package pkg do
action :install
end
end
directory node["openstack"]["network"]["lbaas_config_path"] do
directory node['openstack']['network']['lbaas_config_path'] do
action :create
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
recursive true
end
template "#{node["openstack"]["network"]["lbaas_config_path"]}/lbaas_agent.ini" do
source "lbaas_agent.ini.erb"
notifies :restart, "service[neutron-server]", :immediately
source 'lbaas_agent.ini.erb'
notifies :restart, 'service[neutron-server]', :immediately
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: bigswitch
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: brocade
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: build_openvswitch_source
@ -17,11 +18,11 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
platform_options = node["openstack"]["network"]["platform"]
platform_options = node['openstack']['network']['platform']
platform_options["neutron_openvswitch_build_packages"].each do |pkg|
platform_options['neutron_openvswitch_build_packages'].each do |pkg|
package pkg do
action :install
end
@ -41,7 +42,7 @@ remote_file src_filepath do
not_if { ::File.exists?("#{Chef::Config['file_cache_path']}/#{ovs_options['openvswitch_filename']}") }
end
bash "disable_openvswitch_before_upgrade" do
bash 'disable_openvswitch_before_upgrade' do
cwd '/tmp'
not_if "dpkg -l | grep openvswitch-switch | grep #{ovs_options['openvswitch_dpkgversion']}"
code <<-EOH
@ -65,34 +66,34 @@ bash 'extract_package' do
tar xzf #{src_filename} -C #{extract_path}
cd #{extract_path}/#{ovs_options['openvswitch_base_filename']}
DEB_BUILD_OPTIONS='parallel=8' fakeroot debian/rules binary
EOH
not_if "dpkg -l | grep openvswitch-switch | grep #{ovs_options['openvswitch_dpkgversion']}"
notifies :install, "dpkg_package[openvswitch-common]", :immediately
notifies :install, "dpkg_package[openvswitch-datapath-dkms]", :immediately
notifies :install, "dpkg_package[openvswitch-pki]", :immediately
notifies :install, "dpkg_package[openvswitch-switch]", :immediately
EOH
not_if "dpkg -l | grep openvswitch-switch | grep #{ovs_options['openvswitch_dpkgversion']}"
notifies :install, 'dpkg_package[openvswitch-common]', :immediately
notifies :install, 'dpkg_package[openvswitch-datapath-dkms]', :immediately
notifies :install, 'dpkg_package[openvswitch-pki]', :immediately
notifies :install, 'dpkg_package[openvswitch-switch]', :immediately
end
dpkg_package "openvswitch-common" do
dpkg_package 'openvswitch-common' do
source "#{extract_path}/openvswitch-common_#{ovs_options['openvswitch_dpkgversion']}_#{ovs_options['openvswitch_architecture']}.deb"
action :nothing
end
dpkg_package "openvswitch-common" do
dpkg_package 'openvswitch-common' do
source "#{extract_path}/openvswitch-common_#{ovs_options['openvswitch_dpkgversion']}_#{ovs_options['openvswitch_architecture']}.deb"
action :nothing
end
dpkg_package "openvswitch-datapath-dkms" do
dpkg_package 'openvswitch-datapath-dkms' do
source "#{extract_path}/openvswitch-datapath-dkms_#{ovs_options['openvswitch_dpkgversion']}_all.deb"
action :nothing
end
dpkg_package "openvswitch-pki" do
dpkg_package 'openvswitch-pki' do
source "#{extract_path}/openvswitch-pki_#{ovs_options['openvswitch_dpkgversion']}_all.deb"
action :nothing
end
dpkg_package "openvswitch-switch" do
dpkg_package 'openvswitch-switch' do
source "#{extract_path}/openvswitch-switch_#{ovs_options['openvswitch_dpkgversion']}_#{ovs_options['openvswitch_architecture']}.deb"
action :nothing
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: cisco
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: common
@ -19,31 +20,32 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
require "uri"
require 'uri'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
end
platform_options = node["openstack"]["network"]["platform"]
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"]
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"
if node['openstack']['network']['syslog']['use']
include_recipe 'openstack-common::logging'
end
platform_options["nova_network_packages"].each do |pkg|
platform_options['nova_network_packages'].each do |pkg|
package pkg do
action :purge
end
end
platform_options["neutron_packages"].each do |pkg|
platform_options['neutron_packages'].each do |pkg|
package pkg do
action :install
end
@ -56,85 +58,80 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
end
end
directory "/etc/neutron/plugins" do
directory '/etc/neutron/plugins' do
recursive true
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00700
action :create
end
directory "/var/cache/neutron" do
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
directory '/var/cache/neutron' 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"]
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" }
only_if { node['openstack']['auth']['strategy'] == 'pki' }
end
template "/etc/neutron/rootwrap.conf" do
source "rootwrap.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/rootwrap.conf' do
source 'rootwrap.conf.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
end
template "/etc/neutron/policy.json" do
source "policy.json.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/policy.json' do
source 'policy.json.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
if node["openstack"]["network"]["mq"]["service_type"] == "rabbitmq"
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"]
if node['openstack']['network']['mq']['service_type'] == 'rabbitmq'
rabbit_hosts = rabbit_servers if node['openstack']['network']['rabbit']['ha']
rabbit_pass = user_password node['openstack']['network']['rabbit']['username']
end
identity_endpoint = endpoint "identity-api"
identity_admin_endpoint = endpoint "identity-admin"
identity_endpoint = endpoint 'identity-api'
identity_admin_endpoint = endpoint 'identity-admin'
auth_uri = ::URI.decode identity_endpoint.to_s
db_user = node["openstack"]["network"]["db"]["username"]
db_pass = db_password "neutron"
sql_connection = db_uri("network", db_user, db_pass)
db_user = node['openstack']['network']['db']['username']
db_pass = db_password 'neutron'
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"]
api_endpoint = endpoint 'network-api'
service_pass = service_password 'openstack-network'
if node["openstack"]["network"]["api"]["bind_interface"].nil?
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"]
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"]
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"]
local_ip = address_for node['openstack']['network']['openvswitch']['local_ip_interface']
end
platform_options["neutron_client_packages"].each do |pkg|
platform_options['neutron_client_packages'].each do |pkg|
package pkg do
action :upgrade
options platform_options["package_overrides"]
options platform_options['package_overrides']
end
end
@ -142,51 +139,51 @@ end
# 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 neutron-server process
service "neutron-server" do
service_name platform_options["neutron_server_service"]
supports :status => true, :restart => true
service 'neutron-server' do
service_name platform_options['neutron_server_service']
supports status: true, restart: true
ignore_failure true
action :nothing
end
template "/etc/neutron/neutron.conf" do
source "neutron.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/neutron.conf' do
source 'neutron.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
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[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
template "/etc/neutron/api-paste.ini" do
source "api-paste.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/api-paste.ini' do
source 'api-paste.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00640
variables(
"auth_uri" => auth_uri,
"identity_admin_endpoint" => identity_admin_endpoint,
"identity_endpoint" => identity_endpoint,
"service_pass" => service_pass
'auth_uri' => auth_uri,
'identity_admin_endpoint' => identity_admin_endpoint,
'identity_endpoint' => identity_endpoint,
'service_pass' => service_pass
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
directory "/etc/neutron/plugins/#{main_plugin}" do
recursive true
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00700
end
@ -199,193 +196,190 @@ end
template_file = nil
case main_plugin
when "bigswitch"
when 'bigswitch'
template_file = "/etc/neutron/plugins/bigswitch/restproxy.ini"
template "/etc/neutron/plugins/bigswitch/restproxy.ini" do
source "plugins/bigswitch/restproxy.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template_file = '/etc/neutron/plugins/bigswitch/restproxy.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when "brocade"
when 'brocade'
template_file = "/etc/neutron/plugins/brocade/brocade.ini"
template "/etc/neutron/plugins/brocade/brocade.ini" do
source "plugins/brocade/brocade.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template_file = '/etc/neutron/plugins/brocade/brocade.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when "cisco"
when 'cisco'
template_file = "/etc/neutron/plugins/cisco/cisco_plugins.ini"
template "/etc/neutron/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"]
template_file = '/etc/neutron/plugins/cisco/cisco_plugins.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when "hyperv"
when 'hyperv'
template_file = "/etc/neutron/plugins/hyperv/hyperv_neutron_plugin.ini.erb"
template "/etc/neutron/plugins/hyperv/hyperv_neutron_plugin.ini.erb" do
source "plugins/hyperv/hyperv_neutron_plugin.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template_file = '/etc/neutron/plugins/hyperv/hyperv_neutron_plugin.ini.erb'
template '/etc/neutron/plugins/hyperv/hyperv_neutron_plugin.ini.erb' do
source 'plugins/hyperv/hyperv_neutron_plugin.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
variables(
:sql_connection => sql_connection
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when "linuxbridge"
when 'linuxbridge'
template_file = "/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini"
template "/etc/neutron/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"]
template_file = '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
if node.run_list.expand(node.chef_environment).recipes.include?("openstack-network::linuxbridge")
notifies :restart, "service[neutron-plugin-linuxbridge-agent]", :delayed
end
end
when "midonet"
template_file = "/etc/neutron/plugins/metaplugin/metaplugin.ini"
template "/etc/neutron/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[neutron-server]", :delayed
end
when "nec"
template_file = "/etc/neutron/plugins/nec/nec.ini"
template "/etc/neutron/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[neutron-server]", :delayed
end
when "nicira"
template_file = "/etc/neutron/plugins/nicira/nvp.ini"
template "/etc/neutron/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[neutron-server]", :delayed
end
when "openvswitch"
template_file = "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
template "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini" do
source "plugins/openvswitch/ovs_neutron_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[neutron-server]", :delayed
if node.run_list.expand(node.chef_environment).recipes.include?("openstack-network::openvswitch")
notifies :restart, "service[neutron-plugin-openvswitch-agent]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
if node.run_list.expand(node.chef_environment).recipes.include?('openstack-network::linuxbridge')
notifies :restart, 'service[neutron-plugin-linuxbridge-agent]', :delayed
end
end
when 'midonet'
when "plumgrid"
template_file = "/etc/neutron/plugins/plumgrid/plumgrid.ini"
template "/etc/neutron/plugins/plumgrid/plumgrid.ini" do
source "plugins/plumgrid/plumgrid.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template_file = '/etc/neutron/plugins/metaplugin/metaplugin.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when "ryu"
when 'nec'
template_file = "/etc/neutron/plugins/ryu/ryu.ini"
template "/etc/neutron/plugins/ryu/ryu.ini" do
source "plugins/ryu/ryu.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template_file = '/etc/neutron/plugins/nec/nec.ini'
template '/etc/neutron/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
sql_connection: sql_connection
)
notifies :restart, "service[neutron-server]", :delayed
notifies :restart, 'service[neutron-server]', :delayed
end
when 'nicira'
template_file = '/etc/neutron/plugins/nicira/nvp.ini'
template '/etc/neutron/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[neutron-server]', :delayed
end
when 'openvswitch'
template_file = '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini'
template '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini' do
source 'plugins/openvswitch/ovs_neutron_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[neutron-server]', :delayed
if node.run_list.expand(node.chef_environment).recipes.include?('openstack-network::openvswitch')
notifies :restart, 'service[neutron-plugin-openvswitch-agent]', :delayed
end
end
when 'plumgrid'
template_file = '/etc/neutron/plugins/plumgrid/plumgrid.ini'
template '/etc/neutron/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[neutron-server]', :delayed
end
when 'ryu'
template_file = '/etc/neutron/plugins/ryu/ryu.ini'
template '/etc/neutron/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[neutron-server]', :delayed
end
end
template "/etc/default/neutron-server" do
source "neutron-server.erb"
owner "root"
group "root"
template '/etc/default/neutron-server' do
source 'neutron-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})
}
variables(
plugin_config: template_file
)
only_if do
node.run_list.expand(node.chef_environment).recipes.include?('openstack-network::server')
platform?(%w{ubuntu debian})
end
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: dhcp_agent
@ -17,55 +18,55 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
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]
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]
platform_options["neutron_dhcp_packages"].each do |pkg|
platform_options['neutron_dhcp_packages'].each do |pkg|
package pkg do
options platform_options["package_overrides"]
options platform_options['package_overrides']
action :install
end
end
service "neutron-dhcp-agent" do
service_name platform_options["neutron_dhcp_agent_service"]
supports :status => true, :restart => true
service 'neutron-dhcp-agent' do
service_name platform_options['neutron_dhcp_agent_service']
supports status: true, restart: true
action :enable
end
# Some plugins have DHCP functionality, so we install the plugin
# Python package and include the plugin-specific recipe here...
package platform_options["neutron_plugin_package"].gsub("%plugin%", main_plugin) do
options platform_options["package_overrides"]
package platform_options['neutron_plugin_package'].gsub('%plugin%', main_plugin) do
options platform_options['package_overrides']
action :install
# plugins are installed by the main openstack-neutron package on SUSE
not_if { platform_family? "suse" }
not_if { platform_family? 'suse' }
end
execute "neutron-dhcp-setup --plugin #{main_plugin}" do
only_if { platform?(%w(fedora redhat centos)) } # :pragma-foodcritic: ~FC024 - won't fix this
end
template "/etc/neutron/dnsmasq.conf" do
source "dnsmasq.conf.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/dnsmasq.conf' do
source 'dnsmasq.conf.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
notifies :restart, "service[neutron-dhcp-agent]", :delayed
notifies :restart, 'service[neutron-dhcp-agent]', :delayed
end
template "/etc/neutron/dhcp_agent.ini" do
source "dhcp_agent.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/dhcp_agent.ini' do
source 'dhcp_agent.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
notifies :restart, "service[neutron-dhcp-agent]", :immediately
notifies :restart, 'service[neutron-dhcp-agent]', :immediately
end
# Deal with ubuntu precise dnsmasq 2.59 version by custom
@ -79,9 +80,9 @@ end
#
# Would prefer a PPA or backport but there are none and upstream
# has no plans to fix
if node['lsb'] && node['lsb']['codename'] == "precise"
if node['lsb'] && node['lsb']['codename'] == 'precise'
platform_options["neutron_dhcp_build_packages"].each do |pkg|
platform_options['neutron_dhcp_build_packages'].each do |pkg|
package pkg do
action :install
end
@ -112,20 +113,20 @@ if node['lsb'] && node['lsb']['codename'] == "precise"
debian/rules binary
EOH
not_if { ::File.exists?(extract_path) }
notifies :install, "dpkg_package[dnsmasq-utils]", :immediately
notifies :install, "dpkg_package[dnsmasq-base]", :immediately
notifies :install, "dpkg_package[dnsmasq]", :immediately
notifies :install, 'dpkg_package[dnsmasq-utils]', :immediately
notifies :install, 'dpkg_package[dnsmasq-base]', :immediately
notifies :install, 'dpkg_package[dnsmasq]', :immediately
end
dpkg_package "dnsmasq-utils" do
dpkg_package 'dnsmasq-utils' do
source "#{extract_path}/../dnsmasq-utils_#{dhcp_options['dnsmasq_dpkgversion']}_#{dhcp_options['dnsmasq_architecture']}.deb"
action :nothing
end
dpkg_package "dnsmasq-base" do
dpkg_package 'dnsmasq-base' do
source "#{extract_path}/../dnsmasq-base_#{dhcp_options['dnsmasq_dpkgversion']}_#{dhcp_options['dnsmasq_architecture']}.deb"
action :nothing
end
dpkg_package "dnsmasq" do
dpkg_package 'dnsmasq' do
source "#{extract_path}/../dnsmasq_#{dhcp_options['dnsmasq_dpkgversion']}_all.deb"
action :nothing
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: hyperv
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: identity_registration
@ -18,41 +19,42 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
require "uri"
require 'uri'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
end
identity_admin_endpoint = endpoint "identity-admin"
identity_admin_endpoint = endpoint 'identity-admin'
bootstrap_token = secret "secrets", "openstack_identity_bootstrap_token"
bootstrap_token = secret 'secrets', 'openstack_identity_bootstrap_token'
auth_uri = ::URI.decode identity_admin_endpoint.to_s
api_endpoint = endpoint "network-api"
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"]
service_role = node["openstack"]["network"]["service_role"]
service_pass = service_password 'openstack-network'
service_tenant_name = node['openstack']['network']['service_tenant_name']
service_user = node['openstack']['network']['service_user']
service_role = node['openstack']['network']['service_role']
openstack_identity_register "Register Network API Service" do
openstack_identity_register 'Register Network API Service' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_name node["openstack"]["network"]["service_name"]
service_type node["openstack"]["network"]["service_type"]
service_description "OpenStack Network Service"
service_name node['openstack']['network']['service_name']
service_type node['openstack']['network']['service_type']
service_description 'OpenStack Network Service'
action :create_service
end
openstack_identity_register "Register Network Endpoint" do
openstack_identity_register 'Register Network Endpoint' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_type node["openstack"]["network"]["service_type"]
endpoint_region node["openstack"]["network"]["region"]
service_type node['openstack']['network']['service_type']
endpoint_region node['openstack']['network']['region']
endpoint_adminurl api_endpoint.to_s
endpoint_internalurl api_endpoint.to_s
endpoint_publicurl api_endpoint.to_s
@ -60,11 +62,11 @@ openstack_identity_register "Register Network Endpoint" do
action :create_endpoint
end
openstack_identity_register "Register Service Tenant" do
openstack_identity_register 'Register Service Tenant' do
auth_uri auth_uri
bootstrap_token bootstrap_token
tenant_name service_tenant_name
tenant_description "Service Tenant"
tenant_description 'Service Tenant'
action :create_tenant
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: l3_agent
@ -17,50 +18,50 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
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]
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]
platform_options["neutron_l3_packages"].each do |pkg|
platform_options['neutron_l3_packages'].each do |pkg|
package pkg do
options platform_options["package_overrides"]
options platform_options['package_overrides']
action :install
# The providers below do not use the generic L3 agent...
not_if { ["nicira", "plumgrid", "bigswitch"].include?(main_plugin) }
not_if { ['nicira', 'plumgrid', 'bigswitch'].include?(main_plugin) }
end
end
service "neutron-l3-agent" do
service_name platform_options["neutron_l3_agent_service"]
supports :status => true, :restart => true
service 'neutron-l3-agent' do
service_name platform_options['neutron_l3_agent_service']
supports status: true, restart: true
action :enable
end
execute "neutron-l3-setup --plugin #{main_plugin}" do
only_if {
platform?(%w(fedora redhat centos)) and not # :pragma-foodcritic: ~FC024 - won't fix this
["nicira", "plumgrid", "bigswitch"].include?(main_plugin)
}
only_if do
platform?(%w(fedora redhat centos)) && # :pragma-foodcritic: ~FC024 - won't fix this
!['nicira', 'plumgrid', 'bigswitch'].include?(main_plugin)
end
end
template "/etc/neutron/l3_agent.ini" do
source "l3_agent.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/l3_agent.ini' do
source 'l3_agent.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
notifies :restart, "service[neutron-l3-agent]", :immediately
notifies :restart, 'service[neutron-l3-agent]', :immediately
end
if not ["nicira", "plumgrid", "bigswitch", "linuxbridge"].include?(main_plugin)
unless ['nicira', 'plumgrid', 'bigswitch', 'linuxbridge'].include?(main_plugin)
# See http://docs.openstack.org/trunk/openstack-network/admin/content/install_neutron-l3.html
ext_bridge = node["openstack"]["network"]["l3"]["external_network_bridge"]
ext_bridge_iface = node["openstack"]["network"]["l3"]["external_network_bridge_interface"]
execute "create external network bridge" do
ext_bridge = node['openstack']['network']['l3']['external_network_bridge']
ext_bridge_iface = node['openstack']['network']['l3']['external_network_bridge_interface']
execute 'create external network bridge' do
command "ovs-vsctl add-br #{ext_bridge} && ovs-vsctl add-port #{ext_bridge} #{ext_bridge_iface}"
action :run
not_if "ovs-vsctl show | grep 'Bridge #{ext_bridge}'"

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: linuxbridge
@ -17,21 +18,21 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'
platform_options = node["openstack"]["network"]["platform"]
platform_options = node['openstack']['network']['platform']
platform_options["neutron_linuxbridge_agent_packages"].each do |pkg|
platform_options['neutron_linuxbridge_agent_packages'].each do |pkg|
package pkg do
options platform_options["package_overrides"]
options platform_options['package_overrides']
action :install
end
end
service "neutron-plugin-linuxbridge-agent" do
service_name platform_options["neutron_linuxbridge_agent_service"]
supports :status => true, :restart => true
service 'neutron-plugin-linuxbridge-agent' do
service_name platform_options['neutron_linuxbridge_agent_service']
supports status: true, restart: true
action :enable
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: metadata_agent
@ -17,41 +18,39 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
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]
platform_options = node['openstack']['network']['platform']
identity_endpoint = endpoint "identity-api"
service_pass = service_password "openstack-network"
metadata_secret = secret "secrets", node["openstack"]["network"]["metadata"]["secret_name"]
identity_endpoint = endpoint 'identity-api'
service_pass = service_password 'openstack-network'
metadata_secret = secret 'secrets', node['openstack']['network']['metadata']['secret_name']
template "/etc/neutron/metadata_agent.ini" do
source "metadata_agent.ini.erb"
owner node["openstack"]["network"]["platform"]["user"]
group node["openstack"]["network"]["platform"]["group"]
template '/etc/neutron/metadata_agent.ini' do
source 'metadata_agent.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
variables(
:identity_endpoint => identity_endpoint,
:metadata_secret => metadata_secret,
:service_pass => service_pass
identity_endpoint: identity_endpoint,
metadata_secret: metadata_secret,
service_pass: service_pass
)
notifies :restart, "service[neutron-metadata-agent]", :immediately
notifies :restart, 'service[neutron-metadata-agent]', :immediately
action :create
end
platform_options["neutron_metadata_agent_packages"].each do |pkg|
platform_options['neutron_metadata_agent_packages'].each do |pkg|
package pkg do
action :install
options platform_options["package_overrides"]
options platform_options['package_overrides']
end
end
service "neutron-metadata-agent" do
service_name platform_options["neutron_metadata_agent_service"]
supports :status => true, :restart => true
service 'neutron-metadata-agent' do
service_name platform_options['neutron_metadata_agent_service']
supports status: true, restart: true
action :enable
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: metaplugin
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: midonet
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: nec
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: nicira
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: opensvswitch
@ -17,129 +18,131 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
require 'uri'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
end
include_recipe "openstack-network::common"
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"]
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]
if platform?("ubuntu", "debian")
if platform?('ubuntu', 'debian')
# obtain kernel version for kernel header
# installation on ubuntu and debian
kernel_ver = node["kernel"]["release"]
kernel_ver = node['kernel']['release']
package "linux-headers-#{kernel_ver}" do
options platform_options["package_overrides"]
options platform_options['package_overrides']
action :install
end
end
if node['openstack']['network']['openvswitch']['use_source_version']
if node['lsb'] && node['lsb']['codename'] == "precise"
include_recipe "openstack-network::build_openvswitch_source"
if node['lsb'] && node['lsb']['codename'] == 'precise'
include_recipe 'openstack-network::build_openvswitch_source'
end
else
platform_options["neutron_openvswitch_packages"].each do |pkg|
platform_options['neutron_openvswitch_packages'].each do |pkg|
package pkg do
action :install
end
end
end
service "neutron-openvswitch-switch" do
service_name platform_options["neutron_openvswitch_service"]
supports :status => true, :restart => true
action [ :enable, :restart ]
service 'neutron-openvswitch-switch' do
service_name platform_options['neutron_openvswitch_service']
supports status: true, restart: true
action [:enable, :restart]
end
if node.run_list.expand(node.chef_environment).recipes.include?("openstack-network::server")
service "neutron-server" do
service_name platform_options["neutron_server_service"]
supports :status => true, :restart => true
if node.run_list.expand(node.chef_environment).recipes.include?('openstack-network::server')
service 'neutron-server' do
service_name platform_options['neutron_server_service']
supports status: true, restart: true
action :nothing
end
end
platform_options["neutron_openvswitch_agent_packages"].each do |pkg|
platform_options['neutron_openvswitch_agent_packages'].each do |pkg|
package pkg do
action :install
options platform_options["package_overrides"]
options platform_options['package_overrides']
end
end
service "neutron-plugin-openvswitch-agent" do
service_name platform_options["neutron_openvswitch_agent_service"]
supports :status => true, :restart => true
service 'neutron-plugin-openvswitch-agent' do
service_name platform_options['neutron_openvswitch_agent_service']
supports status: true, restart: true
action :enable
end
execute "neutron-node-setup --plugin openvswitch" do
execute 'neutron-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
unless ['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[neutron-plugin-openvswitch-agent]", :delayed
notifies :restart, 'service[neutron-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
unless ['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[neutron-plugin-openvswitch-agent]", :delayed
notifies :restart, 'service[neutron-plugin-openvswitch-agent]', :delayed
end
end
if node['openstack']['network']['disable_offload']
package "ethtool" do
package 'ethtool' do
action :install
options platform_options["package_overrides"]
options platform_options['package_overrides']
end
service "disable-eth-offload" do
supports :restart => false, :start => true, :stop => false, :reload => false
priority({ 2 => [ :start, 19 ]})
service 'disable-eth-offload' do
supports restart: false, start: true, stop: false, reload: false
priority(
2 => [:start, 19]
)
action :nothing
end
# a priority of 19 ensures we start before openvswitch
# at least on ubuntu and debian
cookbook_file "disable-eth-offload-script" do
path "/etc/init.d/disable-eth-offload"
source "disable-eth-offload.sh"
owner "root"
group "root"
mode "0755"
notifies :enable, "service[disable-eth-offload]"
notifies :start, "service[disable-eth-offload]"
cookbook_file 'disable-eth-offload-script' do
path '/etc/init.d/disable-eth-offload'
source 'disable-eth-offload.sh'
owner 'root'
group 'root'
mode '0755'
notifies :enable, 'service[disable-eth-offload]'
notifies :start, 'service[disable-eth-offload]'
end
end
# From http://git.openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=utilities/ovs-dpctl-top.in;h=f43fdeb7ab52e3ef642a22579036249ec3a4bc22;hb=14b4c575c28421d1181b509dbeae6e4849c7da69
cookbook_file "ovs-dpctl-top" do
path "/usr/bin/ovs-dpctl-top"
source "ovs-dpctl-top"
owner "root"
group "root"
mode "0755"
cookbook_file 'ovs-dpctl-top' do
path '/usr/bin/ovs-dpctl-top'
source 'ovs-dpctl-top'
owner 'root'
group 'root'
mode '0755'
end

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: plumgrid
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: ryu
@ -17,6 +18,6 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
include_recipe "openstack-network::common"
include_recipe 'openstack-network::common'

View File

@ -1,3 +1,4 @@
# Encoding: utf-8
#
# Cookbook Name:: openstack-network
# Recipe:: server
@ -18,43 +19,42 @@
# limitations under the License.
#
['quantum','neutron'].include?(node["openstack"]["compute"]["network"]["service_type"]) || return
['quantum', 'neutron'].include?(node['openstack']['compute']['network']['service_type']) || return
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
end
include_recipe "openstack-network::common"
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"]
platform_options = node['openstack']['network']['platform']
driver_name = node['openstack']['network']['interface_driver'].split('.').last.downcase
platform_options = node["openstack"]["network"]["platform"]
platform_options = node['openstack']['network']['platform']
platform_options["neutron_server_packages"].each do |pkg|
platform_options['neutron_server_packages'].each do |pkg|
package pkg do
options platform_options["package_overrides"]
options platform_options['package_overrides']
action :install
end
end
service "neutron-server" do
service_name platform_options["neutron_server_service"]
supports :status => true, :restart => true
service 'neutron-server' do
service_name platform_options['neutron_server_service']
supports status: true, restart: true
action :enable
end
cookbook_file "neutron-ha-tool" do
source "neutron-ha-tool.py"
path node["openstack"]["network"]["neutron_ha_cmd"]
owner "root"
group "root"
cookbook_file 'neutron-ha-tool' do
source 'neutron-ha-tool.py'
path node['openstack']['network']['neutron_ha_cmd']
owner 'root'
group 'root'
mode 00755
end
if node["openstack"]["network"]["neutron_ha_cmd_cron"]
if node['openstack']['network']['neutron_ha_cmd_cron']
# ensure period checks are offset between multiple l3 agent nodes
# and assumes splay will remain constant (i.e. based on hostname)
# Generate a uniformly distributed unique number to sleep.
@ -62,27 +62,27 @@ if node["openstack"]["network"]["neutron_ha_cmd_cron"]
splay = node['chef_client']['splay'].to_i || 3000
sleep_time = checksum.to_s.hex % splay
cron "neutron-ha-healthcheck" do
minute node["openstack"]["network"]["cron_l3_healthcheck"]
cron 'neutron-ha-healthcheck' do
minute node['openstack']['network']['cron_l3_healthcheck']
command "sleep #{sleep_time} ; . /root/openrc && #{node["openstack"]["network"]["neutron_ha_cmd"]} --l3-agent-migrate > /dev/null 2>&1"
end
cron "neutron-ha-replicate-dhcp" do
minute node["openstack"]["network"]["cron_replicate_dhcp"]
cron 'neutron-ha-replicate-dhcp' do
minute node['openstack']['network']['cron_replicate_dhcp']
command "sleep #{sleep_time} ; . /root/openrc && #{node["openstack"]["network"]["neutron_ha_cmd"]} --replicate-dhcp > /dev/null 2>&1"
end
end
# the default SUSE initfile uses this sysconfig file to determine the
# neutron plugin to use
template "/etc/sysconfig/neutron" do
only_if { platform? "suse" }
source "neutron.sysconfig.erb"
owner "root"
group "root"
template '/etc/sysconfig/neutron' do
only_if { platform? 'suse' }
source 'neutron.sysconfig.erb'
owner 'root'
group 'root'
mode 00644
variables(
:plugin_conf => node["openstack"]["network"]["plugin_conf_map"][driver_name]
plugin_conf: node['openstack']['network']['plugin_conf_map'][driver_name]
)
notifies :restart, "service[neutron-server]"
notifies :restart, 'service[neutron-server]'
end

View File

@ -1,23 +1,24 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::balancer' do
describe "ubuntu" do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::balancer"
@chef_run.converge 'openstack-network::balancer'
end
it "does not install neutron-lbaas-agent when nova networking." do
it 'does not install neutron-lbaas-agent when nova networking.' do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = @chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
@chef_run.converge "openstack-network::balancer"
expect(@chef_run).to_not install_package "neutron-lbaas-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge 'openstack-network::balancer'
expect(@chef_run).to_not install_package 'neutron-lbaas-agent'
end
['haproxy', 'neutron-lbaas-agent'].each do |pack|
@ -31,7 +32,7 @@ describe 'openstack-network::balancer' do
end
it 'balancer config' do
configf = "/etc/neutron/plugins/services/agent_loadbalancer/lbaas_agent.ini"
configf = '/etc/neutron/plugins/services/agent_loadbalancer/lbaas_agent.ini'
expect(@chef_run).to create_template(configf)
expect(@chef_run).to render_file(configf).with_content(/periodic_interval = 10/)
expect(@chef_run).to render_file(configf).with_content(

View File

@ -1,59 +1,60 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe "openvswitch::build_openvswitch_source" do
describe 'openvswitch::build_openvswitch_source' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::openvswitch"
@chef_run.converge "openstack-network::build_openvswitch_source"
@chef_run.converge 'openstack-network::openvswitch'
@chef_run.converge 'openstack-network::build_openvswitch_source'
end
it "does not install openvswitch build dependencies when nova networking" do
it 'does not install openvswitch build dependencies when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::openvswitch"
chef_run.converge "openstack-network::build_openvswitch_source"
[ "build-essential", "pkg-config", "fakeroot", "libssl-dev", "openssl", "debhelper", "autoconf" ].each do |pkg|
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::openvswitch'
chef_run.converge 'openstack-network::build_openvswitch_source'
['build-essential', 'pkg-config', 'fakeroot', 'libssl-dev', 'openssl', 'debhelper', 'autoconf'].each do |pkg|
expect(chef_run).to_not install_package pkg
end
end
# since our mocked version of ubuntu is precise, our compile
# utilities should be installed to build OVS from source
it "installs openvswitch build dependencies" do
[ "build-essential", "pkg-config", "fakeroot", "libssl-dev", "openssl", "debhelper", "autoconf" ].each do |pkg|
it 'installs openvswitch build dependencies' do
['build-essential', 'pkg-config', 'fakeroot', 'libssl-dev', 'openssl', 'debhelper', 'autoconf'].each do |pkg|
expect(@chef_run).to install_package pkg
end
end
it "installs openvswitch switch dpkg" do
pkg = @chef_run.dpkg_package("openvswitch-switch")
it 'installs openvswitch switch dpkg' do
pkg = @chef_run.dpkg_package('openvswitch-switch')
pkg.source.should == "/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-switch_1.10.2-1_amd64.deb"
pkg.action.should == [:nothing]
pkg.source.should eq '/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-switch_1.10.2-1_amd64.deb'
pkg.action.should eq [:nothing]
end
it "installs openvswitch datapath dkms dpkg" do
pkg = @chef_run.dpkg_package("openvswitch-datapath-dkms")
it 'installs openvswitch datapath dkms dpkg' do
pkg = @chef_run.dpkg_package('openvswitch-datapath-dkms')
pkg.source.should == "/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-datapath-dkms_1.10.2-1_all.deb"
pkg.action.should == [:nothing]
pkg.source.should eq '/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-datapath-dkms_1.10.2-1_all.deb'
pkg.action.should eq [:nothing]
end
it "installs openvswitch pki dpkg" do
pkg = @chef_run.dpkg_package("openvswitch-pki")
it 'installs openvswitch pki dpkg' do
pkg = @chef_run.dpkg_package('openvswitch-pki')
pkg.source.should == "/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-pki_1.10.2-1_all.deb"
pkg.action.should == [:nothing]
pkg.source.should eq '/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-pki_1.10.2-1_all.deb'
pkg.action.should eq [:nothing]
end
it "installs openvswitch common dpkg" do
pkg = @chef_run.dpkg_package("openvswitch-common")
it 'installs openvswitch common dpkg' do
pkg = @chef_run.dpkg_package('openvswitch-common')
pkg.source.should == "/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-common_1.10.2-1_amd64.deb"
pkg.action.should == [:nothing]
pkg.source.should eq '/var/chef/cache/22df718eb81fcfe93228e9bba8575e50/openvswitch-common_1.10.2-1_amd64.deb'
pkg.action.should eq [:nothing]
end
end

View File

@ -1,24 +1,25 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe "openstack-network::common" do
describe "redhat" do
describe 'openstack-network::common' do
describe 'redhat' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::common"
@chef_run.converge 'openstack-network::common'
end
it "installs mysql python packages by default" do
expect(@chef_run).to install_package "MySQL-python"
it 'installs mysql python packages by default' do
expect(@chef_run).to install_package 'MySQL-python'
end
it "installs db2 python packages if explicitly told" do
@chef_run.node.set["openstack"]["db"]["network"]["db_type"] = "db2"
@chef_run.converge "openstack-network::common"
it 'installs db2 python packages if explicitly told' do
@chef_run.node.set['openstack']['db']['network']['db_type'] = 'db2'
@chef_run.converge 'openstack-network::common'
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg|
['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(@chef_run).to install_package pkg
end
end

View File

@ -1,33 +1,34 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe "openstack-network::common" do
describe "ubuntu" do
describe 'openstack-network::common' do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::common"
@chef_run.converge 'openstack-network::common'
end
it "does not install python-neutronclient when nova networking" do
it 'does not install python-neutronclient when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::common"
expect(chef_run).to_not install_package "python-neutronclient"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::common'
expect(chef_run).to_not install_package 'python-neutronclient'
end
it "upgrades python neutronclient" do
expect(@chef_run).to upgrade_package "python-neutronclient"
it 'upgrades python neutronclient' do
expect(@chef_run).to upgrade_package 'python-neutronclient'
end
it "upgrades python pyparsing" do
expect(@chef_run).to upgrade_package "python-pyparsing"
it 'upgrades python pyparsing' do
expect(@chef_run).to upgrade_package 'python-pyparsing'
end
it "installs mysql python packages by default" do
expect(@chef_run).to install_package "python-mysqldb"
it 'installs mysql python packages by default' do
expect(@chef_run).to install_package 'python-mysqldb'
end
end

View File

@ -1,49 +1,50 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::dhcp_agent' do
describe "opensuse" do
describe 'opensuse' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::dhcp_agent"
@chef_run.converge 'openstack-network::dhcp_agent'
end
it "does not install openstack-neutron-dhcp-agent when nova networking" do
it 'does not install openstack-neutron-dhcp-agent when nova networking' do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = @chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
@chef_run.converge "openstack-network::dhcp_agent"
expect(@chef_run).to_not install_package "openstack-neutron-dhcp-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge 'openstack-network::dhcp_agent'
expect(@chef_run).to_not install_package 'openstack-neutron-dhcp-agent'
end
it "installs quamtum dhcp package" do
expect(@chef_run).to install_package "openstack-neutron-dhcp-agent"
it 'installs quamtum dhcp package' do
expect(@chef_run).to install_package 'openstack-neutron-dhcp-agent'
end
it "installs plugin packages" do
it 'installs plugin packages' do
expect(@chef_run).not_to install_package(/openvswitch/)
expect(@chef_run).not_to install_package(/plugin/)
end
it "starts the dhcp agent on boot" do
it 'starts the dhcp agent on boot' do
expect(@chef_run).to(
enable_service "openstack-neutron-dhcp-agent")
enable_service 'openstack-neutron-dhcp-agent')
end
it "/etc/neutron/dhcp_agent.ini has the proper owner" do
file = @chef_run.template "/etc/neutron/dhcp_agent.ini"
expect(file.owner).to eq("openstack-neutron")
expect(file.group).to eq("openstack-neutron")
it '/etc/neutron/dhcp_agent.ini has the proper owner' do
file = @chef_run.template '/etc/neutron/dhcp_agent.ini'
expect(file.owner).to eq('openstack-neutron')
expect(file.group).to eq('openstack-neutron')
end
it "/etc/neutron/dnsmasq.conf has the proper owner" do
file = @chef_run.template "/etc/neutron/dnsmasq.conf"
expect(file.owner).to eq("openstack-neutron")
expect(file.group).to eq("openstack-neutron")
it '/etc/neutron/dnsmasq.conf has the proper owner' do
file = @chef_run.template '/etc/neutron/dnsmasq.conf'
expect(file.owner).to eq('openstack-neutron')
expect(file.group).to eq('openstack-neutron')
end
end
end

View File

@ -1,96 +1,97 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::dhcp_agent' do
describe "ubuntu" do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::dhcp_agent"
@chef_run.converge 'openstack-network::dhcp_agent'
end
it "does not include recipe openstack-network::comon when nova networking" do
it 'does not include recipe openstack-network::comon when nova networking' do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = @chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
@chef_run.converge "openstack-network::dhcp_agent"
expect(@chef_run).to_not include_recipe "openstack-network::common"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge 'openstack-network::dhcp_agent'
expect(@chef_run).to_not include_recipe 'openstack-network::common'
end
# since our mocked version of ubuntu is precise, our compile
# utilities should be installed to build dnsmasq
it "installs dnsmasq build dependencies" do
[ "build-essential", "pkg-config", "libidn11-dev", "libdbus-1-dev", "libnetfilter-conntrack-dev", "gettext" ].each do |pkg|
it 'installs dnsmasq build dependencies' do
['build-essential', 'pkg-config', 'libidn11-dev', 'libdbus-1-dev', 'libnetfilter-conntrack-dev', 'gettext'].each do |pkg|
expect(@chef_run).to install_package pkg
end
end
it "installs quamtum dhcp package" do
expect(@chef_run).to install_package "neutron-dhcp-agent"
it 'installs quamtum dhcp package' do
expect(@chef_run).to install_package 'neutron-dhcp-agent'
end
it "installs plugin packages" do
expect(@chef_run).to install_package "neutron-plugin-openvswitch"
it 'installs plugin packages' do
expect(@chef_run).to install_package 'neutron-plugin-openvswitch'
end
it "starts the dhcp agent on boot" do
expect(@chef_run).to enable_service "neutron-dhcp-agent"
it 'starts the dhcp agent on boot' do
expect(@chef_run).to enable_service 'neutron-dhcp-agent'
end
describe "/etc/neutron/plugins" do
describe '/etc/neutron/plugins' do
before do
@file = @chef_run.directory "/etc/neutron/plugins"
@file = @chef_run.directory '/etc/neutron/plugins'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "700"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '700'
end
end
describe "/etc/neutron/dhcp_agent.ini" do
describe '/etc/neutron/dhcp_agent.ini' do
before do
@file = @chef_run.template "/etc/neutron/dhcp_agent.ini"
@file = @chef_run.template '/etc/neutron/dhcp_agent.ini'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "uses ovs driver" do
it 'uses ovs driver' do
expect(@chef_run).to render_file(@file.name).with_content(
"interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver")
'interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver')
end
it "uses namespaces" do
expect(@chef_run).to render_file(@file.name).with_content("use_namespaces = True")
it 'uses namespaces' do
expect(@chef_run).to render_file(@file.name).with_content('use_namespaces = True')
end
it "checks dhcp domain" do
it 'checks dhcp domain' do
expect(@chef_run).to render_file(@file.name).with_content(/^dhcp_domain = openstacklocal$/)
end
end
describe "/etc/neutron/dnsmasq.conf" do
describe '/etc/neutron/dnsmasq.conf' do
before do
@file = @chef_run.template "/etc/neutron/dnsmasq.conf"
@file = @chef_run.template '/etc/neutron/dnsmasq.conf'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "overrides dhcp options" do
expect(@chef_run).to render_file(@file.name).with_content("dhcp-option=26,1454")
it 'overrides dhcp options' do
expect(@chef_run).to render_file(@file.name).with_content('dhcp-option=26,1454')
end
it "checks upstream resolvers" do
it 'checks upstream resolvers' do
expect(@chef_run).to render_file(@file.name).with_content(/^server=209.244.0.3$/)
expect(@chef_run).to render_file(@file.name).with_content(/^server=8.8.8.8$/)
end

View File

@ -1,105 +1,106 @@
require_relative "spec_helper"
# Encoding: utf-8
require_relative 'spec_helper'
describe "openstack-network::identity_registration" do
describe 'openstack-network::identity_registration' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
end
@chef_run.converge "openstack-network::identity_registration"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge 'openstack-network::identity_registration'
end
it "does not do network service registrations when nova networking" do
it 'does not do network service registrations when nova networking' do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = @chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
@chef_run.converge "openstack-network::identity_registration"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge 'openstack-network::identity_registration'
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Network API Service"
'openstack-identity_register',
'Register Network API Service'
)
expect(resource).to be_nil
end
it "registers network service" do
it 'registers network service' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Network API Service"
'openstack-identity_register',
'Register Network API Service'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_type => "network",
:service_description => "OpenStack Network Service",
:action => [:create_service]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'network',
service_description: 'OpenStack Network Service',
action: [:create_service]
)
end
it "registers network endpoint" do
it 'registers network endpoint' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Network Endpoint"
'openstack-identity_register',
'Register Network Endpoint'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_type => "network",
:endpoint_region => "RegionOne",
:endpoint_adminurl => "http://127.0.0.1:9696",
:endpoint_internalurl => "http://127.0.0.1:9696",
:endpoint_publicurl => "http://127.0.0.1:9696",
:action => [:create_endpoint]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'network',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9696',
endpoint_internalurl: 'http://127.0.0.1:9696',
endpoint_publicurl: 'http://127.0.0.1:9696',
action: [:create_endpoint]
)
end
it "registers service tenant" do
it 'registers service tenant' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Service Tenant"
'openstack-identity_register',
'Register Service Tenant'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:tenant_description => "Service Tenant",
:action => [:create_tenant]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
tenant_description: 'Service Tenant',
action: [:create_tenant]
)
end
it "registers service user" do
it 'registers service user' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register neutron User"
'openstack-identity_register',
'Register neutron User'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:user_name => "neutron",
:user_pass => "neutron-pass",
:action => [:create_user]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'neutron',
user_pass: 'neutron-pass',
action: [:create_user]
)
end
it "grants admin role to service user for service tenant" do
it 'grants admin role to service user for service tenant' do
resource = @chef_run.find_resource(
"openstack-identity_register",
'openstack-identity_register',
"Grant 'admin' Role to neutron User for service Tenant"
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:role_name => "admin",
:user_name => "neutron",
:action => [:grant_role]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
role_name: 'admin',
user_name: 'neutron',
action: [:grant_role]
)
end
end

View File

@ -1,100 +1,101 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::l3_agent' do
describe "ubuntu" do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set["openstack"]["network"]["l3"]["external_network_bridge_interface"] = "eth1"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
n.set['openstack']['network']['l3']['external_network_bridge_interface'] = 'eth1'
end
@chef_run.converge "openstack-network::l3_agent"
@chef_run.converge 'openstack-network::l3_agent'
end
it "does not install neutron l3 package when nova networking" do
it 'does not install neutron l3 package when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::l3_agent"
expect(chef_run).to_not install_package "neutron-l3-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::l3_agent'
expect(chef_run).to_not install_package 'neutron-l3-agent'
end
it "installs quamtum l3 package" do
expect(@chef_run).to install_package "neutron-l3-agent"
it 'installs quamtum l3 package' do
expect(@chef_run).to install_package 'neutron-l3-agent'
end
describe "l3_agent.ini" do
describe 'l3_agent.ini' do
before do
@file = @chef_run.template "/etc/neutron/l3_agent.ini"
@file = @chef_run.template '/etc/neutron/l3_agent.ini'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "it has ovs driver" do
it 'it has ovs driver' do
expect(@chef_run).to render_file(@file.name).with_content(
"interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver")
'interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver')
end
it "sets fuzzy delay to default" do
it 'sets fuzzy delay to default' do
expect(@chef_run).to render_file(@file.name).with_content(
"periodic_fuzzy_delay = 5")
'periodic_fuzzy_delay = 5')
end
it "it does not set a nil router_id" do
it 'it does not set a nil router_id' do
expect(@chef_run).not_to render_file(@file.name).with_content(/^router_id =/)
end
it "it does not set a nil router_id" do
it 'it does not set a nil router_id' do
expect(@chef_run).not_to render_file(@file.name).with_content(
/^gateway_external_network_id =/)
end
end
describe "create ovs bridges" do
describe 'create ovs bridges' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
end
cmd = "ovs-vsctl add-br br-ex && ovs-vsctl add-port br-ex eth1"
cmd = 'ovs-vsctl add-br br-ex && ovs-vsctl add-port br-ex eth1'
it "doesn't add the external bridge if it already exists" do
stub_command(/ovs-vsctl show/).and_return(true)
stub_command(/ip link show eth1/).and_return(true)
@chef_run.converge "openstack-network::l3_agent"
@chef_run.converge 'openstack-network::l3_agent'
expect(@chef_run).not_to run_execute(cmd)
end
it "doesn't add the external bridge if the physical interface doesn't exist" do
stub_command(/ovs-vsctl show/).and_return(true)
stub_command(/ip link show eth1/).and_return(false)
@chef_run.converge "openstack-network::l3_agent"
@chef_run.converge 'openstack-network::l3_agent'
expect(@chef_run).not_to run_execute(cmd)
end
it "adds the external bridge if it does not yet exist" do
it 'adds the external bridge if it does not yet exist' do
stub_command(/ovs-vsctl show/).and_return(false)
stub_command(/ip link show eth1/).and_return(true)
@chef_run.converge "openstack-network::l3_agent"
@chef_run.converge 'openstack-network::l3_agent'
expect(@chef_run).to run_execute(cmd)
end
it "adds the external bridge if the physical interface exists" do
it 'adds the external bridge if the physical interface exists' do
stub_command(/ovs-vsctl show/).and_return(false)
stub_command(/ip link show eth1/).and_return(true)
@chef_run.converge "openstack-network::l3_agent"
@chef_run.converge 'openstack-network::l3_agent'
expect(@chef_run).to run_execute(cmd)
end
end

View File

@ -1,31 +1,32 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::linuxbridge' do
describe "opensuse" do
describe 'opensuse' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["openstack"]["network"]["interface_driver"] = "neutron.agent.linux.interface.BridgeInterfaceDriver"
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.BridgeInterfaceDriver'
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::linuxbridge"
@chef_run.converge 'openstack-network::linuxbridge'
end
it "does not install linuxbridge agent package when nova networking" do
it 'does not install linuxbridge agent package when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::linuxbridge"
expect(chef_run).to_not install_package "openstack-neutron-linuxbridge-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::linuxbridge'
expect(chef_run).to_not install_package 'openstack-neutron-linuxbridge-agent'
end
it "installs linuxbridge agent" do
expect(@chef_run).to install_package "openstack-neutron-linuxbridge-agent"
it 'installs linuxbridge agent' do
expect(@chef_run).to install_package 'openstack-neutron-linuxbridge-agent'
end
it "sets the linuxbridge service to start on boot" do
expect(@chef_run).to enable_service "openstack-neutron-linuxbridge-agent"
it 'sets the linuxbridge service to start on boot' do
expect(@chef_run).to enable_service 'openstack-neutron-linuxbridge-agent'
end
end

View File

@ -1,31 +1,32 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::linuxbridge' do
describe "redhat" do
describe 'redhat' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["network"]["interface_driver"] = "neutron.agent.linux.interface.BridgeInterfaceDriver"
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.BridgeInterfaceDriver'
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::linuxbridge"
@chef_run.converge 'openstack-network::linuxbridge'
end
it "does not install linuxbridge agent package when nova networking" do
it 'does not install linuxbridge agent package when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::linuxbridge"
expect(chef_run).to_not install_package "openstack-neutron-linuxbridge"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::linuxbridge'
expect(chef_run).to_not install_package 'openstack-neutron-linuxbridge'
end
it "installs linuxbridge agent" do
expect(@chef_run).to install_package "openstack-neutron-linuxbridge"
it 'installs linuxbridge agent' do
expect(@chef_run).to install_package 'openstack-neutron-linuxbridge'
end
it "sets the linuxbridge service to start on boot" do
expect(@chef_run).to enable_service "neutron-linuxbridge-agent"
it 'sets the linuxbridge service to start on boot' do
expect(@chef_run).to enable_service 'neutron-linuxbridge-agent'
end
end

View File

@ -1,63 +1,64 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::linuxbridge' do
describe "ubuntu" do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["network"]["interface_driver"] = "neutron.agent.linux.interface.BridgeInterfaceDriver"
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set["openstack"]["db"]["network"]["db_name"] = "neutron"
n.set['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.BridgeInterfaceDriver'
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
n.set['openstack']['db']['network']['db_name'] = 'neutron'
end
@chef_run.converge "openstack-network::linuxbridge"
@chef_run.converge 'openstack-network::linuxbridge'
end
it "does not install linuxbridge agent package when nova networking" do
it 'does not install linuxbridge agent package when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::linuxbridge"
expect(chef_run).to_not install_package "neutron-plugin-linuxbridge-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::linuxbridge'
expect(chef_run).to_not install_package 'neutron-plugin-linuxbridge-agent'
end
it "installs linuxbridge agent" do
expect(@chef_run).to install_package "neutron-plugin-linuxbridge-agent"
it 'installs linuxbridge agent' do
expect(@chef_run).to install_package 'neutron-plugin-linuxbridge-agent'
end
it "sets the linuxbridge service to start on boot" do
expect(@chef_run).to enable_service "neutron-plugin-linuxbridge-agent"
it 'sets the linuxbridge service to start on boot' do
expect(@chef_run).to enable_service 'neutron-plugin-linuxbridge-agent'
end
describe "/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini" do
describe '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini' do
before do
@file = @chef_run.template(
"/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini")
'/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "has a correct sql_connection value" do
it 'has a correct sql_connection value' do
expect(@chef_run).to render_file(@file.name).with_content(
"mysql://neutron:neutron-pass@127.0.0.1:3306/neutron")
'mysql://neutron:neutron-pass@127.0.0.1:3306/neutron')
end
it "sets sqlalchemy attributes" do
it 'sets sqlalchemy attributes' do
expect(@chef_run).to render_file(@file.name).with_content(
"sql_dbpool_enable = False")
'sql_dbpool_enable = False')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_min_pool_size = 1")
'sql_min_pool_size = 1')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_max_pool_size = 5")
'sql_max_pool_size = 5')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_idle_timeout = 3600")
'sql_idle_timeout = 3600')
end
end
end

View File

@ -1,75 +1,76 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::metadata_agent' do
describe "ubuntu" do
describe 'ubuntu' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::metadata_agent"
@chef_run.converge 'openstack-network::metadata_agent'
end
it "does not install quamtum metadata agent when nova networking" do
it 'does not install quamtum metadata agent when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::metadata_agent"
expect(chef_run).to_not install_package "neutron-metadata-agent"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::metadata_agent'
expect(chef_run).to_not install_package 'neutron-metadata-agent'
end
it "installs quamtum metadata agent" do
expect(@chef_run).to install_package "neutron-metadata-agent"
it 'installs quamtum metadata agent' do
expect(@chef_run).to install_package 'neutron-metadata-agent'
end
describe "metadata_agent.ini" do
describe 'metadata_agent.ini' do
before do
@file = @chef_run.template "/etc/neutron/metadata_agent.ini"
@file = @chef_run.template '/etc/neutron/metadata_agent.ini'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "sets auth url correctly" do
it 'sets auth url correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_url = http://127.0.0.1:5000/v2.0")
'auth_url = http://127.0.0.1:5000/v2.0')
end
it "sets auth region correctly" do
it 'sets auth region correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_region = RegionOne")
'auth_region = RegionOne')
end
it "sets admin tenant name" do
it 'sets admin tenant name' do
expect(@chef_run).to render_file(@file.name).with_content(
"admin_tenant_name = service")
'admin_tenant_name = service')
end
it "sets admin user" do
it 'sets admin user' do
expect(@chef_run).to render_file(@file.name).with_content(
"admin_user = neutron")
'admin_user = neutron')
end
it "sets admin password" do
it 'sets admin password' do
expect(@chef_run).to render_file(@file.name).with_content(
"admin_password = neutron-pass")
'admin_password = neutron-pass')
end
it "sets nova metadata ip correctly" do
it 'sets nova metadata ip correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
"nova_metadata_ip = 127.0.0.1")
'nova_metadata_ip = 127.0.0.1')
end
it "sets nova metadata ip correctly" do
it 'sets nova metadata ip correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
"nova_metadata_port = 8775")
'nova_metadata_port = 8775')
end
it "sets neutron secret correctly" do
it 'sets neutron secret correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
"metadata_proxy_shared_secret = metadata-secret")
'metadata_proxy_shared_secret = metadata-secret')
end
end
end

View File

@ -1,35 +1,36 @@
require_relative "spec_helper"
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::openvswitch' do
describe "opensuse" do
describe 'opensuse' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["chef_client"]["splay"] = 300
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['chef_client']['splay'] = 300
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@node = @chef_run.node
@chef_run.converge "openstack-network::openvswitch"
@chef_run.converge 'openstack-network::openvswitch'
end
it "does not install openvswitch package when nova networking" do
it 'does not install openvswitch package when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::openvswitch"
expect(chef_run).to_not install_package "openvswitch-switch"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::openvswitch'
expect(chef_run).to_not install_package 'openvswitch-switch'
end
it "installs the openvswitch package" do
expect(@chef_run).to install_package "openvswitch-switch"
it 'installs the openvswitch package' do
expect(@chef_run).to install_package 'openvswitch-switch'
end
it "installs the openvswitch-agent package" do
expect(@chef_run).to install_package "openstack-neutron-openvswitch-agent"
it 'installs the openvswitch-agent package' do
expect(@chef_run).to install_package 'openstack-neutron-openvswitch-agent'
end
it "starts the openvswitch-switch service" do
expect(@chef_run).to enable_service "openvswitch-switch"
it 'starts the openvswitch-switch service' do
expect(@chef_run).to enable_service 'openvswitch-switch'
end
end
end

View File

@ -1,143 +1,145 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::openvswitch' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.automatic_attrs["kernel"]["release"] = "1.2.3"
n.set["openstack"]["network"]["local_ip_interface"] = "eth0"
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set["openstack"]["network"]["openvswitch"]["integration_bridge"] = "br-int"
n.automatic_attrs['kernel']['release'] = '1.2.3'
n.set['openstack']['network']['local_ip_interface'] = 'eth0'
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
n.set['openstack']['network']['openvswitch']['integration_bridge'] = 'br-int'
end
@chef_run.converge "openstack-network::openvswitch"
@chef_run.converge 'openstack-network::openvswitch'
end
it "does not install openvswitch switch when nova networking" do
it 'does not install openvswitch switch when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::openvswitch"
expect(chef_run).to_not install_package "openvswitch-switch"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::openvswitch'
expect(chef_run).to_not install_package 'openvswitch-switch'
end
it "installs openvswitch switch" do
expect(@chef_run).to install_package "openvswitch-switch"
it 'installs openvswitch switch' do
expect(@chef_run).to install_package 'openvswitch-switch'
end
it "installs openvswitch datapath dkms" do
expect(@chef_run).to install_package "openvswitch-datapath-dkms"
it 'installs openvswitch datapath dkms' do
expect(@chef_run).to install_package 'openvswitch-datapath-dkms'
end
it "installs linux bridge utils" do
expect(@chef_run).to install_package "bridge-utils"
it 'installs linux bridge utils' do
expect(@chef_run).to install_package 'bridge-utils'
end
it "installs linux linux headers" do
expect(@chef_run).to install_package "linux-headers-1.2.3"
it 'installs linux linux headers' do
expect(@chef_run).to install_package 'linux-headers-1.2.3'
end
it "sets the openvswitch service to start on boot" do
it 'sets the openvswitch service to start on boot' do
expect(@chef_run).to enable_service 'openvswitch-switch'
end
it "restarts the openvswitch service" do
it 'restarts the openvswitch service' do
expect(@chef_run).to restart_service 'openvswitch-switch'
end
it "installs openvswitch agent" do
expect(@chef_run).to install_package "neutron-plugin-openvswitch-agent"
it 'installs openvswitch agent' do
expect(@chef_run).to install_package 'neutron-plugin-openvswitch-agent'
end
it "sets the openvswitch service to start on boot" do
expect(@chef_run).to enable_service "neutron-plugin-openvswitch-agent"
it 'sets the openvswitch service to start on boot' do
expect(@chef_run).to enable_service 'neutron-plugin-openvswitch-agent'
end
describe "ovs-dpctl-top" do
describe 'ovs-dpctl-top' do
before do
@file = @chef_run.cookbook_file("ovs-dpctl-top")
@file = @chef_run.cookbook_file('ovs-dpctl-top')
end
it "creates the ovs-dpctl-top file" do
expect(@chef_run).to create_cookbook_file("/usr/bin/ovs-dpctl-top")
it 'creates the ovs-dpctl-top file' do
expect(@chef_run).to create_cookbook_file('/usr/bin/ovs-dpctl-top')
end
it "has the proper owner" do
expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
it 'has the proper owner' do
expect(@file.owner).to eq('root')
expect(@file.group).to eq('root')
end
it "has the proper mode" do
expect(sprintf("%o", @file.mode)).to eq "755"
it 'has the proper mode' do
expect(sprintf('%o', @file.mode)).to eq '755'
end
it "has the proper interpreter line" do
it 'has the proper interpreter line' do
expect(@chef_run).to render_file(@file.name).with_content(
/^#!\/usr\/bin\/env python/)
%r{^#!\/usr\/bin\/env python}
)
end
end
describe "ovs_neutron_plugin.ini" do
describe 'ovs_neutron_plugin.ini' do
before do
@file = @chef_run.template "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
@file = @chef_run.template '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "uses default network_vlan_range" do
it 'uses default network_vlan_range' do
expect(@chef_run).not_to render_file(@file.name).with_content(
/^network_vlan_ranges =/)
end
it "uses default tunnel_id_ranges" do
it 'uses default tunnel_id_ranges' do
expect(@chef_run).not_to render_file(@file.name).with_content(
/^tunnel_id_ranges =/)
end
it "uses default integration_bridge" do
it 'uses default integration_bridge' do
expect(@chef_run).to render_file(@file.name).with_content(
"integration_bridge = br-int")
'integration_bridge = br-int')
end
it "uses default tunnel bridge" do
it 'uses default tunnel bridge' do
expect(@chef_run).to render_file(@file.name).with_content(
"tunnel_bridge = br-tun")
'tunnel_bridge = br-tun')
end
it "uses default int_peer_patch_port" do
it 'uses default int_peer_patch_port' do
expect(@chef_run).not_to render_file(@file.name).with_content(
/^int_peer_patch_port =/)
end
it "uses default tun_peer_patch_port" do
it 'uses default tun_peer_patch_port' do
expect(@chef_run).not_to render_file(@file.name).with_content(
/^tun_peer_patch_port =/)
end
it "it has firewall driver" do
it 'it has firewall driver' do
expect(@chef_run).to render_file(@file.name).with_content(
"firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver")
'firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver')
end
it "it uses local_ip from eth0 when local_ip_interface is set" do
expect(@chef_run).to render_file(@file.name).with_content("local_ip = 10.0.0.3")
it 'it uses local_ip from eth0 when local_ip_interface is set' do
expect(@chef_run).to render_file(@file.name).with_content('local_ip = 10.0.0.3')
end
it "sets sqlalchemy attributes" do
it 'sets sqlalchemy attributes' do
expect(@chef_run).to render_file(@file.name).with_content(
"sql_dbpool_enable = False")
'sql_dbpool_enable = False')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_min_pool_size = 1")
'sql_min_pool_size = 1')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_max_pool_size = 5")
'sql_max_pool_size = 5')
expect(@chef_run).to render_file(@file.name).with_content(
"sql_idle_timeout = 3600")
'sql_idle_timeout = 3600')
end
end
end

View File

@ -1,71 +1,72 @@
require_relative "spec_helper"
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::server' do
describe "opensuse" do
describe 'opensuse' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["chef_client"]["splay"] = 300
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['chef_client']['splay'] = 300
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@node = @chef_run.node
@chef_run.converge "openstack-network::server"
@chef_run.converge 'openstack-network::server'
end
it "does not install openstack-neutron when nova networking" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::server"
expect(chef_run).to_not install_package "openstack-neutron"
end
it "installs openstack-neutron packages" do
expect(@chef_run).to install_package "openstack-neutron"
it 'does not install openstack-neutron when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::server'
expect(chef_run).to_not install_package 'openstack-neutron'
end
it "enables openstack-neutron service" do
expect(@chef_run).to enable_service "openstack-neutron"
it 'installs openstack-neutron packages' do
expect(@chef_run).to install_package 'openstack-neutron'
end
it "does not install openvswitch package" do
it 'enables openstack-neutron service' do
expect(@chef_run).to enable_service 'openstack-neutron'
end
it 'does not install openvswitch package' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["chef_client"]["splay"] = 300
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['chef_client']['splay'] = 300
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
chef_run.converge "openstack-network::server"
chef_run.converge 'openstack-network::server'
expect(chef_run).not_to install_package "openstack-neutron-openvswitch"
expect(chef_run).not_to install_package 'openstack-neutron-openvswitch'
end
describe "/etc/sysconfig/neutron" do
describe '/etc/sysconfig/neutron' do
before do
@file = @chef_run.template("/etc/sysconfig/neutron")
@file = @chef_run.template('/etc/sysconfig/neutron')
end
it "has proper owner" do
expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
it 'has proper owner' do
expect(@file.owner).to eq('root')
expect(@file.group).to eq('root')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "has the correct plugin config location - ovs by default" do
it 'has the correct plugin config location - ovs by default' do
expect(@chef_run).to render_file(@file.name).with_content(
"/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini")
'/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini')
end
it "uses linuxbridge when configured to use it" do
it 'uses linuxbridge when configured to use it' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["openstack"]["network"]["interface_driver"] = "neutron.agent.linux.interface.BridgeInterfaceDriver"
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.BridgeInterfaceDriver'
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
chef_run.converge "openstack-network::server"
chef_run.converge 'openstack-network::server'
expect(chef_run).to render_file("/etc/sysconfig/neutron").with_content(
"/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini")
expect(chef_run).to render_file('/etc/sysconfig/neutron').with_content(
'/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
end
end
end

View File

@ -1,39 +1,40 @@
require_relative "spec_helper"
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::server' do
describe "redhat" do
describe 'redhat' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@node = @chef_run.node
@chef_run.converge "openstack-network::server"
@chef_run.converge 'openstack-network::server'
end
it "does not install openstack-neutron when nova networking" do
it 'does not install openstack-neutron when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::server"
expect(chef_run).to_not install_package "openstack-neutron"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::server'
expect(chef_run).to_not install_package 'openstack-neutron'
end
it "installs openstack-neutron packages" do
expect(@chef_run).to install_package "openstack-neutron"
it 'installs openstack-neutron packages' do
expect(@chef_run).to install_package 'openstack-neutron'
end
it "enables openstack-neutron server service" do
expect(@chef_run).to enable_service "neutron-server"
it 'enables openstack-neutron server service' do
expect(@chef_run).to enable_service 'neutron-server'
end
it "does not install openvswitch package" do
it 'does not install openvswitch package' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
chef_run.converge "openstack-network::server"
expect(chef_run).not_to install_package "openvswitch"
expect(chef_run).not_to enable_service "neutron-openvswitch-agent"
chef_run.converge 'openstack-network::server'
expect(chef_run).not_to install_package 'openvswitch'
expect(chef_run).not_to enable_service 'neutron-openvswitch-agent'
end
end
end

View File

@ -1,268 +1,269 @@
# Encoding: utf-8
require_relative 'spec_helper'
describe 'openstack-network::server' do
before do
neutron_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set["openstack"]["mq"]["host"] = "127.0.0.1"
n.set["chef_client"]["splay"] = 300
n.set["openstack"]["network"]["quota"]["driver"] = "my.quota.Driver"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
n.set['openstack']['mq']['host'] = '127.0.0.1'
n.set['chef_client']['splay'] = 300
n.set['openstack']['network']['quota']['driver'] = 'my.quota.Driver'
end
@chef_run.converge "openstack-network::server"
@chef_run.converge 'openstack-network::server'
end
it "does not install neutron-server when nova networking" do
it 'does not install neutron-server when nova networking' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
chef_run.converge "openstack-network::server"
expect(chef_run).to_not install_package "neutron-server"
node.set['openstack']['compute']['network']['service_type'] = 'nova'
chef_run.converge 'openstack-network::server'
expect(chef_run).to_not install_package 'neutron-server'
end
describe "package and services" do
describe 'package and services' do
it "installs neutron packages" do
expect(@chef_run).to install_package "neutron-server"
it 'installs neutron packages' do
expect(@chef_run).to install_package 'neutron-server'
end
it "starts server service" do
expect(@chef_run).to enable_service "neutron-server"
it 'starts server service' do
expect(@chef_run).to enable_service 'neutron-server'
end
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 "neutron-plugin-openvswitch-agent"
expect(@chef_run).not_to enable_service "neutron-plugin-openvswitch-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 'neutron-plugin-openvswitch-agent'
expect(@chef_run).not_to enable_service 'neutron-plugin-openvswitch-agent'
end
end
describe "api-paste.ini" do
describe 'api-paste.ini' do
before do
@file = @chef_run.template "/etc/neutron/api-paste.ini"
@file = @chef_run.template '/etc/neutron/api-paste.ini'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "640"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '640'
end
it "has neutron pass" do
it 'has neutron pass' do
expect(@chef_run).to render_file(@file.name).with_content(
"admin_password = neutron-pass")
'admin_password = neutron-pass')
end
it "has auth_uri" do
it 'has auth_uri' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_uri = http://127.0.0.1:5000/v2.0")
'auth_uri = http://127.0.0.1:5000/v2.0')
end
it "has auth_host" do
it 'has auth_host' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_host = 127.0.0.1")
'auth_host = 127.0.0.1')
end
it "has auth_port" do
it 'has auth_port' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_port = 35357")
'auth_port = 35357')
end
it "has auth_protocol" do
it 'has auth_protocol' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_protocol = http")
'auth_protocol = http')
end
end
it "should create neutron-ha-tool.py script" do
expect(@chef_run).to create_cookbook_file("/usr/local/bin/neutron-ha-tool.py")
it 'should create neutron-ha-tool.py script' do
expect(@chef_run).to create_cookbook_file('/usr/local/bin/neutron-ha-tool.py')
end
describe "neutron.conf" do
describe 'neutron.conf' do
before do
@file = @chef_run.template "/etc/neutron/neutron.conf"
@file = @chef_run.template '/etc/neutron/neutron.conf'
end
it "has proper owner" do
expect(@file.owner).to eq("neutron")
expect(@file.group).to eq("neutron")
it 'has proper owner' do
expect(@file.owner).to eq('neutron')
expect(@file.group).to eq('neutron')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "it sets agent_down_time correctly" do
it 'it sets agent_down_time correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
'agent_down_time = 15')
end
it "it sets agent report interval correctly" do
it 'it sets agent report interval correctly' do
expect(@chef_run).to render_file(@file.name).with_content(
'report_interval = 4')
end
it "it sets root_helper" do
it 'it sets root_helper' do
expect(@chef_run).to render_file(@file.name).with_content(
'root_helper = "sudo neutron-rootwrap /etc/neutron/rootwrap.conf"')
end
it "binds to appropriate api ip" do
it 'binds to appropriate api ip' do
expect(@chef_run).to render_file(@file.name).with_content(
"bind_host = 127.0.0.1")
'bind_host = 127.0.0.1')
end
it "binds to appropriate api port" do
it 'binds to appropriate api port' do
expect(@chef_run).to render_file(@file.name).with_content(
"bind_port = 9696")
'bind_port = 9696')
end
it "has appropriate auth host for agents" do
it 'has appropriate auth host for agents' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_host = 127.0.0.1")
'auth_host = 127.0.0.1')
end
it "has appropriate auth port for agents" do
it 'has appropriate auth port for agents' do
expect(@chef_run).to render_file(@file.name).with_content(
"auth_port = 5000")
'auth_port = 5000')
end
it "has appropriate admin password for agents" do
it 'has appropriate admin password for agents' do
expect(@chef_run).to render_file(@file.name).with_content(
"admin_password = neutron-pass")
'admin_password = neutron-pass')
end
it "has rabbit_host" do
it 'has rabbit_host' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_host=127.0.0.1")
'rabbit_host=127.0.0.1')
end
it "does not have rabbit_hosts" do
it 'does not have rabbit_hosts' do
expect(@chef_run).not_to render_file(@file.name).with_content(
"rabbit_hosts=")
'rabbit_hosts=')
end
it "does not have rabbit_ha_queues" do
it 'does not have rabbit_ha_queues' do
expect(@chef_run).not_to render_file(@file.name).with_content(
"rabbit_ha_queues=")
'rabbit_ha_queues=')
end
it "has rabbit_port" do
it 'has rabbit_port' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_port=5672")
'rabbit_port=5672')
end
it "has rabbit_userid" do
it 'has rabbit_userid' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_userid=guest")
'rabbit_userid=guest')
end
it "has rabbit_password" do
it 'has rabbit_password' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_password=rabbit-pass")
'rabbit_password=rabbit-pass')
end
it "has rabbit_virtual_host" do
it 'has rabbit_virtual_host' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_virtual_host=/")
'rabbit_virtual_host=/')
end
describe "qpid" do
describe 'qpid' do
before do
@file = @chef_run.template "/etc/neutron/neutron.conf"
@chef_run.node.set['openstack']['network']['mq']['service_type'] = "qpid"
@file = @chef_run.template '/etc/neutron/neutron.conf'
@chef_run.node.set['openstack']['network']['mq']['service_type'] = 'qpid'
end
it "has qpid_hostname" do
it 'has qpid_hostname' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_hostname=127.0.0.1")
'qpid_hostname=127.0.0.1')
end
it "has qpid_port" do
it 'has qpid_port' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_port=5672")
'qpid_port=5672')
end
it "has qpid_username" do
it 'has qpid_username' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_username=")
'qpid_username=')
end
it "has qpid_password" do
it 'has qpid_password' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_password=")
'qpid_password=')
end
it "has qpid_sasl_mechanisms" do
it 'has qpid_sasl_mechanisms' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_sasl_mechanisms=")
'qpid_sasl_mechanisms=')
end
it "has qpid_reconnect" do
it 'has qpid_reconnect' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect=true")
'qpid_reconnect=true')
end
it "has qpid_reconnect_timeout" do
it 'has qpid_reconnect_timeout' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect_timeout=0")
'qpid_reconnect_timeout=0')
end
it "has qpid_reconnect_limit" do
it 'has qpid_reconnect_limit' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect_limit=0")
'qpid_reconnect_limit=0')
end
it "has qpid_reconnect_interval_min" do
it 'has qpid_reconnect_interval_min' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect_interval_min=0")
'qpid_reconnect_interval_min=0')
end
it "has qpid_reconnect_interval_max" do
it 'has qpid_reconnect_interval_max' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect_interval_max=0")
'qpid_reconnect_interval_max=0')
end
it "has qpid_reconnect_interval" do
it 'has qpid_reconnect_interval' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_reconnect_interval=0")
'qpid_reconnect_interval=0')
end
it "has qpid_heartbeat" do
it 'has qpid_heartbeat' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_heartbeat=60")
'qpid_heartbeat=60')
end
it "has qpid_protocol" do
it 'has qpid_protocol' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_protocol=tcp")
'qpid_protocol=tcp')
end
it "has qpid_tcp_nodelay" do
it 'has qpid_tcp_nodelay' do
expect(@chef_run).to render_file(@file.name).with_content(
"qpid_tcp_nodelay=true")
'qpid_tcp_nodelay=true')
end
end
it "it does not allow overlapping ips by default" do
it 'it does not allow overlapping ips by default' do
expect(@chef_run).to render_file(@file.name).with_content(
"allow_overlapping_ips = False")
'allow_overlapping_ips = False')
end
it "it has correct default scheduler classes" do
it 'it has correct default scheduler classes' do
expect(@chef_run).to render_file(@file.name).with_content(
"network_scheduler_driver = neutron.scheduler.dhcp_agent_scheduler.ChanceScheduler")
'network_scheduler_driver = neutron.scheduler.dhcp_agent_scheduler.ChanceScheduler')
expect(@chef_run).to render_file(@file.name).with_content(
"router_scheduler_driver = neutron.scheduler.l3_agent_scheduler.ChanceScheduler")
'router_scheduler_driver = neutron.scheduler.l3_agent_scheduler.ChanceScheduler')
end
it "has the overridable default quota values" do
it 'has the overridable default quota values' do
expect(@chef_run).to render_file(@file.name).with_content(
/^quota_items = network,subnet,port/)
expect(@chef_run).to render_file(@file.name).with_content(
@ -279,71 +280,71 @@ describe 'openstack-network::server' do
/^quota_security_group_rule = 100/)
end
it "writes the quota driver properly" do
it 'writes the quota driver properly' do
expect(@chef_run).to render_file(@file.name).with_content(
"quota_driver = my.quota.Driver")
'quota_driver = my.quota.Driver')
end
describe "neutron.conf with rabbit ha" do
describe 'neutron.conf with rabbit ha' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["network"]["rabbit"]["ha"] = true
n.set["chef_client"]["splay"] = 300
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['network']['rabbit']['ha'] = true
n.set['chef_client']['splay'] = 300
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
@chef_run.converge "openstack-network::server"
@chef_run.converge 'openstack-network::server'
end
it "has rabbit_hosts" do
it 'has rabbit_hosts' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672")
'rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672')
end
it "has rabbit_ha_queues" do
it 'has rabbit_ha_queues' do
expect(@chef_run).to render_file(@file.name).with_content(
"rabbit_ha_queues=True")
'rabbit_ha_queues=True')
end
it "does not have rabbit_host" do
it 'does not have rabbit_host' do
expect(@chef_run).not_to render_file(@file.name).with_content(
"rabbit_host=127.0.0.1")
'rabbit_host=127.0.0.1')
end
it "does not have rabbit_port" do
it 'does not have rabbit_port' do
expect(@chef_run).not_to render_file(@file.name).with_content(
"rabbit_port=5672")
'rabbit_port=5672')
end
end
describe "/etc/default/neutron-server" do
describe '/etc/default/neutron-server' do
before do
@file = @chef_run.template(
"/etc/default/neutron-server")
'/etc/default/neutron-server')
end
it "has proper owner" do
expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
it 'has proper owner' do
expect(@file.owner).to eq('root')
expect(@file.group).to eq('root')
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "has a correct plugin config path" do
it 'has a correct plugin config path' do
expect(@chef_run).to render_file(@file.name).with_content(
"/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini")
'/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini')
end
end
it "does not install sysconfig template" do
it 'does not install sysconfig template' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
n.set['openstack']['compute']['network']['service_type'] = 'neutron'
end
stub_command(/python/).and_return(true)
chef_run.converge "openstack-network::server"
expect(chef_run).not_to create_file("/etc/sysconfig/neutron")
chef_run.converge 'openstack-network::server'
expect(chef_run).not_to create_file('/etc/sysconfig/neutron')
end
end
end

View File

@ -1,42 +1,43 @@
require "chefspec"
require "chef/application"
# Encoding: utf-8
require 'chefspec'
require 'chef/application'
::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = {
:platform => "opensuse",
:version => "12.3",
:log_level => ::LOG_LEVEL
platform: 'opensuse',
version: '12.3',
log_level: ::LOG_LEVEL
}
::REDHAT_OPTS = {
:platform => "redhat",
:version => "6.3",
:log_level => ::LOG_LEVEL
platform: 'redhat',
version: '6.3',
log_level: ::LOG_LEVEL
}
::UBUNTU_OPTS = {
:platform => "ubuntu",
:version => "12.04",
:log_level => ::LOG_LEVEL
platform: 'ubuntu',
version: '12.04',
log_level: ::LOG_LEVEL
}
MOCK_NODE_NETWORK_DATA =
{
"ipaddress" => '10.0.0.2',
"fqdn" => 'localhost.localdomain',
"hostname" => 'localhost',
"network" => {
"default_interface" => "eth0",
"interfaces" => {
"eth0" => {
"addresses" => {
"fe80::a00:27ff:feca:ab08" => {"scope" => "Link", "prefixlen" => "64", "family" => "inet6"},
"10.0.0.2" => {"netmask" => "255.255.255.0", "broadcast" => "10.0.0.255", "family" => "inet"},
"08:00:27:CA:AB:08" => {"family" => "lladdr"}
'ipaddress' => '10.0.0.2',
'fqdn' => 'localhost.localdomain',
'hostname' => 'localhost',
'network' => {
'default_interface' => 'eth0',
'interfaces' => {
'eth0' => {
'addresses' => {
'fe80::a00:27ff:feca:ab08' => { 'scope' => 'Link', 'prefixlen' => '64', 'family' => 'inet6' },
'10.0.0.2' => { 'netmask' => '255.255.255.0', 'broadcast' => '10.0.0.255', 'family' => 'inet' },
'08:00:27:CA:AB:08' => { 'family' => 'lladdr' }
},
},
"lo" => {
"addresses" => {
"::1" => {"scope" => "Node", "prefixlen" => "128", "family" => "inet6"},
"127.0.0.1" => {"netmask" => "255.0.0.0", "family" => "inet"}
'lo' => {
'addresses' => {
'::1' => { 'scope' => 'Node', 'prefixlen' => '128', 'family' => 'inet6' },
'127.0.0.1' => { 'netmask' => '255.0.0.0', 'family' => 'inet' }
},
},
},
@ -44,35 +45,34 @@ MOCK_NODE_NETWORK_DATA =
}
def neutron_stubs
::Chef::Recipe.any_instance.stub(:rabbit_servers).
and_return "1.1.1.1:5672,2.2.2.2:5672"
::Chef::Recipe.any_instance.stub(:config_by_role).
with("rabbitmq-server", "queue").and_return(
{'host' => 'rabbit-host', 'port' => 'rabbit-port'}
::Chef::Recipe.any_instance.stub(:rabbit_servers)
.and_return '1.1.1.1:5672,2.2.2.2:5672'
::Chef::Recipe.any_instance.stub(:config_by_role)
.with('rabbitmq-server', 'queue').and_return(
host: 'rabbit-host',
port: 'rabbit-port'
)
::Chef::Recipe.any_instance.stub(:config_by_role).
with("glance-api", "glance").and_return []
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
::Chef::Recipe.any_instance.stub(:db_password).and_return "neutron-pass"
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "neutron_metadata_secret").
and_return "metadata-secret"
::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
::Chef::Recipe.any_instance.stub(:service_password).and_return String.new
::Chef::Recipe.any_instance.stub(:service_password).with("openstack-network").
and_return "neutron-pass"
::Chef::Recipe.any_instance.stub(:user_password).with("guest").
and_return("rabbit-password")
::Chef::Recipe.any_instance.stub(:config_by_role)
.with('glance-api', 'glance').and_return []
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'openstack_identity_bootstrap_token')
.and_return 'bootstrap-token'
::Chef::Recipe.any_instance.stub(:db_password).and_return 'neutron-pass'
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'neutron_metadata_secret')
.and_return 'metadata-secret'
::Chef::Recipe.any_instance.stub(:user_password).and_return ''
::Chef::Recipe.any_instance.stub(:service_password).and_return ''
::Chef::Recipe.any_instance.stub(:service_password).with('openstack-network')
.and_return 'neutron-pass'
::Chef::Recipe.any_instance.stub(:user_password).with('guest')
.and_return('rabbit-password')
::Chef::Application.stub(:fatal!)
stub_command("dpkg -l | grep openvswitch-switch | grep 1.10.2-1").and_return(true)
stub_command('dpkg -l | grep openvswitch-switch | grep 1.10.2-1').and_return(true)
stub_command("ovs-vsctl show | grep 'Bridge br-int'").and_return(false)
stub_command("ovs-vsctl show | grep 'Bridge br-tun'").and_return(false)
stub_command("ip link show eth1").and_return(false)
stub_command('ip link show eth1').and_return(false)
end
at_exit { ChefSpec::Coverage.report! }