diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 65c6c0e6..bea6dda8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/attributes/default.rb b/attributes/default.rb index d92bdf13..2392d899 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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 diff --git a/metadata.rb b/metadata.rb index a2de1c34..1103206e 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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 diff --git a/recipes/api-ec2.rb b/recipes/api-ec2.rb index 3423a150..8ffaed12 100644 --- a/recipes/api-ec2.rb +++ b/recipes/api-ec2.rb @@ -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 diff --git a/recipes/api-metadata.rb b/recipes/api-metadata.rb index 712f148a..85cb2b13 100644 --- a/recipes/api-metadata.rb +++ b/recipes/api-metadata.rb @@ -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 diff --git a/recipes/api-os-compute.rb b/recipes/api-os-compute.rb index 984a0a07..a781fa02 100644 --- a/recipes/api-os-compute.rb +++ b/recipes/api-os-compute.rb @@ -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 diff --git a/recipes/compute.rb b/recipes/compute.rb index 1d8fd906..d70fe806 100644 --- a/recipes/compute.rb +++ b/recipes/compute.rb @@ -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'] } diff --git a/recipes/docker-setup.rb b/recipes/docker-setup.rb index b038800b..8ca11e24 100644 --- a/recipes/docker-setup.rb +++ b/recipes/docker-setup.rb @@ -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 diff --git a/recipes/libvirt.rb b/recipes/libvirt.rb index d1b2d7af..7872f9ff 100644 --- a/recipes/libvirt.rb +++ b/recipes/libvirt.rb @@ -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'] diff --git a/recipes/nova-common.rb b/recipes/nova-common.rb index fa43a529..064ef368 100644 --- a/recipes/nova-common.rb +++ b/recipes/nova-common.rb @@ -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 diff --git a/recipes/nova-setup.rb b/recipes/nova-setup.rb index 2cc5db6f..62c8476f 100644 --- a/recipes/nova-setup.rb +++ b/recipes/nova-setup.rb @@ -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 diff --git a/spec/client-redhat_spec.rb b/spec/client-redhat_spec.rb index 034f0934..a33ffec3 100644 --- a/spec/client-redhat_spec.rb +++ b/spec/client-redhat_spec.rb @@ -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 diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 506a5d42..28e66936 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -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 diff --git a/spec/compute_spec.rb b/spec/compute_spec.rb index a4d9f88c..f9de82cf 100644 --- a/spec/compute_spec.rb +++ b/spec/compute_spec.rb @@ -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 diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb index c54024f8..1b340751 100644 --- a/spec/nova-common_spec.rb +++ b/spec/nova-common_spec.rb @@ -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$/ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 36a0e151..dbab0861 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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