diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-15 13:02:21 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-15 13:02:21 -0800 |
commit | 80b6150b5aafa1426629102d2b70f13b893b9faf (patch) | |
tree | 0e7f79dd1b90b0f4fe18b0247c44d3f155cd1fce /lib/chef/provider/mdadm.rb | |
parent | ac07b819652edb10b0421c12c16cce13e6e70f23 (diff) | |
download | chef-80b6150b5aafa1426629102d2b70f13b893b9faf.tar.gz |
cleans up the remaining new/current_resource ivarslcg/remove-ivars
switches from using ivars to accessors for getters
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/mdadm.rb')
-rw-r--r-- | lib/chef/provider/mdadm.rb | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index f8225ff63a..88da7b5eff 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -34,57 +34,57 @@ class Chef end def load_current_resource - @current_resource = Chef::Resource::Mdadm.new(@new_resource.name) - @current_resource.raid_device(@new_resource.raid_device) - Chef::Log.debug("#{@new_resource} checking for software raid device #{@current_resource.raid_device}") + @current_resource = Chef::Resource::Mdadm.new(new_resource.name) + current_resource.raid_device(new_resource.raid_device) + Chef::Log.debug("#{new_resource} checking for software raid device #{current_resource.raid_device}") device_not_found = 4 - mdadm = shell_out!("mdadm --detail --test #{@new_resource.raid_device}", :returns => [0, device_not_found]) + mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", :returns => [0, device_not_found]) exists = (mdadm.status == 0) - @current_resource.exists(exists) + current_resource.exists(exists) end def action_create - unless @current_resource.exists + unless current_resource.exists converge_by("create RAID device #{new_resource.raid_device}") do - command = "yes | mdadm --create #{@new_resource.raid_device} --level #{@new_resource.level}" - command << " --chunk=#{@new_resource.chunk}" unless @new_resource.level == 1 - command << " --metadata=#{@new_resource.metadata}" - command << " --bitmap=#{@new_resource.bitmap}" if @new_resource.bitmap - command << " --layout=#{@new_resource.layout}" if @new_resource.layout - command << " --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}" - Chef::Log.debug("#{@new_resource} mdadm command: #{command}") + command = "yes | mdadm --create #{new_resource.raid_device} --level #{new_resource.level}" + command << " --chunk=#{new_resource.chunk}" unless new_resource.level == 1 + command << " --metadata=#{new_resource.metadata}" + command << " --bitmap=#{new_resource.bitmap}" if new_resource.bitmap + command << " --layout=#{new_resource.layout}" if new_resource.layout + command << " --raid-devices #{new_resource.devices.length} #{new_resource.devices.join(" ")}" + Chef::Log.debug("#{new_resource} mdadm command: #{command}") shell_out!(command) - Chef::Log.info("#{@new_resource} created raid device (#{@new_resource.raid_device})") + Chef::Log.info("#{new_resource} created raid device (#{new_resource.raid_device})") end else - Chef::Log.debug("#{@new_resource} raid device already exists, skipping create (#{@new_resource.raid_device})") + Chef::Log.debug("#{new_resource} raid device already exists, skipping create (#{new_resource.raid_device})") end end def action_assemble - unless @current_resource.exists + unless current_resource.exists converge_by("assemble RAID device #{new_resource.raid_device}") do - command = "yes | mdadm --assemble #{@new_resource.raid_device} #{@new_resource.devices.join(" ")}" - Chef::Log.debug("#{@new_resource} mdadm command: #{command}") + command = "yes | mdadm --assemble #{new_resource.raid_device} #{new_resource.devices.join(" ")}" + Chef::Log.debug("#{new_resource} mdadm command: #{command}") shell_out!(command) - Chef::Log.info("#{@new_resource} assembled raid device (#{@new_resource.raid_device})") + Chef::Log.info("#{new_resource} assembled raid device (#{new_resource.raid_device})") end else - Chef::Log.debug("#{@new_resource} raid device already exists, skipping assemble (#{@new_resource.raid_device})") + Chef::Log.debug("#{new_resource} raid device already exists, skipping assemble (#{new_resource.raid_device})") end end def action_stop - if @current_resource.exists + if current_resource.exists converge_by("stop RAID device #{new_resource.raid_device}") do - command = "yes | mdadm --stop #{@new_resource.raid_device}" - Chef::Log.debug("#{@new_resource} mdadm command: #{command}") + command = "yes | mdadm --stop #{new_resource.raid_device}" + Chef::Log.debug("#{new_resource} mdadm command: #{command}") shell_out!(command) - Chef::Log.info("#{@new_resource} stopped raid device (#{@new_resource.raid_device})") + Chef::Log.info("#{new_resource} stopped raid device (#{new_resource.raid_device})") end else - Chef::Log.debug("#{@new_resource} raid device doesn't exist (#{@new_resource.raid_device}) - not stopping") + Chef::Log.debug("#{new_resource} raid device doesn't exist (#{new_resource.raid_device}) - not stopping") end end |