Cleanup minor rubocop offenses

Cleaned up all the minor rubocop issues, the ones left relate to
complex logic and what I think is a bug in rubocop for nested
vs compact modules/class definitions.

Change-Id: Ic874a3e0a8d005e410baa40584f0f00dfc805a56
This commit is contained in:
Mark Vanderwiel 2015-05-28 15:43:06 -05:00
parent 8d1f4228d2
commit 27207cd30b
16 changed files with 97 additions and 159 deletions

View File

@ -1,84 +1,30 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-27 14:34:42 -0600 using RuboCop version 0.29.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: 3
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Enabled: false
# Offense count: 2
Metrics/AbcSize:
Max: 69
# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundBlockBody:
Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FormatString:
Enabled: false
# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MultilineOperationIndentation:
Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/SelfAssignment:
Enabled: false
# Offense count: 30
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/UnneededCapitalW:
Enabled: false
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-05-28 15:42:49 -0500 using RuboCop version 0.29.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
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Enabled: false
# Offense count: 2
Metrics/AbcSize:
Max: 69
# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
Enabled: false

View File

@ -231,7 +231,7 @@ default['openstack']['compute']['scheduler']['scheduler_manager'] = 'nova.schedu
default['openstack']['compute']['scheduler']['scheduler_driver'] = 'nova.scheduler.filter_scheduler.FilterScheduler'
default['openstack']['compute']['scheduler']['scheduler_host_manager'] = 'nova.scheduler.host_manager.HostManager'
default['openstack']['compute']['scheduler']['available_filters'] = 'nova.scheduler.filters.all_filters'
default['openstack']['compute']['scheduler']['default_filters'] = %W(
default['openstack']['compute']['scheduler']['default_filters'] = %w(
RetryFilter
AvailabilityZoneFilter
RamFilter

View File

@ -1,10 +1,10 @@
name 'openstack-compute'
maintainer 'openstack-chef'
name 'openstack-compute'
maintainer 'openstack-chef'
maintainer_email 'opscode-chef-openstack@googlegroups.com'
license 'Apache 2.0'
description 'The OpenStack Compute service Nova.'
license 'Apache 2.0'
description 'The OpenStack Compute service Nova.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '11.0.0'
version '11.0.0'
recipe 'openstack-compute::api-ec2', 'Installs AWS EC2 compatible API'
recipe 'openstack-compute::api-metadata', 'Installs the nova metadata package'
@ -22,7 +22,7 @@ recipe 'openstack-compute::nova-setup', 'Sets up the nova database on the mysql
recipe 'openstack-compute::scheduler', 'Installs nova scheduler service'
recipe 'openstack-compute::vncproxy', 'Installs and configures the vncproxy service for console access to VMs'
%w{ ubuntu fedora redhat centos suse }.each do |os|
%w(ubuntu fedora redhat centos suse).each do |os|
supports os
end

View File

@ -49,8 +49,8 @@ end
template '/etc/nova/api-paste.ini' do
source 'api-paste.ini.erb'
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
notifies :restart, 'service[nova-api-ec2]'
end

View File

@ -52,8 +52,8 @@ end
template '/etc/nova/api-paste.ini' do
source 'api-paste.ini.erb'
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
notifies :restart, 'service[nova-api-metadata]'
end

View File

@ -55,8 +55,8 @@ end
template '/etc/nova/api-paste.ini' do
source 'api-paste.ini.erb'
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00644
notifies :restart, 'service[nova-api-os-compute]'
end

View File

@ -75,7 +75,7 @@ end
cookbook_file '/etc/nova/nova-compute.conf' do
source 'nova-compute.conf'
mode 00644
mode 00644
action :create
end
@ -103,10 +103,10 @@ group docker_group do
end
file 'docker.filter' do
owner 'root'
group 'root'
mode 00644
path filter_target_path
owner 'root'
group 'root'
mode 00644
path filter_target_path
content lazy { ::File.open(filter_source_path).read }
action :create
only_if { node['openstack']['compute']['docker']['enable'] }

View File

@ -51,7 +51,7 @@ git_download_directory = "#{Chef::Config['file_cache_path']}/nova-docker"
git git_download_directory do
repository github_repository
revision github_branch
revision github_branch
action :sync
end

View File

@ -73,9 +73,9 @@ end
def update_boot_kernel_and_trigger_reboot(flavor = 'default') # rubocop:disable MethodLength
# only default and xen flavor is supported by this helper right now
if File.exists?('/boot/grub/menu.lst')
if File.exist?('/boot/grub/menu.lst')
update_grub_default_kernel(flavor)
elsif File.exists?('/etc/default/grub')
elsif File.exist?('/etc/default/grub')
update_grub2_default_kernel(flavor)
else
::Chef::Application.fatal!(
@ -141,7 +141,7 @@ group node['openstack']['compute']['libvirt']['group'] do
members [node['openstack']['compute']['group']]
action :create
only_if { platform_family? %w{suse fedora rhel} }
only_if { platform_family? %w(suse fedora rhel) }
end
# http://fedoraproject.org/wiki/Getting_started_with_OpenStack_EPEL#Installing_within_a_VM
@ -149,7 +149,7 @@ end
link '/usr/bin/qemu-system-x86_64' do
to '/usr/libexec/qemu-kvm'
only_if { platform_family? %w{fedora rhel} }
only_if { platform_family? %w(fedora rhel) }
end
service 'dbus' do
@ -181,9 +181,9 @@ end
# TODO(breu): this section needs to be rewritten to support key privisioning
template '/etc/libvirt/libvirtd.conf' do
source 'libvirtd.conf.erb'
owner 'root'
group 'root'
mode 00644
owner 'root'
group 'root'
mode 00644
variables(
auth_tcp: node['openstack']['compute']['libvirt']['auth_tcp'],
libvirt_group: node['openstack']['compute']['libvirt']['group']
@ -195,24 +195,24 @@ end
template '/etc/default/libvirt-bin' do
source 'libvirt-bin.erb'
owner 'root'
group 'root'
mode 00644
owner 'root'
group 'root'
mode 00644
notifies :restart, 'service[libvirt-bin]', :immediately
only_if { platform_family? %w{debian} }
only_if { platform_family? 'debian' }
end
template '/etc/sysconfig/libvirtd' do
source 'libvirtd.erb'
owner 'root'
group 'root'
mode 00644
owner 'root'
group 'root'
mode 00644
notifies :restart, 'service[libvirt-bin]', :immediately
only_if { platform_family? %w{fedora rhel} }
only_if { platform_family? %w(fedora rhel) }
end
volume_backend = node['openstack']['compute']['libvirt']['volume_backend']

View File

@ -56,7 +56,7 @@ end
directory '/etc/nova' do
owner node['openstack']['compute']['user']
group node['openstack']['compute']['group']
mode 00750
mode 00750
action :create
end
@ -110,14 +110,14 @@ image_endpoint = internal_endpoint 'image-api'
ironic_endpoint = internal_endpoint 'bare-metal-api'
ironic_admin_password = get_password 'service', 'openstack-bare-metal'
Chef::Log.debug("openstack-compute::nova-common:identity_endpoint|#{identity_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:xvpvnc_endpoint|#{xvpvnc_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:novnc_endpoint|#{novnc_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:identity_endpoint|#{identity_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:xvpvnc_endpoint|#{xvpvnc_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:novnc_endpoint|#{novnc_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:compute_api_endpoint|#{::URI.decode compute_api_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:ec2_public_endpoint|#{ec2_public_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:network_endpoint|#{network_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:image_endpoint|#{image_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:ironic_endpoint|#{ironic_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:ec2_public_endpoint|#{ec2_public_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:network_endpoint|#{network_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:image_endpoint|#{image_endpoint}")
Chef::Log.debug("openstack-compute::nova-common:ironic_endpoint|#{ironic_endpoint}")
if node['openstack']['compute']['network']['service_type'] == 'neutron'
neutron_admin_password = get_password 'service', 'openstack-network'
@ -182,9 +182,9 @@ end
template '/etc/nova/rootwrap.conf' do
source 'rootwrap.conf.erb'
# Must be root!
owner 'root'
group 'root'
mode 00644
owner 'root'
group 'root'
mode 00644
end
execute 'enable nova login' do

View File

@ -48,7 +48,7 @@ when 'nova'
# are 'label' and 'ipv4_cidr'.
cmd = "nova-manage network create --label=#{net['label']} --fixed_range_v4=#{net['ipv4_cidr']}"
cmd += " --multi_host='#{net['multi_host']}'" if net.key?('multi_host')
%w{num_networks network_size bridge dns1 dns2}.each do |v|
%w(num_networks network_size bridge dns1 dns2).each do |v|
cmd += " --#{v}=#{net[v]}" if net.key?(v)
end
# Older attributes have the key as 'bridge_dev' instead
@ -61,7 +61,7 @@ when 'nova'
cmd += " --vlan=#{net['vlan']}"
elsif node['openstack']['compute']['network']['network_manager'] == 'nova.network.manager.VlanManager'
cmd += " --vlan=#{next_vlan}"
next_vlan = next_vlan + 1
next_vlan += 1
end
command cmd
not_if "nova-manage network list | grep #{net['ipv4_cidr']}", user: nova_user, group: nova_group
@ -74,7 +74,7 @@ when 'nova'
user 'root'
group 'root'
source 'add_floaters.py'
mode 00755
mode 00755
action :create
end
@ -116,7 +116,7 @@ when 'neutron'
user 'root'
group 'root'
source 'add_floaters.py'
mode 00755
mode 00755
action :create
end
@ -128,7 +128,7 @@ when 'neutron'
execute 'neutron floating create' do
command cmd
not_if ". /root/openrc && neutron floatingip-list |grep -E '.*([0-9]{1,3}[\.]){3}[0-9]{1,3}*'"
only_if { File.exists?('/root/openrc') }
only_if { File.exist?('/root/openrc') }
action :run
end

View File

@ -2,9 +2,7 @@
require_relative 'spec_helper'
describe 'openstack-compute::client' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) do

View File

@ -2,9 +2,7 @@
require_relative 'spec_helper'
describe 'openstack-compute::client' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do

View File

@ -73,7 +73,7 @@ describe 'openstack-compute::compute' do
expect(chef_run).to upgrade_package('nova-compute-qemu').with(options: '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes')
end
%w{qemu kvm}.each do |virt_type|
%w(qemu kvm).each do |virt_type|
it "honors the package name platform overrides for #{virt_type}" do
node.set['openstack']['compute']['libvirt']['virt_type'] = virt_type
node.set['openstack']['compute']['platform']["#{virt_type}_compute_packages"] = ["my-nova-#{virt_type}"]
@ -87,13 +87,10 @@ describe 'openstack-compute::compute' do
it 'creates the file' do
expect(chef_run).to create_cookbook_file(file.name).with(
source: 'nova-compute.conf'
source: 'nova-compute.conf',
mode: 00644
)
end
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq '644'
end
end
it 'runs libvirt recipe' do

View File

@ -98,7 +98,7 @@ describe 'openstack-compute::nova-common' do
end
it 'has default ssl options set' do
%W(ssl_only=false
%w(ssl_only=false
cert=self.pem
key=).each do |line|
expect(chef_run).to render_file(file.name).with_content(/^#{line}$/)
@ -843,11 +843,10 @@ describe 'openstack-compute::nova-common' do
end
it 'sets the upgrade levels' do
node.set['openstack']['compute']['upgrade_levels'] = {
'compute' => 'juno',
'cert' => '3.0',
'network' => 'havana'
}
node.set['openstack']['compute']['upgrade_levels'] = { 'compute' => 'juno',
'cert' => '3.0',
'network' => 'havana'
}
node['openstack']['compute']['upgrade_levels'].each do |key, val|
expect(chef_run).to render_config_file(file.name).with_section_content('upgrade_levels', /^#{key} = #{val}$/)
end
@ -874,8 +873,8 @@ describe 'openstack-compute::nova-common' do
it 'sets the default attributes' do
[
%r(^filters_path=/etc/nova/rootwrap.d,/usr/share/nova/rootwrap$),
%r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
%r{^filters_path=/etc/nova/rootwrap.d,/usr/share/nova/rootwrap$},
%r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$},
/^use_syslog=False$/,
/^syslog_log_facility=syslog$/,
/^syslog_log_level=ERROR$/

View File

@ -164,25 +164,25 @@ def expect_creates_api_paste(service, action = :restart) # rubocop:disable Metho
it 'sets the pipeline attribute' do
expect(chef_run).to render_file(file.name)
.with_content(/^pipeline = ec2faultwrap logrequest metaapp$/)
.with_content(/^pipeline = ec2faultwrap logrequest metaapp$/)
end
it 'sets ec2 attributes' do
expect(chef_run).to render_file(file.name)
.with_content(/^\[composite:ec2\]$/)
.with_content(/^\[composite:ec2\]$/)
end
end
it 'sets the pipeline attribute when ec2 api is disabled' do
node.set['openstack']['compute']['enabled_apis'] = []
expect(chef_run).to render_file(file.name)
.with_content(/^pipeline = faultwrap metaapp$/)
.with_content(/^pipeline = faultwrap metaapp$/)
end
it 'pastes the misc attributes' do
node.set['openstack']['compute']['misc_paste'] = %w(paste1 paste2)
expect(chef_run).to render_file(file.name)
.with_content(/^paste1$/).with_content(/^paste2$/)
.with_content(/^paste1$/).with_content(/^paste2$/)
end
end