Skip to content

Commit

Permalink
rename megaraid_smartd_device_name fact to megaraid_virtual_drives an…
Browse files Browse the repository at this point in the history
…d list all megaraid VD block devices
  • Loading branch information
Joshua Hoblitt committed May 14, 2013
1 parent 5a1fd71 commit f2042c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions lib/facter/megaraid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,14 @@ def lsscsi_usable?
# on Linux we have to find a block device that corresponds to a
# *logical* drive on the controller. Any logical drive will do,
# so long as it's on the same controller. We only support one
# controller for now. If smartmontools is not already installed,
# it will take two Puppet runs to determine this.
Facter.add(:megaraid_smartd_device_name) do
# controller for now.
Facter.add(:megaraid_virtual_drives) do
confine :kernel => [ :Linux ]
setcode do
device = nil
if megacli_usable?
out = Facter::Util::Resolution.exec('lsscsi | awk \'{ if($2 == "disk" && $3 == "LSI") { print $6 } }\'')
out.each_line do |line|
if line =~ /\/dev\/\S+/
device = line
end
end
list = Facter::Util::Resolution.exec('lsscsi | awk \'{ if($2 == "disk" && $3 == "LSI") { print $6 } }\'')
list.map(&:chomp).sort.join(',')
end
device
end
end

Expand Down
3 changes: 2 additions & 1 deletion templates/smartd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ DEVICESCAN <% if @devicescan_options %><%= @devicescan_options %><% end %>
<% end #newline here, please %>
<% end -%>
<% megaraid_adapters = scope.lookupvar('::megaraid_adapters')
megaraid_device = scope.lookupvar('::megaraid_smartd_device_name')
megaraid_device = scope.lookupvar('::megaraid_virtual_drives')
megaraid_drives = scope.lookupvar('::megaraid_physical_drives')
megaraid_device = megaraid_device.split(/,/)[0]
megaraid_drives = megaraid_drives.nil? ? [] : megaraid_drives.split(/,/)

if megaraid_device and megaraid_device != '' and
Expand Down

0 comments on commit f2042c3

Please sign in to comment.