2 # Cookbook Name:: hardware
5 # Copyright 2012, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 case node[:cpu][:"0"][:vendor_id]
22 package "intel-microcode"
25 if node[:dmi] and node[:dmi][:system]
26 case node[:dmi][:system][:manufacturer]
28 manufacturer = node[:dmi][:base_board][:manufacturer]
29 product = node[:dmi][:base_board][:product_name]
31 manufacturer = node[:dmi][:system][:manufacturer]
32 product = node[:dmi][:system][:product_name]
35 manufacturer = "Unknown"
48 when "TYAN Computer Corporation"
53 when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F"
65 if manufacturer == "HP" and node[:lsb][:release].to_f > 11.10
68 git "/opt/hp/hp-legacy" do
70 repository "git://chef.openstreetmap.org/hp-legacy.git"
75 link "/opt/hp/hp-health/bin/hpasmd" do
76 to "/opt/hp/hp-legacy/hpasmd"
79 link "/usr/lib/libhpasmintrfc.so.3.0" do
80 to "/opt/hp/hp-legacy/libhpasmintrfc.so.3.0"
83 link "/usr/lib/libhpasmintrfc.so.3" do
84 to "libhpasmintrfc.so.3.0"
87 link "/usr/lib/libhpasmintrfc.so" do
88 to "libhpasmintrfc.so.3.0"
93 file "/etc/init/ttySttyS#{unit}.conf" do
97 template "/etc/init/ttyS#{unit}.conf" do
102 variables :unit => unit, :speed => speed
105 service "ttyS#{unit}" do
106 provider Chef::Provider::Service::Upstart
107 action [ :enable, :start ]
108 supports :status => true, :restart => true, :reload => false
109 subscribes :restart, "template[/etc/init/ttyS#{unit}.conf]"
113 if File.exist?("/etc/default/grub")
114 execute "update-grub" do
116 command "/usr/sbin/update-grub"
119 template "/etc/default/grub" do
124 variables :unit => unit, :speed => speed
125 notifies :run, "execute[update-grub]"
129 execute "update-initramfs" do
131 command "update-initramfs -u -k all"
136 template "/etc/initramfs-tools/conf.d/mdadm" do
137 source "initramfs-mdadm.erb"
141 notifies :run, "execute[update-initramfs]"
144 if node[:kernel][:modules].include?("ipmi_si")
151 node[:kernel][:modules].each_key do |modname|
154 tools_packages << "hpacucli"
155 status_packages["cciss-vol-status"] ||= []
157 tools_packages << "hpacucli"
158 status_packages["cciss-vol-status"] ||= []
160 tools_packages << "lsiutil"
161 #status_packages["mpt-status"] ||= []
163 tools_packages << "sas2ircu"
164 status_packages["sas2ircu-status"] ||= []
166 tools_packages << "megactl"
167 status_packages["megaraid-status"] ||= []
169 tools_packages << "megacli"
170 status_packages["megaclisas-status"] ||= []
172 tools_packages << "arcconf"
173 status_packages["aacraid-status"] ||= []
177 node[:block_device].each do |name,attributes|
178 if attributes[:vendor] == "HP" and attributes[:model] == "LOGICAL VOLUME"
179 if name =~ /^cciss!(c[0-9]+)d[0-9]+$/
180 status_packages["cciss-vol-status"] |= [ "cciss/#{$1}d0" ]
182 Dir.glob("/sys/block/#{name}/device/scsi_generic/*").each do |sg|
183 status_packages["cciss-vol-status"] |= [ File.basename(sg) ]
189 ["hpacucli", "lsiutil", "sas2ircu", "megactl", "megacli", "arcconf"].each do |tools_package|
190 if tools_packages.include?(tools_package)
191 package tools_package
193 package tools_package do
199 ["cciss-vol-status", "mpt-status", "sas2ircu-status", "megaraid-status", "megaclisas-status", "aacraid-status"].each do |status_package|
200 if status_packages.include?(status_package)
201 package status_package
203 template "/etc/default/#{status_package}d" do
204 source "raid.default.erb"
208 variables :devices => status_packages[status_package]
211 service "#{status_package}d" do
212 action [ :start, :enable ]
213 supports :status => false, :restart => true, :reload => false
214 subscribes :restart, "template[/etc/default/#{status_package}d]"
217 package status_package do
221 file "/etc/default/#{status_package}d" do