Initial network Pike updates

- Switched default linter to cookstyle
- Renamed rake tasks to better conform with Chef conventions

Change-Id: I5dd1971392fdf282d0f214dfce9dcbecc18542a8
This commit is contained in:
Samuel Cassiba 2017-08-23 21:14:27 -04:00
parent 3868368eca
commit 9de60304f4
19 changed files with 31 additions and 60 deletions

View File

@ -1,5 +1,3 @@
inherit_from: .rubocop_todo.yml
AllCops: AllCops:
Include: Include:
- metadata.rb - metadata.rb

View File

@ -1,27 +0,0 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-17 14:16:15 +0200 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 42
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 122
# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'recipes/_bridge_config_example.rb'
- 'recipes/default.rb'
- 'recipes/fwaas.rb'
- 'recipes/identity_registration.rb'
- 'recipes/l3_agent.rb'
- 'recipes/lbaas.rb'
- 'recipes/ml2_openvswitch.rb'
- 'recipes/server.rb'
- 'recipes/vpnaas.rb'

View File

@ -1,20 +1,20 @@
task default: ["test"] task default: ["test"]
task :test => [:lint, :style, :unit] task :test => [:syntax, :lint, :unit]
desc "Vendor the cookbooks in the Berksfile" desc "Vendor the cookbooks in the Berksfile"
task :berks_prep do task :berks_prep do
sh %{chef exec berks vendor} sh %{chef exec berks vendor}
end end
desc "Run FoodCritic (lint) tests" desc "Run FoodCritic (syntax) tests"
task :lint do task :syntax do
sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} sh %{chef exec foodcritic --exclude spec -f any .}
end end
desc "Run RuboCop (style) tests" desc "Run RuboCop (lint) tests"
task :style do task :lint do
sh %{chef exec rubocop} sh %{chef exec cookstyle}
end end
desc "Run RSpec (unit) tests" desc "Run RSpec (unit) tests"

View File

@ -67,6 +67,6 @@ service 'neutron-dhcp-agent' do
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
'template [/etc/neutron/dnsmasq.conf]', 'template [/etc/neutron/dnsmasq.conf]',
"template[#{node['openstack']['network_dhcp']['config_file']}]", "template[#{node['openstack']['network_dhcp']['config_file']}]",
'rpm_package[dnsmasq]' 'rpm_package[dnsmasq]',
] ]
end end

View File

@ -33,7 +33,7 @@ auth_url = ::URI.decode identity_admin_endpoint.to_s
interfaces = { interfaces = {
public: { url: public_endpoint('network') }, public: { url: public_endpoint('network') },
internal: { url: internal_endpoint('network') }, internal: { url: internal_endpoint('network') },
admin: { url: admin_endpoint('network') } admin: { url: admin_endpoint('network') },
} }
service_pass = get_password 'service', 'openstack-network' service_pass = get_password 'service', 'openstack-network'
@ -58,7 +58,7 @@ connection_params = {
openstack_username: admin_user, openstack_username: admin_user,
openstack_api_key: admin_pass, openstack_api_key: admin_pass,
openstack_project_name: admin_project, openstack_project_name: admin_project,
openstack_domain_name: admin_domain openstack_domain_name: admin_domain,
} }
# Register Network Service # Register Network Service

View File

@ -64,7 +64,7 @@ service 'neutron-l3-agent' do
action [:enable, :start] action [:enable, :start]
subscribes :restart, [ subscribes :restart, [
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
"template[#{node['openstack']['network_fwaas']['config_file']}]" "template[#{node['openstack']['network_fwaas']['config_file']}]",
] ]
end end
end end

View File

@ -65,6 +65,6 @@ service 'neutron-metadata-agent' do
action [:enable, :start] action [:enable, :start]
subscribes :restart, [ subscribes :restart, [
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
"template[#{node['openstack']['network_metadata']['config_file']}]" "template[#{node['openstack']['network_metadata']['config_file']}]",
] ]
end end

View File

@ -46,6 +46,6 @@ service 'neutron-metering-agent' do
action [:enable, :start] action [:enable, :start]
subscribes :restart, [ subscribes :restart, [
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
"template[#{node['openstack']['network_metering']['config_file']}]" "template[#{node['openstack']['network_metering']['config_file']}]",
] ]
end end

View File

@ -45,6 +45,6 @@ service 'neutron-openvswitch-agent' do
action [:enable, :start] action [:enable, :start]
subscribes :restart, [ subscribes :restart, [
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
"template[#{plugin_file_path}]" "template[#{plugin_file_path}]",
] ]
end end

View File

@ -103,7 +103,7 @@ service 'neutron-server' do
subscribes :restart, [ subscribes :restart, [
plugin_templates, plugin_templates,
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
'remote_file[/etc/neutron/policy.json]' 'remote_file[/etc/neutron/policy.json]',
].flatten ].flatten
end end

View File

@ -69,6 +69,6 @@ service 'neutron-vpn-agent' do
subscribes :restart, [ subscribes :restart, [
'template[/etc/neutron/neutron.conf]', 'template[/etc/neutron/neutron.conf]',
"template[#{node['openstack']['network_vpnaas']['config_file']}]", "template[#{node['openstack']['network_vpnaas']['config_file']}]",
"template[#{node['openstack']['network_fwaas']['config_file']}]" "template[#{node['openstack']['network_fwaas']['config_file']}]",
] ]
end end

View File

@ -55,7 +55,7 @@ describe 'openstack-network' do
%r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$},
/^use_syslog = false$/, /^use_syslog = false$/,
/^syslog_log_facility = syslog$/, /^syslog_log_facility = syslog$/,
/^syslog_log_level = ERROR$/ /^syslog_log_level = ERROR$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
@ -72,7 +72,7 @@ describe 'openstack-network' do
/^core_plugin = ml2$/, /^core_plugin = ml2$/,
%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$},
/^bind_host = 127\.0\.0\.1$/, /^bind_host = 127\.0\.0\.1$/,
/^bind_port = 9696$/ /^bind_port = 9696$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
@ -80,7 +80,7 @@ describe 'openstack-network' do
end end
end end
[ [
%r{^root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf$} %r{^root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf$},
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
@ -94,7 +94,7 @@ describe 'openstack-network' do
/^project_domain_name = Default/, /^project_domain_name = Default/,
%r{^auth_url = http://127\.0\.0\.1:5000/v3$}, %r{^auth_url = http://127\.0\.0\.1:5000/v3$},
/^password = neutron-pass$/, /^password = neutron-pass$/,
/^auth_type = v3password$/ /^auth_type = v3password$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
@ -108,7 +108,7 @@ describe 'openstack-network' do
/^username = nova$/, /^username = nova$/,
/^user_domain_name = Default/, /^user_domain_name = Default/,
/^project_domain_name = Default/, /^project_domain_name = Default/,
/^project_name = service$/ /^project_name = service$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
@ -116,7 +116,7 @@ describe 'openstack-network' do
end end
end end
[ [
%(connection = mysql+pymysql://neutron:neutron@127.0.0.1:3306/neutron?charset=utf8) %(connection = mysql+pymysql://neutron:neutron@127.0.0.1:3306/neutron?charset=utf8),
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)

View File

@ -18,7 +18,7 @@ describe 'openstack-network::identity_registration' do
openstack_username: 'admin', openstack_username: 'admin',
openstack_api_key: 'admin-pass', openstack_api_key: 'admin-pass',
openstack_project_name: 'admin', openstack_project_name: 'admin',
openstack_domain_name: 'default' openstack_domain_name: 'default',
} }
service_name = 'neutron' service_name = 'neutron'
service_type = 'network' service_type = 'network'

View File

@ -33,7 +33,7 @@ describe 'openstack-network::lbaas' do
/^periodic_interval = 10$/, /^periodic_interval = 10$/,
/^ovs_use_veth = false$/, /^ovs_use_veth = false$/,
/^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/, /^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/,
/^device_driver = neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver$/ /^device_driver = neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver$/,
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end

View File

@ -31,7 +31,7 @@ describe 'openstack-network::metering_agent' do
it do it do
[ [
/^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/, /^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/,
/^driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver$/ /^driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver$/,
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end

View File

@ -37,7 +37,7 @@ describe 'openstack-network::ml2_linuxbridge' do
chef_run.template('/etc/neutron/plugins/ml2/linuxbridge_agent.ini') chef_run.template('/etc/neutron/plugins/ml2/linuxbridge_agent.ini')
end end
[ [
/^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/ /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)

View File

@ -38,7 +38,7 @@ describe 'openstack-network::ml2_linuxbridge' do
chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini') chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
end end
[ [
/^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/ /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/,
].each do |line| ].each do |line|
it do it do
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)

View File

@ -102,7 +102,7 @@ describe 'openstack-network::server' do
%r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$},
/^use_syslog = false$/, /^use_syslog = false$/,
/^syslog_log_facility = syslog$/, /^syslog_log_facility = syslog$/,
/^syslog_log_level = ERROR$/ /^syslog_log_level = ERROR$/,
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end

View File

@ -11,17 +11,17 @@ LOG_LEVEL = :fatal
REDHAT_OPTS = { REDHAT_OPTS = {
platform: 'redhat', platform: 'redhat',
version: '7.1', version: '7.1',
log_level: LOG_LEVEL log_level: LOG_LEVEL,
}.freeze }.freeze
UBUNTU_OPTS = { UBUNTU_OPTS = {
platform: 'ubuntu', platform: 'ubuntu',
version: '16.04', version: '16.04',
log_level: LOG_LEVEL log_level: LOG_LEVEL,
}.freeze }.freeze
CENTOS_OPTS = { CENTOS_OPTS = {
platform: 'centos', platform: 'centos',
version: '7.2.1511', version: '7.2.1511',
log_level: LOG_LEVEL log_level: LOG_LEVEL,
}.freeze }.freeze
shared_context 'neutron-stubs' do shared_context 'neutron-stubs' do