]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/templates/default/lldp.rb.erb
Fix smart device detection for megaraid arrays
[chef.git] / cookbooks / hardware / templates / default / lldp.rb.erb
index 15e35050ad8c0759f2710468184a1e9adb83d313..fb8d8cf0ff41ef1e57b6bac7574365bcb76095f1 100644 (file)
@@ -6,9 +6,15 @@ Ohai.plugin(:Lldp) do
   collect_data(:default) do
     lldp Mash.new
 
-    json = JSON.parse(%x(/sbin/lldpctl -f json))
+    json = JSON.parse(%x(/usr/sbin/lldpctl -f json))
 
-    json["lldp"]["interface"].each do |interface|
+    interfaces = if json["lldp"]["interface"].is_a?(Array)
+                   json["lldp"]["interface"]
+                 else
+                   [json["lldp"]["interface"]]
+                 end
+
+    interfaces.each do |interface|
       interface.each do |name, details|
         lldp[name] = details
       end