diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ca778387..2eb50a23 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,72 +1,13 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-08-17 14:16:04 +0200 using RuboCop version 0.47.1. +# on 2017-08-25 09:18:09 -0400 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: 1 -Metrics/AbcSize: - Max: 16 - -# Offense count: 28 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 373 - -# Offense count: 2 -# Configuration parameters: CountComments. -Metrics/MethodLength: - Max: 19 - -# Offense count: 8 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'recipes/api-metadata.rb' - - 'recipes/api-os-compute.rb' - - 'recipes/compute.rb' - - 'recipes/identity_registration.rb' - - 'recipes/libvirt_rbd.rb' - - 'recipes/nova-common.rb' - - 'recipes/nova-setup.rb' - - 'recipes/placement_api.rb' - -# Offense count: 7 -Style/Documentation: - Exclude: - - 'spec/**/*' - - 'test/**/*' - - 'recipes/api-metadata.rb' - - 'recipes/api-os-compute.rb' - - 'recipes/compute.rb' - - 'recipes/identity_registration.rb' - - 'recipes/libvirt_rbd.rb' - - 'recipes/nova-setup.rb' - - 'recipes/placement_api.rb' - # Offense count: 3 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - 'recipes/libvirt.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Exclude: - - 'recipes/libvirt.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'spec/identity_registration_spec.rb' - - 'spec/placement_api_spec.rb' - - 'spec/spec_helper.rb' diff --git a/Rakefile b/Rakefile index 676e7d46..932f2ad3 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 CookStyle (lint) tests" +task :lint do + sh %{chef exec cookstyle} end desc "Run RSpec (unit) tests" diff --git a/attributes/default.rb b/attributes/default.rb index c38eab65..32e3c1ba 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -8,8 +8,8 @@ default['enable_monit'] = false # OS provides packages # Set to some text value if you want templated config files # to contain a custom banner at the top of the written file default['openstack']['compute']['custom_template_banner'] = ' -# This file autogenerated by Chef -# Do not edit, changes will be overwritten +# This file is automatically generated by Chef +# Any changes will be overwritten ' # The name of the Chef role that knows about the message queue server @@ -92,7 +92,7 @@ default['openstack']['compute']['ratelimit']['settings'] = { 'create-servers-limit' => { 'verb' => 'POST', 'uri' => '*/servers', 'regex' => '^/servers', 'limit' => '50', 'interval' => 'DAY' }, 'generic-put-limit' => { 'verb' => 'PUT', 'uri' => '*', 'regex' => '.*', 'limit' => '10', 'interval' => 'MINUTE' }, 'changes-since-limit' => { 'verb' => 'GET', 'uri' => '*changes-since*', 'regex' => '.*changes-since.*', 'limit' => '3', 'interval' => 'MINUTE' }, - 'generic-delete-limit' => { 'verb' => 'DELETE', 'uri' => '*', 'regex' => '.*', 'limit' => '100', 'interval' => 'MINUTE' } + 'generic-delete-limit' => { 'verb' => 'DELETE', 'uri' => '*', 'regex' => '.*', 'limit' => '100', 'interval' => 'MINUTE' }, } # Metering settings @@ -169,7 +169,7 @@ when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this 'common_packages' => ['openstack-nova-common'], 'iscsi_helper' => 'ietadm', 'volume_packages' => ['sysfsutils', 'sg3_utils', 'device-mapper-multipath'], - 'package_overrides' => '' + 'package_overrides' => '', } when 'debian' default['openstack']['compute']['platform'] = { @@ -205,7 +205,7 @@ when 'debian' 'common_packages' => ['nova-common'], 'iscsi_helper' => 'tgtadm', 'volume_packages' => ['sysfsutils', 'sg3-utils', 'multipath-tools'], - 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" + 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", } end diff --git a/attributes/nova_conf.rb b/attributes/nova_conf.rb index ccadbea0..63031969 100644 --- a/attributes/nova_conf.rb +++ b/attributes/nova_conf.rb @@ -13,12 +13,6 @@ default['openstack']['compute']['conf'].tap do |conf| conf['DEFAULT']['log_config'] = '/etc/openstack/logging.conf' end - conf['DEFAULT']['use_neutron'] = 'true' - conf['DEFAULT']['linuxnet_interface_driver'] = 'nova.network.linux_net.LinuxOVSInterfaceDriver' - conf['DEFAULT']['firewall_driver'] = 'nova.virt.firewall.NoopFirewallDriver' - conf['DEFAULT']['default_floating_pool'] = 'public' # not listed - conf['DEFAULT']['dns_server'] = '8.8.8.8' # [] in docs - # [keystone_authtoken] conf['keystone_authtoken']['auth_type'] = 'v3password' conf['keystone_authtoken']['region_name'] = node['openstack']['region'] diff --git a/recipes/api-metadata.rb b/recipes/api-metadata.rb index e9f89cbc..c143bcb2 100644 --- a/recipes/api-metadata.rb +++ b/recipes/api-metadata.rb @@ -49,6 +49,6 @@ service 'nova-api-metadata' do action [:enable, :start] subscribes :restart, [ 'template[/etc/nova/nova.conf]', - 'template[/etc/nova/api-paste.ini]' + 'template[/etc/nova/api-paste.ini]', ] end diff --git a/recipes/api-os-compute.rb b/recipes/api-os-compute.rb index b11c6826..082c6ab7 100644 --- a/recipes/api-os-compute.rb +++ b/recipes/api-os-compute.rb @@ -57,7 +57,7 @@ service 'nova-api-os-compute' do action [:enable, :start] subscribes :restart, [ 'template[/etc/nova/nova.conf]', - 'template[/etc/nova/api-paste.ini]' + 'template[/etc/nova/api-paste.ini]', ] end diff --git a/recipes/compute.rb b/recipes/compute.rb index 9285475a..75050340 100644 --- a/recipes/compute.rb +++ b/recipes/compute.rb @@ -72,6 +72,6 @@ service 'nova-compute' do action [:enable, :start] subscribes :restart, [ 'template[/etc/nova/nova.conf]', - 'file[docker.filter]' + 'file[docker.filter]', ] end diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index d2b8fe95..186eba88 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -29,11 +29,11 @@ identity_admin_endpoint = admin_endpoint 'identity' interfaces = { public: { url: public_endpoint('compute-api') }, internal: { url: internal_endpoint('compute-api') }, - admin: { url: admin_endpoint('compute-api') } + admin: { url: admin_endpoint('compute-api') }, } placement_interfaces = { public: { url: public_endpoint('placement-api') }, - internal: { url: internal_endpoint('placement-api') } + internal: { url: internal_endpoint('placement-api') }, } auth_url = ::URI.decode identity_admin_endpoint.to_s service_pass = get_password 'service', 'openstack-compute' @@ -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 Compute Services diff --git a/recipes/libvirt.rb b/recipes/libvirt.rb index f724e440..e5aae2fc 100644 --- a/recipes/libvirt.rb +++ b/recipes/libvirt.rb @@ -40,17 +40,16 @@ def update_grub_default_kernel(flavor = 'default') f.lines.each do |line| current_default = line.scan(/\d/).first.to_i if line.start_with?('default') - if line.start_with?('title') - if flavor.eql?('xen') - # found boot index - break if line.include?('Xen') - else - # take first kernel as default, unless we are searching for xen - # kernel - break - end - default_boot += 1 + next unless line.start_with?('title') + if flavor.eql?('xen') + # found boot index + break if line.include?('Xen') + else + # take first kernel as default, unless we are searching for xen + # kernel + break end + default_boot += 1 end end diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 5e367eef..d06644a3 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -15,7 +15,7 @@ describe 'openstack-compute::identity_registration' do openstack_username: 'admin', openstack_api_key: 'admin', openstack_project_name: 'admin', - openstack_domain_name: 'default' + openstack_domain_name: 'default', } service_name = 'nova' service_type = 'compute' @@ -49,7 +49,7 @@ describe 'openstack-compute::identity_registration' do ) end - it "registers placement service" do + it 'registers placement service' do expect(chef_run).to create_openstack_service( placement_service_name ).with( @@ -74,7 +74,7 @@ describe 'openstack-compute::identity_registration' do end end - context "registers placement endpoint" do + context 'registers placement endpoint' do %w(internal public).each do |interface| it "creates #{interface} endpoint with default values" do expect(chef_run).to create_openstack_endpoint( @@ -112,7 +112,7 @@ describe 'openstack-compute::identity_registration' do ) end - context "grants user roles" do + context 'grants user roles' do [service_user, placement_service_user].each do |user_name| it do expect(chef_run).to grant_domain_openstack_user( diff --git a/spec/libvirt_spec.rb b/spec/libvirt_spec.rb index 3e0cfa64..1fcbf6f4 100644 --- a/spec/libvirt_spec.rb +++ b/spec/libvirt_spec.rb @@ -95,7 +95,7 @@ describe 'openstack-compute::libvirt' do it 'template contents' do [ /^start_libvirtd="yes"$/, - /^libvirtd_opts="-l"$/ + /^libvirtd_opts="-l"$/, ].each do |line| expect(chef_run).to render_file(file.name).with_content(line) end diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb index 31854200..f490f6dc 100644 --- a/spec/nova-common_spec.rb +++ b/spec/nova-common_spec.rb @@ -8,7 +8,7 @@ describe 'openstack-compute::nova-common' do let(:node) { runner.node } let(:chef_run) do node.set['openstack']['mq'] = { - 'host' => '127.0.0.1' + 'host' => '127.0.0.1', } node.set['openstack']['mq']['compute']['rabbit']['ha'] = true @@ -128,7 +128,7 @@ describe 'openstack-compute::nova-common' do 'username = nova', 'project_name = service', 'user_domain_name = Default', - 'project_domain_name = Default' + 'project_domain_name = Default', ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('keystone_authtoken', /^#{Regexp.quote(line)}$/) @@ -145,7 +145,7 @@ describe 'openstack-compute::nova-common' do 'username = placement', 'project_name = service', 'user_domain_name = Default', - 'project_domain_name = Default' + 'project_domain_name = Default', ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('placement', /^#{Regexp.quote(line)}$/) @@ -155,7 +155,7 @@ describe 'openstack-compute::nova-common' do it 'uses default values for attributes' do [ - %r{^api_servers = http://127.0.0.1:9292$} + %r{^api_servers = http://127.0.0.1:9292$}, ].each do |line| expect(chef_run).to render_config_file(file.name)\ @@ -169,7 +169,7 @@ describe 'openstack-compute::nova-common' do /^project_name = service$/, /^user_domain_name = Default/, /^project_domain_name = Default/, - %r{^url = http://127.0.0.1:9696$} + %r{^url = http://127.0.0.1:9696$}, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('neutron', line) @@ -243,7 +243,7 @@ describe 'openstack-compute::nova-common' do it 'has vmware config options set' do [ - /^host_password = vmware_secret_name$/ + /^host_password = vmware_secret_name$/, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('vmware', line) @@ -279,7 +279,7 @@ describe 'openstack-compute::nova-common' do /^images_rbd_pool = instances$/, %r{^images_rbd_ceph_conf = /etc/ceph/ceph.conf$}, /^rbd_user = cinder$/, - /^rbd_secret_uuid = 00000000-0000-0000-0000-000000000000$/ + /^rbd_secret_uuid = 00000000-0000-0000-0000-000000000000$/, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('libvirt', line) @@ -298,7 +298,7 @@ describe 'openstack-compute::nova-common' do [ /^images_type = rbd$/, /^images_rbd_pool = myrbd$/, - %r{^images_rbd_ceph_conf = /etc/myceph/ceph.conf$} + %r{^images_rbd_ceph_conf = /etc/myceph/ceph.conf$}, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('libvirt', line) @@ -317,7 +317,7 @@ describe 'openstack-compute::nova-common' do [ /^images_type = lvm$/, /^images_volume_group = instances$/, - /^sparse_logical_volumes = false$/ + /^sparse_logical_volumes = false$/, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('libvirt', line) @@ -352,7 +352,7 @@ describe 'openstack-compute::nova-common' do # /^enabled = False$/, %r{base_url = ws://127.0.0.1:6083$}, # /^port_range = 10000:20000$/, - /^proxyclient_address = 127.0.0.1$/ + /^proxyclient_address = 127.0.0.1$/, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('serial_console', line) @@ -371,7 +371,7 @@ describe 'openstack-compute::nova-common' do # /^enabled = True$/, %r{base_url = wss://1.1.1.1:6082$}, # /^port_range = 11000:15000$/, - /^proxyclient_address = 127.0.0.1$/ + /^proxyclient_address = 127.0.0.1$/, ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('serial_console', line) @@ -435,7 +435,7 @@ describe 'openstack-compute::nova-common' 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/placement_api_spec.rb b/spec/placement_api_spec.rb index e2b05300..308d59d9 100644 --- a/spec/placement_api_spec.rb +++ b/spec/placement_api_spec.rb @@ -10,15 +10,15 @@ describe 'openstack-compute::placement_api' do include_context 'compute_stubs' - it "includes nova-common recipe" do + it 'includes nova-common recipe' do expect(chef_run).to include_recipe 'openstack-compute::nova-common' end - it "upgrades package nova-placement-api" do + it 'upgrades package nova-placement-api' do expect(chef_run).to upgrade_package 'nova-placement-api' end - it "executes placement-api: nova-manage api_db sync" do + it 'executes placement-api: nova-manage api_db sync' do expect(chef_run).to run_execute('placement-api: nova-manage api_db sync').with( timeout: 3600, user: 'nova', @@ -27,7 +27,7 @@ describe 'openstack-compute::placement_api' do ) end - it "disables nova-placement-api service" do + it 'disables nova-placement-api service' do expect(chef_run).to disable_service 'disable nova-placement-api service' end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fecb5068..eac98607 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,13 +13,13 @@ 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, - file_cache_path: Chef::Config[:file_cache_path] + file_cache_path: Chef::Config[:file_cache_path], }.freeze shared_context 'compute_stubs' do @@ -35,9 +35,9 @@ shared_context 'compute_stubs' do 'openstack' => { 'identity' => { 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin' - } - } + 'admin_user' => 'admin', + }, + }, }] ) allow_any_instance_of(Chef::Recipe).to receive(:get_password) @@ -88,7 +88,7 @@ shared_context 'compute_stubs' do # stub_command('nova-manage network list | grep 192.168.100.0/24').and_return(false) # stub_command('nova-manage network list | grep 192.168.200.0/24').and_return(false) # stub_command("nova-manage floating list |grep -E '.*([0-9]{1,3}[.]){3}[0-9]{1,3}*'").and_return(false) - stub_command("/usr/sbin/apache2 -t").and_return(true) + stub_command('/usr/sbin/apache2 -t').and_return(true) stub_command('virsh net-list | grep -q default').and_return(true) stub_command('ovs-vsctl br-exists br-int').and_return(true) stub_command('ovs-vsctl br-exists br-tun').and_return(true) diff --git a/templates/default/api-paste.ini.erb b/templates/default/api-paste.ini.erb index ce14afb3..fc831851 100644 --- a/templates/default/api-paste.ini.erb +++ b/templates/default/api-paste.ini.erb @@ -30,17 +30,20 @@ use = call:nova.api.openstack.urlmap:urlmap_factory [composite:openstack_compute_api_v21] use = call:nova.api.auth:pipeline_factory_v21 -noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap sizelimit osprofiler noauth2 osapi_compute_app_v21 -keystone = cors http_proxy_to_wsgi compute_req_id faultwrap sizelimit osprofiler authtoken keystonecontext osapi_compute_app_v21 +noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler noauth2 osapi_compute_app_v21 +keystone = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler authtoken keystonecontext osapi_compute_app_v21 [composite:openstack_compute_api_v21_legacy_v2_compatible] use = call:nova.api.auth:pipeline_factory_v21 -noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap sizelimit osprofiler noauth2 legacy_v2_compatible osapi_compute_app_v21 -keystone = cors http_proxy_to_wsgi compute_req_id faultwrap sizelimit osprofiler authtoken keystonecontext legacy_v2_compatible osapi_compute_app_v21 +noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler noauth2 legacy_v2_compatible osapi_compute_app_v21 +keystone = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler authtoken keystonecontext legacy_v2_compatible osapi_compute_app_v21 [filter:request_id] paste.filter_factory = oslo_middleware:RequestId.factory +[filter:request_log] +paste.filter_factory = nova.api.openstack.requestlog:RequestLog.factory + [filter:compute_req_id] paste.filter_factory = nova.api.compute_req_id:ComputeReqIdMiddleware.factory @@ -66,7 +69,7 @@ paste.filter_factory = nova.api.openstack:LegacyV2CompatibleWrapper.factory paste.app_factory = nova.api.openstack.compute:APIRouterV21.factory [pipeline:oscomputeversions] -pipeline = cors faultwrap http_proxy_to_wsgi oscomputeversionapp +pipeline = cors faultwrap request_log http_proxy_to_wsgi oscomputeversionapp [app:oscomputeversionapp] paste.app_factory = nova.api.openstack.compute.versions:Versions.factory