summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dibowitz <phild@fb.com>2015-07-03 13:04:26 -0700
committerPhil Dibowitz <phild@fb.com>2015-07-03 13:04:26 -0700
commit6f9a8788daaa9dde15cbe5685db97612c86608be (patch)
tree6bbf2bca80ab768421577454b46d17152dd8c26b
parent414c4a6df21073238997dd541c06efd2602bb19d (diff)
downloadohai-6f9a8788daaa9dde15cbe5685db97612c86608be.tar.gz
filesystem2 bugfix
This makes 'mounts' in by_device and 'devices' in by_mount always get initialized as an empty array instead of not existing. if the data doesn't exist. This prevents callers from having to do ``` if foo and foo['mounts'] and foo['mounts'].emtpy? ``` to determine if something is mounted.
-rw-r--r--lib/ohai/plugins/linux/filesystem2.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/filesystem2.rb b/lib/ohai/plugins/linux/filesystem2.rb
index dfb28c5d..265e6e35 100644
--- a/lib/ohai/plugins/linux/filesystem2.rb
+++ b/lib/ohai/plugins/linux/filesystem2.rb
@@ -64,8 +64,8 @@ Ohai.plugin(:Filesystem2) do
next if ['device', 'mount'].include?(key)
view[entry[:device]][key] = val
end
+ view[entry[:device]][:mounts] = [] unless view[entry[:device]][:mounts]
if entry[:mount]
- view[entry[:device]][:mounts] = [] unless view[entry[:device]][:mounts]
view[entry[:device]][:mounts] << entry[:mount]
end
end
@@ -81,8 +81,8 @@ Ohai.plugin(:Filesystem2) do
next if ['mount', 'device'].include?(key)
view[entry[:mount]][key] = val
end
+ view[entry[:mount]][:devices] = [] unless view[entry[:mount]][:devices]
if entry[:device]
- view[entry[:mount]][:devices] = [] unless view[entry[:mount]][:devices]
view[entry[:mount]][:devices] << entry[:device]
end
end