# class Chef::Provider::Mdadm

### Public Instance Methods

action_assemble() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 65
    def action_assemble
      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}")
          shell_out!(command)
          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})")
      end
    end

action_create() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 48
    def action_create
      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 << " --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})")
        end
      else
        Chef::Log.debug("#{@new_resource} raid device already exists, skipping create (#{@new_resource.raid_device})")
      end
    end

action_stop() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 78
    def action_stop
      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}")
          shell_out!(command)
          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")
      end
    end

load_current_resource() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 37
    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}")

      device_not_found = 4
      mdadm = shell_out!("mdadm --detail --test #{@new_resource.raid_device}", :returns => [0,device_not_found])
      exists = (mdadm.status == 0)
      @current_resource.exists(exists)
    end

popen4() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 29
    def popen4
      raise Exception, "deprecated"
    end

whyrun_supported?() click to toggle source

    # File lib/chef/provider/mdadm.rb, line 33
    def whyrun_supported?
      true
    end