diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ec8987d..aee1852 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,55 +1,21 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2015-02-27 14:45:01 -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: 1 -Metrics/AbcSize: - Max: 28 - -# Offense count: 5 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/ClassAndModuleChildren: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/EmptyLinesAroundBlockBody: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/FirstParameterIndentation: - Enabled: false - -# Offense count: 8 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/FormatString: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/MultilineOperationIndentation: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 13 -# Cop supports --auto-correct. -Style/SingleSpaceBeforeFirstArg: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -Style/SymbolProc: - Enabled: false +# This configuration was generated by `rubocop --auto-gen-config` +# on 2015-05-28 14:36: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: 1 +Metrics/AbcSize: + Max: 18 + +# Offense count: 5 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/SymbolProc: + Enabled: false diff --git a/metadata.rb b/metadata.rb index 2967135..d897773 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,21 +1,21 @@ # encoding: UTF-8 -name 'openstack-block-storage' -maintainer 'openstack-chef' +name 'openstack-block-storage' +maintainer 'openstack-chef' maintainer_email 'opscode-chef-openstack@googlegroups.com' -license 'Apache 2.0' -description 'The OpenStack Advanced Volume Management service Cinder.' +license 'Apache 2.0' +description 'The OpenStack Advanced Volume Management service Cinder.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.1.0' +version '11.1.0' -recipe 'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone' -recipe 'openstack-block-storage::client', 'Install packages required for cinder client' -recipe 'openstack-block-storage::common', 'Defines the common pieces of repeated code from the other recipes' -recipe 'openstack-block-storage::keystone_registration', 'Registers cinder service/user/endpoints in keystone' -recipe 'openstack-block-storage::scheduler', 'Installs the cinder-scheduler service' -recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper' -recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service' +recipe 'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone' +recipe 'openstack-block-storage::client', 'Install packages required for cinder client' +recipe 'openstack-block-storage::common', 'Defines the common pieces of repeated code from the other recipes' +recipe 'openstack-block-storage::keystone_registration', 'Registers cinder service/user/endpoints in keystone' +recipe 'openstack-block-storage::scheduler', 'Installs the cinder-scheduler service' +recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper' +recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service' -%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/cinder-common.rb b/recipes/cinder-common.rb index dee23d4..7e9f6d7 100644 --- a/recipes/cinder-common.rb +++ b/recipes/cinder-common.rb @@ -131,5 +131,5 @@ template '/etc/cinder/rootwrap.conf' do source 'rootwrap.conf.erb' owner 'root' group 'root' - mode 00644 + mode 00644 end diff --git a/recipes/volume.rb b/recipes/volume.rb index a3592f9..8e93841 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -22,7 +22,8 @@ # limitations under the License. # -class ::Chef::Recipe # rubocop:disable Documentation +# Chef +class ::Chef::Recipe include ::Openstack end @@ -257,7 +258,7 @@ end # RHEL7 doesn't need targets.conf file template '/etc/tgt/targets.conf' do source 'targets.conf.erb' - mode 00600 + mode 00600 notifies :restart, 'service[iscsitarget]', :immediately not_if { node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7 } end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 9a25580..5df877c 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -39,16 +39,11 @@ describe 'openstack-block-storage::api' do let(:dir) { chef_run.directory('/var/cache/cinder') } it 'should create the directory' do - expect(chef_run).to create_directory(dir.name) - end - - it 'has proper owner' do - expect(dir.owner).to eq('cinder') - expect(dir.group).to eq('cinder') - end - - it 'has proper modes' do - expect(sprintf('%o', dir.mode)).to eq('700') + expect(chef_run).to create_directory(dir.name).with( + owner: 'cinder', + group: 'cinder', + mode: 00700 + ) end end diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb index 0dffd0f..06705a3 100644 --- a/spec/backup_spec.rb +++ b/spec/backup_spec.rb @@ -75,6 +75,5 @@ describe 'openstack-block-storage::backup' do expect(chef_run).not_to upgrade_package 'python-mysqldb' end end - end end diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index 6166433..6d7b0df 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -25,16 +25,11 @@ describe 'openstack-block-storage::cinder-common' do let(:dir) { chef_run.directory('/etc/cinder') } it 'should create the /etc/cinder directory' do - expect(chef_run).to create_directory(dir.name) - end - - it 'has proper owner' do - expect(dir.owner).to eq('cinder') - expect(dir.group).to eq('cinder') - end - - it 'has proper modes' do - expect(sprintf('%o', dir.mode)).to eq '750' + expect(chef_run).to create_directory(dir.name).with( + owner: 'cinder', + group: 'cinder', + mode: 00750 + ) end end @@ -48,16 +43,11 @@ describe 'openstack-block-storage::cinder-common' do end it 'should create the cinder.conf template' do - expect(chef_run).to create_template(file.name) - end - - it 'has proper owner' do - expect(file.owner).to eq('cinder') - expect(file.group).to eq('cinder') - end - - it 'has proper modes' do - expect(sprintf('%o', file.mode)).to eq '640' + expect(chef_run).to create_template(file.name).with( + owner: 'cinder', + group: 'cinder', + mode: 00640 + ) end context 'keystone authtoken attributes with default values' do @@ -124,13 +114,12 @@ describe 'openstack-block-storage::cinder-common' do end context 'endpoint related' do - it 'has auth_uri' 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 'has identity_uri' 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 end @@ -165,7 +154,6 @@ describe 'openstack-block-storage::cinder-common' do end context 'template contents' do - context 'commonly named attributes' do %w(debug verbose host notification_driver storage_availability_zone quota_volumes quota_gigabytes quota_driver @@ -237,7 +225,7 @@ describe 'openstack-block-storage::cinder-common' do end it 'has a lock_path attribute' do - expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lib/cinder/lock$)) + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path=/var/lib/cinder/lock$}) end it 'does not have unique host id by default' do @@ -839,7 +827,7 @@ describe 'openstack-block-storage::cinder-common' do it 'has wsdl_location line with attribute present' do node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl' - expect(chef_run).to render_file(file.name).with_content(%r(^vmware_wsdl_location = http://127.0.0.1/wsdl$)) + expect(chef_run).to render_file(file.name).with_content(%r{^vmware_wsdl_location = http://127.0.0.1/wsdl$}) end end @@ -1015,7 +1003,6 @@ describe 'openstack-block-storage::cinder-common' do it 'set gpfs option' do expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/) end - end it 'no multiple backends configured' do @@ -1032,16 +1019,11 @@ describe 'openstack-block-storage::cinder-common' do let(:dir) { chef_run.directory('/var/lib/cinder/lock') } it 'should create the /var/lib/cinder/lock directory' do - expect(chef_run).to create_directory(dir.name) - end - - it 'has proper owner' do - expect(dir.owner).to eq('cinder') - expect(dir.group).to eq('cinder') - end - - it 'has proper modes' do - expect(sprintf('%o', dir.mode)).to eq '755' + expect(chef_run).to create_directory(dir.name).with( + user: 'cinder', + group: 'cinder', + mode: 00755 + ) end end @@ -1061,13 +1043,13 @@ describe 'openstack-block-storage::cinder-common' do node.set['openstack']['block-storage']['custom_template_banner'] = 'banner' expect(chef_run).to render_file(file.name) - .with_content(/^banner$/) + .with_content(/^banner$/) end it 'sets the default attributes' do [ - %r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$), - %r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$), + %r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/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 e210954..836e780 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,13 +99,12 @@ def expect_creates_cinder_conf(service, user, group, action = :restart) # ruboco describe 'cinder.conf' do let(:file) { chef_run.template('/etc/cinder/cinder.conf') } - it 'has proper owner' do - expect(file.owner).to eq(user) - expect(file.group).to eq(group) - end - - it 'has proper modes' do - expect(sprintf('%o', file.mode)).to eq '640' + it 'creates the /etc/cinder/cinder.conf file' do + expect(chef_run).to create_template(file.name).with( + user: user, + group: group, + mode: 0640 + ) end it 'notifies service restart' do diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb index 8327bc6..c77278a 100644 --- a/spec/volume-redhat_spec.rb +++ b/spec/volume-redhat_spec.rb @@ -63,9 +63,9 @@ describe 'openstack-block-storage::volume' do it 'creates IBMNAS shares_config file' do expect(chef_run).to create_template(file.name).with( - owner: 'cinder', - group: 'cinder', - mode: '0600' + owner: 'cinder', + group: 'cinder', + mode: '0600' ) expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export') end @@ -77,9 +77,9 @@ describe 'openstack-block-storage::volume' do it 'creates the nfs mount point' do expect(chef_run).to create_directory('/mnt/cinder-volumes').with( - owner: 'cinder', - group: 'cinder', - mode: '0755' + owner: 'cinder', + group: 'cinder', + mode: '0755' ) end end @@ -155,9 +155,9 @@ describe 'openstack-block-storage::volume' do it 'verifies gpfs volume directory is created with owner and mode set correctly' do expect(@chef_run).to create_directory('volumes').with( - owner: 'cinder', - group: 'cinder', - mode: '0755' + owner: 'cinder', + group: 'cinder', + mode: '0755' ) end end @@ -172,7 +172,7 @@ describe 'openstack-block-storage::volume' do describe 'template contents' do it 'sources /etc/rc.d/init.d/functions' do - expect(chef_run).to render_file(file.name).with_content(%r(^\s*. /etc/rc.d/init.d/functions$)) + expect(chef_run).to render_file(file.name).with_content(%r{^\s*. /etc/rc.d/init.d/functions$}) end it 'calls success and echo' do diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index 2b38edf..757fd74 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -65,9 +65,9 @@ describe 'openstack-block-storage::volume' do context 'IBMNAS shares_config file' do it 'creates the file' do expect(chef_run).to create_template(file.name).with( - owner: 'cinder', - group: 'cinder', - mode: '0600' + owner: 'cinder', + group: 'cinder', + mode: '0600' ) end @@ -84,9 +84,9 @@ describe 'openstack-block-storage::volume' do it 'creates the nfs mount point' do expect(chef_run).to create_directory('/mnt/cinder-volumes').with( - owner: 'cinder', - group: 'cinder', - mode: '0755' + owner: 'cinder', + group: 'cinder', + mode: '0755' ) end end @@ -216,11 +216,9 @@ describe 'openstack-block-storage::volume' do let(:file) { chef_run.template('/etc/tgt/targets.conf') } it 'should create the targets.conf' do - expect(chef_run).to create_template(file.name) - end - - it 'has proper modes' do - expect(sprintf('%o', file.mode)).to eq '600' + expect(chef_run).to create_template(file.name).with( + mode: 0600 + ) end it 'notifies iscsi restart' do @@ -277,7 +275,7 @@ describe 'openstack-block-storage::volume' do end it 'calls vgs with the volume name attribute' do - expect(chef_run).to render_file(file.name).with_content(%r(vgs #{volume_group_value} > /dev/null 2>&1)) + expect(chef_run).to render_file(file.name).with_content(%r{vgs #{volume_group_value} > /dev/null 2>&1}) end it 'calls vgcreate with the volume name and volume file attributes' do @@ -315,11 +313,9 @@ describe 'openstack-block-storage::volume' do end it 'creates cinder emc config file' do - expect(chef_run).to create_template(file.name) - end - - it 'has proper modes' do - expect(sprintf('%o', file.mode)).to eq('644') + expect(chef_run).to create_template(file.name).with( + mode: 0644 + ) end describe 'template contents' do