From 9de60304f4e79259d83631b27649a0db39610ecc Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Wed, 23 Aug 2017 21:14:27 -0400 Subject: [PATCH] Initial network Pike updates - Switched default linter to cookstyle - Renamed rake tasks to better conform with Chef conventions Change-Id: I5dd1971392fdf282d0f214dfce9dcbecc18542a8 --- .rubocop.yml | 2 -- .rubocop_todo.yml | 27 --------------------------- Rakefile | 14 +++++++------- recipes/dhcp_agent.rb | 2 +- recipes/identity_registration.rb | 4 ++-- recipes/l3_agent.rb | 2 +- recipes/metadata_agent.rb | 2 +- recipes/metering_agent.rb | 2 +- recipes/openvswitch_agent.rb | 2 +- recipes/server.rb | 2 +- recipes/vpnaas.rb | 2 +- spec/default_spec.rb | 12 ++++++------ spec/identity_registration_spec.rb | 2 +- spec/lbaas_spec.rb | 2 +- spec/metering_agent_spec.rb | 2 +- spec/ml2_linuxbridge-redhat_spec.rb | 2 +- spec/ml2_linuxbridge_spec.rb | 2 +- spec/server_spec.rb | 2 +- spec/spec_helper.rb | 6 +++--- 19 files changed, 31 insertions(+), 60 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 5e0be9fb..253be243 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,3 @@ -inherit_from: .rubocop_todo.yml - AllCops: Include: - metadata.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 0f8ebc46..00000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -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' diff --git a/Rakefile b/Rakefile index 676e7d46..c9edb131 100644 --- a/Rakefile +++ b/Rakefile @@ -1,20 +1,20 @@ task default: ["test"] -task :test => [:lint, :style, :unit] +task :test => [:syntax, :lint, :unit] desc "Vendor the cookbooks in the Berksfile" task :berks_prep do sh %{chef exec berks vendor} end -desc "Run FoodCritic (lint) tests" -task :lint do - sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} +desc "Run FoodCritic (syntax) tests" +task :syntax do + sh %{chef exec foodcritic --exclude spec -f any .} end -desc "Run RuboCop (style) tests" -task :style do - sh %{chef exec rubocop} +desc "Run RuboCop (lint) tests" +task :lint do + sh %{chef exec cookstyle} end desc "Run RSpec (unit) tests" diff --git a/recipes/dhcp_agent.rb b/recipes/dhcp_agent.rb index 5a63abc6..088e628f 100644 --- a/recipes/dhcp_agent.rb +++ b/recipes/dhcp_agent.rb @@ -67,6 +67,6 @@ service 'neutron-dhcp-agent' do 'template[/etc/neutron/neutron.conf]', 'template [/etc/neutron/dnsmasq.conf]', "template[#{node['openstack']['network_dhcp']['config_file']}]", - 'rpm_package[dnsmasq]' + 'rpm_package[dnsmasq]', ] end diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index fb70fb7b..9bbb92c2 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -33,7 +33,7 @@ auth_url = ::URI.decode identity_admin_endpoint.to_s interfaces = { public: { url: public_endpoint('network') }, internal: { url: internal_endpoint('network') }, - admin: { url: admin_endpoint('network') } + admin: { url: admin_endpoint('network') }, } service_pass = get_password 'service', 'openstack-network' @@ -58,7 +58,7 @@ connection_params = { openstack_username: admin_user, openstack_api_key: admin_pass, openstack_project_name: admin_project, - openstack_domain_name: admin_domain + openstack_domain_name: admin_domain, } # Register Network Service diff --git a/recipes/l3_agent.rb b/recipes/l3_agent.rb index 9f89543d..78971528 100644 --- a/recipes/l3_agent.rb +++ b/recipes/l3_agent.rb @@ -64,7 +64,7 @@ service 'neutron-l3-agent' do action [:enable, :start] subscribes :restart, [ 'template[/etc/neutron/neutron.conf]', - "template[#{node['openstack']['network_fwaas']['config_file']}]" + "template[#{node['openstack']['network_fwaas']['config_file']}]", ] end end diff --git a/recipes/metadata_agent.rb b/recipes/metadata_agent.rb index 4c730ab9..d29d8dac 100644 --- a/recipes/metadata_agent.rb +++ b/recipes/metadata_agent.rb @@ -65,6 +65,6 @@ service 'neutron-metadata-agent' do action [:enable, :start] subscribes :restart, [ 'template[/etc/neutron/neutron.conf]', - "template[#{node['openstack']['network_metadata']['config_file']}]" + "template[#{node['openstack']['network_metadata']['config_file']}]", ] end diff --git a/recipes/metering_agent.rb b/recipes/metering_agent.rb index a7629d5b..8e20d52a 100644 --- a/recipes/metering_agent.rb +++ b/recipes/metering_agent.rb @@ -46,6 +46,6 @@ service 'neutron-metering-agent' do action [:enable, :start] subscribes :restart, [ 'template[/etc/neutron/neutron.conf]', - "template[#{node['openstack']['network_metering']['config_file']}]" + "template[#{node['openstack']['network_metering']['config_file']}]", ] end diff --git a/recipes/openvswitch_agent.rb b/recipes/openvswitch_agent.rb index 652f0a3c..9fbce523 100644 --- a/recipes/openvswitch_agent.rb +++ b/recipes/openvswitch_agent.rb @@ -45,6 +45,6 @@ service 'neutron-openvswitch-agent' do action [:enable, :start] subscribes :restart, [ 'template[/etc/neutron/neutron.conf]', - "template[#{plugin_file_path}]" + "template[#{plugin_file_path}]", ] end diff --git a/recipes/server.rb b/recipes/server.rb index 06e9b76d..aaaf2fc1 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -103,7 +103,7 @@ service 'neutron-server' do subscribes :restart, [ plugin_templates, 'template[/etc/neutron/neutron.conf]', - 'remote_file[/etc/neutron/policy.json]' + 'remote_file[/etc/neutron/policy.json]', ].flatten end diff --git a/recipes/vpnaas.rb b/recipes/vpnaas.rb index e5af11eb..f49c9cfd 100644 --- a/recipes/vpnaas.rb +++ b/recipes/vpnaas.rb @@ -69,6 +69,6 @@ service 'neutron-vpn-agent' do subscribes :restart, [ 'template[/etc/neutron/neutron.conf]', "template[#{node['openstack']['network_vpnaas']['config_file']}]", - "template[#{node['openstack']['network_fwaas']['config_file']}]" + "template[#{node['openstack']['network_fwaas']['config_file']}]", ] end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 5374e4a7..d90167b4 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -55,7 +55,7 @@ describe 'openstack-network' do %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, /^use_syslog = false$/, /^syslog_log_facility = syslog$/, - /^syslog_log_level = ERROR$/ + /^syslog_log_level = ERROR$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) @@ -72,7 +72,7 @@ describe 'openstack-network' do /^core_plugin = ml2$/, %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, /^bind_host = 127\.0\.0\.1$/, - /^bind_port = 9696$/ + /^bind_port = 9696$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) @@ -80,7 +80,7 @@ describe 'openstack-network' do 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| it do expect(chef_run).to render_config_file(file.name) @@ -94,7 +94,7 @@ describe 'openstack-network' do /^project_domain_name = Default/, %r{^auth_url = http://127\.0\.0\.1:5000/v3$}, /^password = neutron-pass$/, - /^auth_type = v3password$/ + /^auth_type = v3password$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) @@ -108,7 +108,7 @@ describe 'openstack-network' do /^username = nova$/, /^user_domain_name = Default/, /^project_domain_name = Default/, - /^project_name = service$/ + /^project_name = service$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) @@ -116,7 +116,7 @@ describe 'openstack-network' do 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| it do expect(chef_run).to render_config_file(file.name) diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index f1c4bee7..ce096507 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -18,7 +18,7 @@ describe 'openstack-network::identity_registration' do openstack_username: 'admin', openstack_api_key: 'admin-pass', openstack_project_name: 'admin', - openstack_domain_name: 'default' + openstack_domain_name: 'default', } service_name = 'neutron' service_type = 'network' diff --git a/spec/lbaas_spec.rb b/spec/lbaas_spec.rb index 70a2fc79..29bcd40d 100644 --- a/spec/lbaas_spec.rb +++ b/spec/lbaas_spec.rb @@ -33,7 +33,7 @@ describe 'openstack-network::lbaas' do /^periodic_interval = 10$/, /^ovs_use_veth = false$/, /^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| expect(chef_run).to render_file(file.name).with_content(line) end diff --git a/spec/metering_agent_spec.rb b/spec/metering_agent_spec.rb index 0536fae8..ef6657f3 100644 --- a/spec/metering_agent_spec.rb +++ b/spec/metering_agent_spec.rb @@ -31,7 +31,7 @@ describe 'openstack-network::metering_agent' do it do [ /^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| expect(chef_run).to render_file(file.name).with_content(line) end diff --git a/spec/ml2_linuxbridge-redhat_spec.rb b/spec/ml2_linuxbridge-redhat_spec.rb index 0993eb88..f6cccc4e 100644 --- a/spec/ml2_linuxbridge-redhat_spec.rb +++ b/spec/ml2_linuxbridge-redhat_spec.rb @@ -37,7 +37,7 @@ describe 'openstack-network::ml2_linuxbridge' do chef_run.template('/etc/neutron/plugins/ml2/linuxbridge_agent.ini') end [ - /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/ + /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) diff --git a/spec/ml2_linuxbridge_spec.rb b/spec/ml2_linuxbridge_spec.rb index dd650007..7e5e4ebe 100644 --- a/spec/ml2_linuxbridge_spec.rb +++ b/spec/ml2_linuxbridge_spec.rb @@ -38,7 +38,7 @@ describe 'openstack-network::ml2_linuxbridge' do chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini') end [ - /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/ + /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/, ].each do |line| it do expect(chef_run).to render_config_file(file.name) diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 38347afe..7fb117c7 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -102,7 +102,7 @@ describe 'openstack-network::server' do %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, /^use_syslog = false$/, /^syslog_log_facility = syslog$/, - /^syslog_log_level = ERROR$/ + /^syslog_log_level = ERROR$/, ].each do |line| expect(chef_run).to render_file(file.name).with_content(line) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d1d46aa4..faff9e33 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,17 +11,17 @@ LOG_LEVEL = :fatal REDHAT_OPTS = { platform: 'redhat', version: '7.1', - log_level: LOG_LEVEL + log_level: LOG_LEVEL, }.freeze UBUNTU_OPTS = { platform: 'ubuntu', version: '16.04', - log_level: LOG_LEVEL + log_level: LOG_LEVEL, }.freeze CENTOS_OPTS = { platform: 'centos', version: '7.2.1511', - log_level: LOG_LEVEL + log_level: LOG_LEVEL, }.freeze shared_context 'neutron-stubs' do