From 258cbbac6d5cbb22b3ff47254d2456be5e9b09f6 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 23 Mar 2026 22:18:47 +0000 Subject: [PATCH] Drop support for older raid systems we no longer use --- cookbooks/hardware/recipes/default.rb | 31 +- .../hardware/templates/default/ohai.rb.erb | 325 ------------------ 2 files changed, 1 insertion(+), 355 deletions(-) diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 934c3559b..2ac4ce5b8 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -295,26 +295,15 @@ if node[:virtualization][:role] != "guest" || node[:kernel][:modules].each_key do |modname| case modname - when "cciss" - tools_packages << "ssacli" - status_packages["cciss-vol-status"] ||= [] when "hpsa" tools_packages << "ssacli" status_packages["cciss-vol-status"] ||= [] - when "mptsas" - tools_packages << "lsiutil" - status_packages["mpt-status"] ||= [] - when "mpt2sas", "mpt3sas" + when "mpt3sas" tools_packages << "sas2ircu" status_packages["sas2ircu-status"] ||= [] when "megaraid_sas" tools_packages << "megacli" status_packages["megaclisas-status"] ||= [] - when "aacraid" - tools_packages << "arcconf" - status_packages["aacraid-status"] ||= [] - when "arcmsr" - tools_packages << "areca" end end @@ -343,24 +332,6 @@ include_recipe "apt::hwraid" unless status_packages.empty? end end -if tools_packages.include?("areca") - include_recipe "git" - - git "/opt/areca" do - action :sync - repository "https://git.openstreetmap.org/private/areca.git" - depth 1 - user "root" - group "root" - not_if { kitchen? } - end -else - directory "/opt/areca" do - action :delete - recursive true - end -end - %w[cciss-vol-status mpt-status sas2ircu-status megaclisas-status aacraid-status].each do |status_package| package status_package do action :purge diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 1ca3089b7..ac7308202 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -150,10 +150,7 @@ Ohai.plugin(:Hardware) do find_hp_disks(disk) if File.exist?("/usr/sbin/ssacli") find_megaraid_disks(disk) if File.exist?("/usr/sbin/megacli") - find_mpt1_disks(disk) if File.exist?("/usr/sbin/lsiutil") find_mpt2_disks(disk) if File.exist?("/usr/sbin/sas2ircu") - find_adaptec_disks(disk) if File.exist?("/usr/sbin/arcconf") - find_areca_disks(disk) if File.exist?("/opt/areca/x86_64/cli64") find_md_arrays(disk) if File.exist?("/prod/mdstat") @@ -613,86 +610,6 @@ Ohai.plugin(:Hardware) do end end - def find_mpt1_disks(devices) - controllers = [] - disks = [] - - controller = nil - - IO.popen(%w(lsiutil -s)).each do |line| - if line =~ /^\/proc\/mpt\/ioc(\d+)\s+LSI Logic\s+(\S+)\s+/ - controller = { - :id => devices[:controllers].count, - :type => "mpt1", - :model => Regexp.last_match(1), - :arrays => [], - :disks => [] - } - - controllers << controller - devices[:controllers] << controller - elsif line =~ /^\s+(\d+)\s+(\d+)\s+PhysDisk (\d+)\s+(\S+)\s+(\S+)\s+\d+\s+(\S+)\s+/ - disks[Regexp.last_match(3).to_i] = { - :id => devices[:disks].count, - :controller => controller[:id], - :vendor => Regexp.last_match(4), - :model => Regexp.last_match(5), - :sas_address => Regexp.last_match(6), - :arrays => [] - } - - controller[:disks] << devices[:disks].count - devices[:disks] << disks[Regexp.last_match(3).to_i] - end - end - - controllers.each_with_index do |controller, index| - port = index + 1 - array = nil - - IO.popen(["lsiutil", "-p", port.to_s, "-a", "69,0"]).each do |line| - if line =~ /^ (\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+RAID/ - seg = Regexp.last_match(1).to_i - bus = Regexp.last_match(2).to_i - dev = Regexp.last_match(3).to_i - fun = Regexp.last_match(4).to_i - - controller[:pci_slot] = sprintf("%04x:%02x:%02x.%01x", seg, bus, dev, fun) - end - end - - IO.popen(["lsiutil", "-p", port.to_s, "-a", "21,1,0,0"]).each do |line| - if line =~ /^Volume (\d+) is/ - array = { - :id => devices[:arrays].count, - :controller => controller[:id], - :number => Regexp.last_match(1), - :disks => [] - } - - devices[:arrays] << array - controller[:arrays] << array[:id] - elsif line =~ /^ Member \d+ is PhysDisk (\d+) / - array[:disks] << disks[Regexp.last_match(1).to_i][:id] - disks[Regexp.last_match(1).to_i][:arrays] << array[:id] - end - end - end - - disks.each do |disk| - slot = controllers[disk[:controller]][:pci_slot] - sas_address = "0x#{disk[:sas_address]}" - - Dir.glob("/sys/bus/pci/devices/#{slot}/host*/port-*:*/end_device-*:*/sas_device/end_device-*:*").each do |sas_device| - if read_sysctl_file("#{sas_device}/sas_address") == sas_address - if device = Dir.glob("#{sas_device}/device/target*:0:*/*:0:*:0/scsi_generic/sg*").first - disk[:device] = "/dev/#{File.basename(device)}" - end - end - end - end - end - def find_mpt2_disks(devices) controllers = [] @@ -809,248 +726,6 @@ Ohai.plugin(:Hardware) do end end - def find_adaptec_disks(devices) - controller_count = IO.popen(%w(arcconf getconfig 0)).first.scan(/^Controllers Found: (\d+)$/i).first.first.to_i - - 1.upto(controller_count).each do |controller_number| - controller = { - :id => devices[:controllers].count, - :number => controller_number, - :type => "adaptec", - :arrays => [], - :disks => [] - } - - devices[:controllers] << controller - - arrays = [] - disks = [] - - array = nil - disk = nil - - IO.popen(["arcconf", "getconfig", controller_number.to_s]).each do |line| - if line =~ /^Logical Device Number (\d+)$/i - array = { - :id => devices[:arrays].count, - :controller => controller[:id], - :number => Regexp.last_match(1).to_i, - :disks => [] - } - - devices[:arrays] << array - controller[:arrays] << array[:id] - - arrays << array - elsif line =~ /^ Device #(\d+)$/ - disk = nil - elsif line =~ /^ Device is a Hard drive$/ - disk = { - :id => devices[:disks].count, - :controller => controller[:id], - :arrays => [] - } - - devices[:disks] << disk - controller[:disks] << disk[:id] - - disks << disk - elsif disk && line =~ /^ Reported Channel,Device\(T:L\)\s*:\s+(\d+),(\d+)\(\d+:0\)\s*$/ - disk[:channel_number] = Regexp.last_match(1) - disk[:device_number] = Regexp.last_match(2) - elsif disk && line =~ /^ State\s*:\s+(\S.*\S)\s*$/ - case Regexp.last_match(1) - when "Online" then disk[:status] = "online" - when "Online (JBOD)" then disk[:status] = "online" - when "Hot Spare" then disk[:status] = "hotspare" - when "Ready" then disk[:status] = "unconfigured" - when "Global Hot-Spare" then disk[:status] = "hostspare" - when "Dedicated Hot-Spare" then disk[:status] = "hotspare" - else disk[:status] = "unknown" - end - elsif disk && line =~ /^ (\S.*\S)\s*:\s+(\S.*\S)\s*$/ - case Regexp.last_match(1) - when "Reported Location" then disk[:location] = Regexp.last_match(2) - when "Vendor" then disk[:vendor] = Regexp.last_match(2) - when "Model" then disk[:model] = Regexp.last_match(2) - when "Firmware" then disk[:firmware_version] = Regexp.last_match(2) - when "Serial number" then disk[:serial_number] = Regexp.last_match(2) - when "Serial Number" then disk[:serial_number] = Regexp.last_match(2) - when "World-wide name" then disk[:wwn] = Regexp.last_match(2) - when "World-wide Name" then disk[:wwn] = Regexp.last_match(2) - when "Total Size" then disk[:size] = memory_to_disk_size(Regexp.last_match(2)) - when "Size" then disk[:size] = memory_to_disk_size(Regexp.last_match(2)) - end - elsif array && line =~ / Present \(.*((?:Connector|Enclosure):\d+,\s*(?:Device|Slot):\d+)\) / - array[:disks] << Regexp.last_match(1).tr(":", " ").gsub(/,\s*/, ", ") - elsif array && line =~ /^ Status of Logical Device\s*:\s+(\S.*\S)\s*$/ - case Regexp.last_match(1) - when "Optimal" then array[:status] = "optimal" - else array[:status] = "unknown" - end - elsif array && line =~ /^ (\S.*\S)\s*:\s+(\S.*\S)\s*$/ - case Regexp.last_match(1) - when "RAID level" then array[:raid_level] = Regexp.last_match(2) - when "RAID Level" then array[:raid_level] = Regexp.last_match(2) - when "Size" then array[:size] = memory_to_disk_size(Regexp.last_match(2)) - end - elsif line =~ /^ (\S.*\S)\s*:\s+(\S.*\S)\s*$/ - case Regexp.last_match(1) - when "Controller Model" then controller[:model] = Regexp.last_match(2) - when "Controller Serial Number" then controller[:serial_number] = Regexp.last_match(2) - when "Controller World Wide Name" then controller[:wwn] = Regexp.last_match(2) - when "BIOS" then controller[:bios_version] = Regexp.last_match(2) - when "Firmware" then controller[:firmware_version] = Regexp.last_match(2) - end - elsif line =~ /^ Serial Number\s*:\s+(\S.*\S)\s*$/ - controller[:serial_number] = Regexp.last_match(1) - end - end - - host = Dir.glob("/sys/class/scsi_host/host*").find do |host| - read_sysctl_file("#{host}/serial_number") == controller[:serial_number] - end - - arrays.each do |array| - array_number = array[:number] - device = Dir.glob("#{host}/device/target*:0:#{array_number}/*:0:#{array_number}:0/block/*").first - - array[:device] = "/dev/#{File.basename(device)}" - - array[:disks].map! do |location| - disk = disks.find { |disk| disk[:location] == location } - - controller_number = controller[:number] - 1 - device_number = disk[:device_number] - - disk[:device] = "/dev/#{File.basename(device)}" - disk[:smart_device] = "aacraid,#{controller_number},0,#{device_number}" - - disk[:arrays] << array[:id] - disk[:id] - end - end - end - end - - def find_areca_disks(devices) - controller = { - :id => devices[:controllers].count, - :type => "areca", - :arrays => [], - :disks => [] - } - - devices[:controllers] << controller - - IO.popen(%w(/opt/areca/x86_64/cli64 sys info)).each do |line| - next unless line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ - - case Regexp.last_match(1) - when "Firmware Version" then controller[:firmware_version] = Regexp.last_match(2) - when "BOOT ROM Version" then controller[:bios_version] = Regexp.last_match(2) - when "Serial Number" then controller[:serial_number] = Regexp.last_match(2) - when "Controller Name" then controller[:model] = Regexp.last_match(2) - end - end - - path = Dir.glob("/sys/bus/pci/devices/*/host*/scsi_host/host*/host_fw_model").find do |file| - read_sysctl_file(file) == controller[:model] - end - - controller[:pci_slot] = File.basename(File.expand_path("#{path}/../../../..")) - controller[:device] = File.basename(Dir.glob(File.expand_path("#{path}/../../../target0:0:16/0:0:16:0/scsi_generic/*")).first) - - arrays = [] - - IO.popen(%w(/opt/areca/x86_64/cli64 vsf info)).each do |line| - next unless line =~ /^\s+(\d+)\s+/ - array = { - :id => devices[:arrays].count, - :number => Regexp.last_match(1), - :controller => controller[:id], - :disks => [] - } - - devices[:arrays] << array - controller[:arrays] << array[:id] - - arrays << array - end - - arrays.each do |array| - IO.popen(["/opt/areca/x86_64/cli64", "vsf", "info", "vol=#{array[:number]}"]).each do |line| - if line =~ /^SCSI Ch\/Id\/Lun\s+:\s+(\d+)\/(\d+)\/(\d+)\s*$/ - pci_slot = controller[:pci_slot] - channel = Regexp.last_match(1).to_i - id = Regexp.last_match(2).to_i - lun = Regexp.last_match(3).to_i - - device = Dir.glob("/sys/bus/pci/devices/#{pci_slot}/host*/target*:0:0/0:#{channel}:#{id}:#{lun}/block/*").first - - array[:device] = "/dev/#{File.basename(device)}" - elsif line =~ /^Volume State\s+:\s+(.*\S)\s*$/ - case Regexp.last_match(1) - when "Normal" then array[:status] = "optimal" - else array[:status] = "unknown" - end - elsif line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ - case Regexp.last_match(1) - when "Volume Set Name" then array[:volume_set] = Regexp.last_match(2) - when "Raid Set Name" then array[:raid_set] = Regexp.last_match(2) - when "Volume Capacity" then array[:size] = format_disk_size(Regexp.last_match(2).to_f * 1000 * 1000) - when "Raid Level" then array[:raid_level] = Regexp.last_match(2).sub(/^Raid/, "") - end - end - end - end - - disks = [] - - IO.popen(%w(/opt/areca/x86_64/cli64 disk info)).each do |line| - next unless line =~ /^\s+(\d+)\s+.*\s+\d+\.\d+GB\s+(\S.*\S)\s*$/ - next if Regexp.last_match(2) == "N.A." - - disk = { - :id => devices[:disks].count, - :number => Regexp.last_match(1), - :controller => controller[:id], - :arrays => [] - } - - devices[:disks] << disk - controller[:disks] << disk[:id] - - if array = arrays.find { |array| array[:raid_set] == Regexp.last_match(2) } - disk[:arrays] << array[:id] - array[:disks] << disk[:id] - end - - disks << disk - end - - disks.each do |disk| - IO.popen(["/opt/areca/x86_64/cli64", "disk", "info", "drv=#{disk[:number]}"]).each do |line| - if line =~ /^IDE Channel\s+:\s+(\d+)\s*$/i - disk[:smart_device] = "areca,#{Regexp.last_match(1)}" - elsif line =~ /^Device Location\s+:\s+Enclosure#(\d+) Slot#?\s*0*(\d+)\s*$/i - disk[:smart_device] = "areca,#{Regexp.last_match(2)}/#{Regexp.last_match(1)}" - elsif line =~ /^Device State\s+:\s+(.*\S)\s*$/ - case Regexp.last_match(1) - when "NORMAL" then disk[:status] = "online" - else disk[:status] = "unknown" - end - elsif line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ - case Regexp.last_match(1) - when "Model Name" then disk[:vendor], disk[:model] = Regexp.last_match(2).split - when "Serial Number" then disk[:serial_number] = Regexp.last_match(2) - when "Disk Capacity" then disk[:size] = format_disk_size(Regexp.last_match(2).to_f * 1000 * 1000) - end - end - end - end - end - def lvm_devices { :pvs => find_lvm_pvs, -- 2.39.5