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: I6097cd1032a5b2305d9a6ca8cb2e2b19f6a57a1e
This commit is contained in:
Mark Vanderwiel 2015-05-29 10:09:57 -05:00
parent 103b626560
commit e53ae638f1
12 changed files with 60 additions and 105 deletions

View File

@ -1,44 +1,11 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-27 13:36:11 -0600 using RuboCop version 0.29.1.
# on 2015-05-29 10:08:48 -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/StringConversionInInterpolation:
Enabled: false
# Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundBlockBody:
Enabled: false
# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FormatString:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MultilineOperationIndentation:
Enabled: false
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 26
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Enabled: false

View File

@ -203,7 +203,7 @@ when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
default['openstack']['image']['user'] = 'glance'
default['openstack']['image']['group'] = 'glance'
default['openstack']['image']['platform'] = {
'image_packages' => %w{openstack-glance cronie python-glanceclient},
'image_packages' => %w(openstack-glance cronie python-glanceclient),
'image_client_packages' => ['python-glanceclient'],
'ceph_packages' => ['python-ceph'],
'swift_packages' => ['openstack-swift'],

View File

@ -11,7 +11,7 @@ recipe 'openstack-image::registry', 'Installs packages required for a
recipe 'openstack-image::identity_registration', 'Registers Glance endpoints and service with Keystone'
recipe 'openstack-image::image_upload', 'Upload image using glance image-create command'
%w{ ubuntu fedora redhat centos suse }.each do |os|
%w(ubuntu fedora redhat centos suse).each do |os|
supports os
end

View File

@ -73,7 +73,7 @@ def _upload_image_bare(name, api, url, public, type)
execute "Uploading #{type} image #{name}" do
cwd '/tmp'
command "#{glance_cmd} image-create --name #{name} --is-public #{public} #{c_fmt} #{d_fmt} --location #{url}"
not_if "#{glance_cmd} image-list | grep #{name.to_s}"
not_if "#{glance_cmd} image-list | grep #{name}"
end
end
@ -113,6 +113,6 @@ def _upload_ami(name, api, url, public) # rubocop:disable MethodLength
rid=$(#{glance_cmd} image-create --name "${image_name}-initrd" --is-public #{public} #{ari_fmt} < ${ramdisk} | grep -m 1 '^|[ ]*id[ ]*|' | cut -d'|' -f3 | sed 's/ //')
#{glance_cmd} image-create --name "#{name}" --is-public #{public} #{ami_fmt} --property "kernel_id=$kid" --property "ramdisk_id=$rid" < ${kernel}
EOH
not_if "#{glance_cmd} image-list | grep #{name.to_s}"
not_if "#{glance_cmd} image-list | grep #{name}"
end
end

View File

@ -48,7 +48,7 @@ node['openstack']['image']['upload_images'].each do |img|
type = 'unknown'
type = node['openstack']['image']['upload_image_type'][img.to_sym] if node['openstack']['image']['upload_image_type'][img.to_sym]
openstack_image_image "Image setup for #{img.to_s}" do
openstack_image_image "Image setup for #{img}" do
image_url node['openstack']['image']['upload_image'][img.to_sym]
image_name img
image_type type

View File

@ -199,7 +199,7 @@ describe 'openstack-image::api' do
it 'sets the filesystem_store_metadata_file attribute' do
node.set['openstack']['image']['filesystem_store_metadata_file'] = '/etc/glance/images.json'
expect(chef_run).to render_file(file.name).with_content(%r(^filesystem_store_metadata_file = /etc/glance/images.json$))
expect(chef_run).to render_file(file.name).with_content(%r{^filesystem_store_metadata_file = /etc/glance/images.json$})
end
context 'api related attributes' do
@ -241,12 +241,12 @@ describe 'openstack-image::api' do
context 'syslog use' do
it 'shows log_config if syslog use is enabled' do
node.set['openstack']['image']['syslog']['use'] = true
expect(chef_run).to render_file(file.name).with_content(%r(^log_config = /etc/openstack/logging.conf$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_config = /etc/openstack/logging.conf$})
end
it 'shows log_file if syslog use is disabled' do
node.set['openstack']['image']['syslog']['use'] = false
expect(chef_run).to render_file(file.name).with_content(%r(^log_file = /var/log/glance/api.log$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_file = /var/log/glance/api.log$})
end
end
@ -307,7 +307,6 @@ describe 'openstack-image::api' do
node.set['openstack']['image']['api']['swift_store_user'] = 'swift_store_user_value'
expect(chef_run).to render_file(file.name).with_content(/^swift_store_user = swift_user_tenant_value:swift_store_user_value$/)
end
end
context 'store auth disabled' do
@ -316,7 +315,7 @@ describe 'openstack-image::api' do
end
it 'sets the auth address' do
expect(chef_run).to render_file(file.name).with_content(%r(^swift_store_auth_address = http://127.0.0.1:5000/v2.0$))
expect(chef_run).to render_file(file.name).with_content(%r{^swift_store_auth_address = http://127.0.0.1:5000/v2.0$})
end
it 'sets the auth version' do
@ -509,12 +508,12 @@ describe 'openstack-image::api' do
context 'syslog options' do
it 'sets the log_config attribute if syslog use is enabled' do
node.set['openstack']['image']['syslog']['use'] = true
expect(chef_run).to render_file(file.name).with_content(%r(^log_config = /etc/openstack/logging.conf$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_config = /etc/openstack/logging.conf$})
end
it 'sets the log_file attribute if syslog use is disabled' do
node.set['openstack']['image']['syslog']['use'] = false
expect(chef_run).to render_file(file.name).with_content(%r(^log_file = /var/log/glance/image-cache.log$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_file = /var/log/glance/image-cache.log$})
end
end

View File

@ -2,9 +2,7 @@
require_relative 'spec_helper'
describe 'openstack-image::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-image::client' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do

View File

@ -39,7 +39,7 @@ describe 'openstack-image::registry' do
expect(chef_run).to upgrade_package('my-mysql-py').with(options: '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes')
end
%w{db2 postgresql}.each do |service_type|
%w(db2 postgresql).each do |service_type|
it "upgrades #{service_type} python packages if chosen" do
node.set['openstack']['db']['image']['service_type'] = service_type
node.set['openstack']['db']['python_packages'][service_type] = ["my-#{service_type}-py"]
@ -243,7 +243,6 @@ describe 'openstack-image::registry' do
end
end
end
end
it 'notifies glance-registry restart' do

View File

@ -115,13 +115,12 @@ shared_examples 'cache-directory' do
describe '/var/cache/glance' do
let(:dir) { chef_run.directory('/var/cache/glance') }
it 'has proper owner' do
expect(dir.owner).to eq('glance')
expect(dir.group).to eq('glance')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '700'
it 'creates directory /var/cache/glance' do
expect(chef_run).to create_directory(dir.name).with(
user: 'glance',
group: 'glance',
mode: 00700
)
end
end
end
@ -130,17 +129,13 @@ shared_examples 'image-lib-cache-directory' do
describe '/var/lib/glance/image-cache/' do
let(:dir) { chef_run.directory('/var/lib/glance/image-cache/') }
it 'has proper owner' do
expect(dir.owner).to eq('glance')
expect(dir.group).to eq('glance')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '755'
end
it 'creates directory recursively' do
expect(dir.recursive).to eq(true)
it 'creates directory /var/lib/glance/image-cache' do
expect(chef_run).to create_directory(dir.name).with(
user: 'glance',
group: 'glance',
mode: 00755,
recursive: true
)
end
end
end
@ -149,13 +144,12 @@ shared_examples 'glance-directory' do
describe '/etc/glance' do
let(:dir) { chef_run.directory('/etc/glance') }
it 'has proper owner' do
expect(dir.owner).to eq('glance')
expect(dir.group).to eq('glance')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '700'
it 'creates directory /etc/glance' do
expect(chef_run).to create_directory(dir.name).with(
user: 'glance',
group: 'glance',
mode: 00700
)
end
end
end
@ -190,22 +184,22 @@ end
shared_examples 'syslog use' do
it 'shows log_config if syslog use is enabled' do
node.set['openstack']['image']['syslog']['use'] = true
expect(chef_run).to render_file(file.name).with_content(%r(^log_config = /etc/openstack/logging.conf$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_config = /etc/openstack/logging.conf$})
end
it 'shows log_file if syslog use is disabled' do
node.set['openstack']['image']['syslog']['use'] = false
expect(chef_run).to render_file(file.name).with_content(%r(^log_file = /var/log/glance/#{log_file_name}$))
expect(chef_run).to render_file(file.name).with_content(%r{^log_file = /var/log/glance/#{log_file_name}$})
end
end
shared_examples 'keystone attribute setter' do |version|
it 'sets the auth_uri value' do
expect(chef_run).to render_file(file.name).with_content(%r(^auth_uri = http://127.0.0.1:5000/v2.0$))
expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$})
end
it 'sets the identity_uri value' do
expect(chef_run).to render_file(file.name).with_content(%r(^identity_uri = http://127.0.0.1:35357/$))
expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:35357/$})
end
context 'auth version' do