]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/templates/default/ohai.rb.erb
Avoid exceptions on machines with bonded interfaces
[chef.git] / cookbooks / hardware / templates / default / ohai.rb.erb
index e83343a8ed8198611b84513c36d57fdea7437a39..132d5bcacdb015bb697a958a35958363d7562cf0 100644 (file)
@@ -5,12 +5,12 @@ Ohai.plugin(:Hardware) do
 
   def read_sysctl_link(file)
     File.basename(File.readlink(file))
-  rescue Errno::ENOENT
+  rescue Errno::ENOENT, Errno::ENOTDIR
   end
 
   def read_sysctl_file(file)
     IO.read(file).strip
-  rescue Errno::ENOENT, Errno::EINVAL
+  rescue Errno::ENOENT, Errno::ENOTDIR, Errno::EINVAL
   end
 
   def parse_memory_size(size)
@@ -180,7 +180,7 @@ Ohai.plugin(:Hardware) do
         end
       end
 
-      disk[:model].sub!(/-.*$/, "")
+      disk[:model].sub!(/-.*$/, "") if disk[:model]
     end
 
     disk