From 7f61b5e221e2b69966aabc7e7e43152179f3b9be Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Thu, 2 Jun 2016 17:59:32 +0200 Subject: [PATCH] Fix rubocop deprecated conf Fix rubocop version in Gemfile --- .rubocop.yml | 4 +- .travis.yml | 1 - Gemfile | 2 +- libraries/default.rb | 17 ++++----- providers/client.rb | 2 +- recipes/apt.rb | 8 ++-- recipes/osd.rb | 91 ++++++++++++++++++++++---------------------- recipes/tgt.rb | 4 +- 8 files changed, 62 insertions(+), 67 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c739e34..efd8686 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,11 +22,11 @@ MethodLength: Enabled: false SignalException: Enabled: false -TrailingComma: - Enabled: false WordArray: Enabled: false Metrics/AbcSize: Enabled: false Metrics/PerceivedComplexity: Enabled: false +ConditionalAssignment: + Enabled: false diff --git a/.travis.yml b/.travis.yml index 232d1a5..44f0647 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ sudo: false cache: bundler bundler_args: --without kitchen_common kitchen_vagrant rvm: - - 2.0 - 2.1 - 2.2 script: diff --git a/Gemfile b/Gemfile index 55080da..fec5311 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' group :lint do gem 'foodcritic', '~> 4.0' - gem 'rubocop', '~> 0.33' + gem 'rubocop', '~> 0.40.0' end group :unit do diff --git a/libraries/default.rb b/libraries/default.rb index 297da37..9eda1af 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -95,6 +95,7 @@ def ip_address_to_ceph_address(ip, params) elsif params['family'].eql?('inet6') return "[#{ip}]:6789" end + return nil end def mon_addresses @@ -110,15 +111,13 @@ def mon_addresses mons << node if node['ceph']['is_mon'] mons += mon_nodes - if crowbar? - mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, 'admin').address } - else - if node['ceph']['config']['global'] && node['ceph']['config']['global']['public network'] - mon_ips = mons.map { |nodeish| find_node_ip_in_network(node['ceph']['config']['global']['public network'], nodeish) } - else - mon_ips = mons.map { |node| node['ipaddress'] + ':6789' } - end - end + mon_ips = if crowbar? + mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, 'admin').address } + elsif node['ceph']['config']['global'] && node['ceph']['config']['global']['public network'] + mons.map { |nodeish| find_node_ip_in_network(node['ceph']['config']['global']['public network'], nodeish) } + else + mons.map { |node| node['ipaddress'] + ':6789' } + end end mon_ips.reject(&:nil?).uniq end diff --git a/providers/client.rb b/providers/client.rb index 548b76b..25e3716 100644 --- a/providers/client.rb +++ b/providers/client.rb @@ -53,7 +53,7 @@ def load_current_resource @current_resource.key(get_key(@current_resource.keyname)) @current_resource.caps_match = @current_resource.caps == @new_resource.caps @current_resource.keys_match = @new_resource.key.nil? || (@current_resource.key == @new_resource.key) - @current_resource.exists = ! (@current_resource.key.nil? || @current_resource.key.empty?) + @current_resource.exists = !(@current_resource.key.nil? || @current_resource.key.empty?) end def file_content(keyname, key, as_keyring) diff --git a/recipes/apt.rb b/recipes/apt.rb index b5720fb..278a7ff 100644 --- a/recipes/apt.rb +++ b/recipes/apt.rb @@ -4,10 +4,10 @@ branch = node['ceph']['branch'] distribution_codename = -case node['lsb']['codename'] -when 'jessie' then 'sid' -else node['lsb']['codename'] -end + case node['lsb']['codename'] + when 'jessie' then 'sid' + else node['lsb']['codename'] + end apt_preference 'ceph_repo' do glob '*' diff --git a/recipes/osd.rb b/recipes/osd.rb index d07f161..5b4e490 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -81,7 +81,7 @@ command 'udevadm trigger --subsystem-match=block --action=add' action :nothing end -else + # Calling ceph-disk-prepare is sufficient for deploying an OSD # After ceph-disk-prepare finishes, the new device will be caught # by udev which will run ceph-disk-activate on it (udev will map @@ -91,60 +91,59 @@ # osd/$cluster-$id) # - $cluster should always be ceph # - The --dmcrypt option will be available starting w/ Cuttlefish - if node['ceph']['osd_devices'] - devices = node['ceph']['osd_devices'] +elsif node['ceph']['osd_devices'] + devices = node['ceph']['osd_devices'] - devices = Hash[(0...devices.size).zip devices] unless devices.is_a? Hash + devices = Hash[(0...devices.size).zip devices] unless devices.is_a? Hash - devices.each do |index, osd_device| - unless osd_device['status'].nil? - Log.info("osd: osd_device #{osd_device} has already been setup.") - next - end + devices.each do |index, osd_device| + unless osd_device['status'].nil? + Log.info("osd: osd_device #{osd_device} has already been setup.") + next + end - directory osd_device['device'] do # ~FC022 - owner 'root' - group 'root' - recursive true - only_if { osd_device['type'] == 'directory' } - end + directory osd_device['device'] do # ~FC022 + owner 'root' + group 'root' + recursive true + only_if { osd_device['type'] == 'directory' } + end - dmcrypt = osd_device['encrypted'] == true ? '--dmcrypt' : '' + dmcrypt = osd_device['encrypted'] == true ? '--dmcrypt' : '' - execute "ceph-disk-prepare on #{osd_device['device']}" do - command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']} #{osd_device['journal']}" - action :run - notifies :create, "ruby_block[save osd_device status #{index}]", :immediately - end + execute "ceph-disk-prepare on #{osd_device['device']}" do + command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']} #{osd_device['journal']}" + action :run + notifies :create, "ruby_block[save osd_device status #{index}]", :immediately + end - execute "ceph-disk-activate #{osd_device['device']}" do - only_if { osd_device['type'] == 'directory' } - end + execute "ceph-disk-activate #{osd_device['device']}" do + only_if { osd_device['type'] == 'directory' } + end - # we add this status to the node env - # so that we can implement recreate - # and/or delete functionalities in the - # future. - ruby_block "save osd_device status #{index}" do - block do - node.normal['ceph']['osd_devices'][index]['status'] = 'deployed' - node.save - end - action :nothing + # we add this status to the node env + # so that we can implement recreate + # and/or delete functionalities in the + # future. + ruby_block "save osd_device status #{index}" do + block do + node.normal['ceph']['osd_devices'][index]['status'] = 'deployed' + node.save end + action :nothing end - service 'ceph_osd' do - case service_type - when 'upstart' - service_name 'ceph-osd-all-starter' - provider Chef::Provider::Service::Upstart - else - service_name 'ceph' - end - action [:enable, :start] - supports :restart => true + end + service 'ceph_osd' do + case service_type + when 'upstart' + service_name 'ceph-osd-all-starter' + provider Chef::Provider::Service::Upstart + else + service_name 'ceph' end - else - Log.info('node["ceph"]["osd_devices"] empty') + action [:enable, :start] + supports :restart => true end +else + Log.info('node["ceph"]["osd_devices"] empty') end diff --git a/recipes/tgt.rb b/recipes/tgt.rb index eb353e9..821262d 100644 --- a/recipes/tgt.rb +++ b/recipes/tgt.rb @@ -42,10 +42,8 @@ if node['platform'] == 'ubuntu' # The ceph version of tgt does not provide an Upstart script provider Chef::Provider::Service::Init::Debian - service_name 'tgt' - else - service_name 'tgt' end + service_name 'tgt' supports :restart => true action [:enable, :start] end