]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Supermicro X9DRW has serial console on ttyS1
[chef.git] / cookbooks / hardware / recipes / default.rb
index e1b58c0f359223903e256725388e21923a83a1a3..4d797a52bf6a0f5f15533743a2b776dab79b5cf1 100644 (file)
@@ -40,7 +40,6 @@ case manufacturer
 when "HP"
   package "hponcfg"
   package "hp-health"
-  package "hpacucli"
   unit = "1"
   speed = "115200"
 when "TYAN"
@@ -51,7 +50,7 @@ when "TYAN Computer Corporation"
   speed = "115200"
 when "Supermicro"
   case product
-  when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F"
+  when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F", "X9DRW"
     unit = "1"
     speed = "115200"
   else
@@ -64,6 +63,8 @@ when "IBM"
 end
 
 if manufacturer == "HP" and node[:lsb][:release].to_f > 11.10
+  include_recipe "git"
+
   git "/opt/hp/hp-legacy" do
     action :sync
     repository "git://chef.openstreetmap.org/hp-legacy.git"
@@ -105,7 +106,7 @@ unless unit.nil?
     provider Chef::Provider::Service::Upstart
     action [ :enable, :start ]
     supports :status => true, :restart => true, :reload => false
-    subscribes :restart, resources(:template => "/etc/init/ttyS#{unit}.conf")
+    subscribes :restart, "template[/etc/init/ttyS#{unit}.conf]"
   end
 end
 
@@ -121,7 +122,7 @@ if File.exist?("/etc/default/grub")
     group "root"
     mode 0644
     variables :unit => unit, :speed => speed
-    notifies :run, resources(:execute => "update-grub")
+    notifies :run, "execute[update-grub]"
   end
 end
 
@@ -140,7 +141,85 @@ template "/etc/initramfs-tools/conf.d/mdadm" do
   notifies :run, "execute[update-initramfs]"
 end
 
-if node[:kernel][:modules].include?("mpt2sas")
-  package "sas2ircu"
-  package "sas2ircu-status"
+if node[:kernel][:modules].include?("ipmi_si")
+  package "ipmitool"
+end
+
+tools_packages = []
+status_packages = {}
+
+node[:kernel][:modules].each_key do |modname|
+  case modname
+  when "cciss"
+    tools_packages << "hpacucli"
+    status_packages["cciss-vol-status"] ||= []
+  when "hpsa"
+    tools_packages << "hpacucli"
+    status_packages["cciss-vol-status"] ||= []
+  when "mptsas"
+    tools_packages << "lsiutil"
+    #status_packages["mpt-status"] ||= []
+  when "mpt2sas"
+    tools_packages << "sas2ircu"
+    status_packages["sas2ircu-status"] ||= []
+  when "megaraid_mm"
+    tools_packages << "megactl"
+    status_packages["megaraid-status"] ||= []
+  when "megaraid_sas"
+    tools_packages << "megacli"
+    status_packages["megaclisas-status"] ||= []
+  when "aacraid"
+    tools_packages << "arcconf"
+    status_packages["aacraid-status"] ||= []
+  end
+end
+
+node[:block_device].each do |name,attributes|
+  if attributes[:vendor] == "HP" and attributes[:model] == "LOGICAL VOLUME"
+    if name =~ /^cciss!(c[0-9]+)d[0-9]+$/
+      status_packages["cciss-vol-status"] |= [ "cciss/#{$1}d0" ]
+    else
+      Dir.glob("/sys/block/#{name}/device/scsi_generic/*").each do |sg|
+        status_packages["cciss-vol-status"] |= [ File.basename(sg) ]
+      end
+    end
+  end
+end
+
+["hpacucli", "lsiutil", "sas2ircu", "megactl", "megacli", "arcconf"].each do |tools_package|
+  if tools_packages.include?(tools_package)
+    package tools_package
+  else
+    package tools_package do
+      action :purge
+    end
+  end
+end
+
+["cciss-vol-status", "mpt-status", "sas2ircu-status", "megaraid-status", "megaclisas-status", "aacraid-status"].each do |status_package|
+  if status_packages.include?(status_package)
+    package status_package
+
+    template "/etc/default/#{status_package}d" do
+      source "raid.default.erb"
+      owner "root"
+      group "root"
+      mode 0644
+      variables :devices => status_packages[status_package]
+    end
+
+    service "#{status_package}d" do
+      action [ :start, :enable ]
+      supports :status => false, :restart => true, :reload => false
+      subscribes :restart, "template[/etc/default/#{status_package}d]"
+    end
+  else
+    package status_package do
+      action :purge
+    end
+
+    file "/etc/default/#{status_package}d" do
+      action :delete
+    end
+  end
 end