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,20 +1,10 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-27 14:34:42 -0600 using RuboCop version 0.29.1.
# 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: 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:
@ -29,56 +19,12 @@ Metrics/AbcSize:
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

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

@ -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

@ -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
@ -201,7 +201,7 @@ template '/etc/default/libvirt-bin' do
notifies :restart, 'service[libvirt-bin]', :immediately
only_if { platform_family? %w{debian} }
only_if { platform_family? 'debian' }
end
template '/etc/sysconfig/libvirtd' do
@ -212,7 +212,7 @@ template '/etc/sysconfig/libvirtd' do
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

@ -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'

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
@ -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,8 +843,7 @@ describe 'openstack-compute::nova-common' do
end
it 'sets the upgrade levels' do
node.set['openstack']['compute']['upgrade_levels'] = {
'compute' => 'juno',
node.set['openstack']['compute']['upgrade_levels'] = { 'compute' => 'juno',
'cert' => '3.0',
'network' => 'havana'
}
@ -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$/