summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-04-03 20:42:27 -0700
committerTim Smith <tsmith@chef.io>2017-04-03 20:42:27 -0700
commit9cf706651606715b638317924447b3a8dfafd4bd (patch)
treea251a79c6daa04c9aa4025db661550a19f87ac80
parent7d46875b830650d8a5ba1059ad16b9a18a664ec9 (diff)
downloadohai-filesystem_2_no_more.tar.gz
Fully replace filesystem with filesystem2 on Darwin and fix Linux specsfilesystem_2_no_more
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/darwin/filesystem.rb90
-rw-r--r--lib/ohai/plugins/darwin/filesystem2.rb107
-rw-r--r--lib/ohai/plugins/linux/filesystem.rb (renamed from lib/ohai/plugins/linux/filesystem2.rb)18
-rw-r--r--spec/unit/plugins/darwin/filesystem2_spec.rb139
-rw-r--r--spec/unit/plugins/darwin/filesystem_spec.rb73
-rw-r--r--spec/unit/plugins/linux/filesystem_spec.rb (renamed from spec/unit/plugins/linux/filesystem2_spec.rb)56
6 files changed, 166 insertions, 317 deletions
diff --git a/lib/ohai/plugins/darwin/filesystem.rb b/lib/ohai/plugins/darwin/filesystem.rb
index c3534bbb..c2f4048d 100644
--- a/lib/ohai/plugins/darwin/filesystem.rb
+++ b/lib/ohai/plugins/darwin/filesystem.rb
@@ -1,6 +1,8 @@
#
+# Author:: Phil Dibowitz (<phil@ipom.com>)
# Author:: Benjamin Black (<bb@chef.io>)
# Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2015 Facebook, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,46 +20,90 @@
Ohai.plugin(:Filesystem) do
provides "filesystem"
+ provides "filesystem2"
+
+ def generate_device_view(fs)
+ view = {}
+ fs.each_value do |entry|
+ view[entry[:device]] = Mash.new unless view[entry[:device]]
+ entry.each do |key, val|
+ next if %w{device mount}.include?(key)
+ view[entry[:device]][key] = val
+ end
+ if entry[:mount]
+ view[entry[:device]][:mounts] = [] unless view[entry[:device]][:mounts]
+ view[entry[:device]][:mounts] << entry[:mount]
+ end
+ end
+ view
+ end
+
+ def generate_mountpoint_view(fs)
+ view = {}
+ fs.each_value do |entry|
+ next unless entry[:mount]
+ view[entry[:mount]] = Mash.new unless view[entry[:mount]]
+ entry.each do |key, val|
+ next if %w{mount device}.include?(key)
+ view[entry[:mount]][key] = val
+ end
+ if entry[:device]
+ view[entry[:mount]][:devices] = [] unless view[entry[:mount]][:devices]
+ view[entry[:mount]][:devices] << entry[:device]
+ end
+ end
+ view
+ end
collect_data(:darwin) do
fs = Mash.new
-
block_size = 0
+ # on new versions of OSX, -i is default, on old versions it's not, so
+ # specifying it gets consistent output
so = shell_out("df -i")
- so.stdout.lines do |line|
+ so.stdout.each_line do |line|
case line
when /^Filesystem\s+(\d+)-/
block_size = $1.to_i
next
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$/
- filesystem = $1
- fs[filesystem] = Mash.new
- fs[filesystem][:block_size] = block_size
- # To match linux, these should be strings, but we don't want
- # to break back compat so we'll leave them as they are. In filesystem2
- # we make them consistent.
- fs[filesystem][:kb_size] = $2.to_i / (1024 / block_size)
- fs[filesystem][:kb_used] = $3.to_i / (1024 / block_size)
- fs[filesystem][:kb_available] = $4.to_i / (1024 / block_size)
- fs[filesystem][:percent_used] = $5
- fs[filesystem][:inodes_used] = $6
- fs[filesystem][:inodes_available] = $7
- fs[filesystem][:total_inodes] = ($6.to_i + $7.to_i).to_s
- fs[filesystem][:mount] = $9
+ key = "#{$1},#{$9}"
+ fs[key] = Mash.new
+ fs[key][:block_size] = block_size
+ fs[key][:device] = $1
+ fs[key][:kb_size] = ($2.to_i / (1024 / block_size)).to_s
+ fs[key][:kb_used] = ($3.to_i / (1024 / block_size)).to_s
+ fs[key][:kb_available] = ($4.to_i / (1024 / block_size)).to_s
+ fs[key][:percent_used] = $5
+ fs[key][:inodes_used] = $6
+ fs[key][:inodes_available] = $7
+ fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
+ fs[key][:inodes_percent_used] = $8
+ fs[key][:mount] = $9
end
end
so = shell_out("mount")
so.stdout.lines do |line|
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
- filesystem = $1
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem][:mount] = $2
- fs[filesystem][:fs_type] = $3
- fs[filesystem][:mount_options] = $4.split(/,\s*/)
+ key = "#{$1},#{$2}"
+ fs[key] = Mash.new unless fs.has_key?(key)
+ fs[key][:mount] = $2
+ fs[key][:fs_type] = $3
+ fs[key][:mount_options] = $4.split(/,\s*/)
end
end
- filesystem fs
+ by_pair = fs
+ by_device = generate_device_view(fs)
+ by_mountpoint = generate_mountpoint_view(fs)
+
+ fs_data = Mash.new
+ fs_data["by_device"] = by_device
+ fs_data["by_mountpoint"] = by_mountpoint
+ fs_data["by_pair"] = by_pair
+
+ filesystem fs_data
+ filesystem2 fs_data
end
end
diff --git a/lib/ohai/plugins/darwin/filesystem2.rb b/lib/ohai/plugins/darwin/filesystem2.rb
deleted file mode 100644
index 45b41e18..00000000
--- a/lib/ohai/plugins/darwin/filesystem2.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-# Author:: Phil Dibowitz (<phil@ipom.com>)
-# Author:: Benjamin Black (<bb@chef.io>)
-# Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
-# Copyright:: Copyright (c) 2015 Facebook, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin(:Filesystem2) do
- provides "filesystem2"
-
- def generate_device_view(fs)
- view = {}
- fs.each_value do |entry|
- view[entry[:device]] = Mash.new unless view[entry[:device]]
- entry.each do |key, val|
- next if %w{device mount}.include?(key)
- view[entry[:device]][key] = val
- end
- if entry[:mount]
- view[entry[:device]][:mounts] = [] unless view[entry[:device]][:mounts]
- view[entry[:device]][:mounts] << entry[:mount]
- end
- end
- view
- end
-
- def generate_mountpoint_view(fs)
- view = {}
- fs.each_value do |entry|
- next unless entry[:mount]
- view[entry[:mount]] = Mash.new unless view[entry[:mount]]
- entry.each do |key, val|
- next if %w{mount device}.include?(key)
- view[entry[:mount]][key] = val
- end
- if entry[:device]
- view[entry[:mount]][:devices] = [] unless view[entry[:mount]][:devices]
- view[entry[:mount]][:devices] << entry[:device]
- end
- end
- view
- end
-
- collect_data(:darwin) do
- fs = Mash.new
- block_size = 0
- # on new versions of OSX, -i is default, on old versions it's not, so
- # specifying it gets consistent output
- so = shell_out("df -i")
- so.stdout.each_line do |line|
- case line
- when /^Filesystem\s+(\d+)-/
- block_size = $1.to_i
- next
- when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$/
- key = "#{$1},#{$9}"
- fs[key] = Mash.new
- fs[key][:block_size] = block_size
- fs[key][:device] = $1
- fs[key][:kb_size] = ($2.to_i / (1024 / block_size)).to_s
- fs[key][:kb_used] = ($3.to_i / (1024 / block_size)).to_s
- fs[key][:kb_available] = ($4.to_i / (1024 / block_size)).to_s
- fs[key][:percent_used] = $5
- fs[key][:inodes_used] = $6
- fs[key][:inodes_available] = $7
- fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
- fs[key][:inodes_percent_used] = $8
- fs[key][:mount] = $9
- end
- end
-
- so = shell_out("mount")
- so.stdout.lines do |line|
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
- key = "#{$1},#{$2}"
- fs[key] = Mash.new unless fs.has_key?(key)
- fs[key][:mount] = $2
- fs[key][:fs_type] = $3
- fs[key][:mount_options] = $4.split(/,\s*/)
- end
- end
-
- by_pair = fs
- by_device = generate_device_view(fs)
- by_mountpoint = generate_mountpoint_view(fs)
-
- fs2 = Mash.new
- fs2["by_device"] = by_device
- fs2["by_mountpoint"] = by_mountpoint
- fs2["by_pair"] = by_pair
-
- filesystem2 fs2
- end
-end
diff --git a/lib/ohai/plugins/linux/filesystem2.rb b/lib/ohai/plugins/linux/filesystem.rb
index 94c14985..4e6791d3 100644
--- a/lib/ohai/plugins/linux/filesystem2.rb
+++ b/lib/ohai/plugins/linux/filesystem.rb
@@ -1,7 +1,7 @@
#
# Author:: Phil Dibowitz <phil@ipom.com>
# Author:: Adam Jacob <adam@chef.io>
-# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2008-2017 Chef Software, Inc.
# Copyright:: Copyright (c) 2015 Facebook, Inc.
# License:: Apache License, Version 2.0
#
@@ -18,9 +18,9 @@
# limitations under the License.
#
-Ohai.plugin(:Filesystem2) do
- provides "filesystem2"
+Ohai.plugin(:Filesystem) do
provides "filesystem"
+ provides "filesystem2"
def find_device(name)
%w{/dev /dev/mapper}.each do |dir|
@@ -213,13 +213,13 @@ Ohai.plugin(:Filesystem2) do
by_device = generate_device_view(fs)
by_mountpoint = generate_mountpoint_view(fs)
- fs2 = Mash.new
- fs2["by_device"] = by_device
- fs2["by_mountpoint"] = by_mountpoint
- fs2["by_pair"] = by_pair
+ fs_data = Mash.new
+ fs_data["by_device"] = by_device
+ fs_data["by_mountpoint"] = by_mountpoint
+ fs_data["by_pair"] = by_pair
# Set the filesystem data
- filesystem2 fs2
- filesystem fs2
+ filesystem fs_data
+ filesystem2 fs_data
end
end
diff --git a/spec/unit/plugins/darwin/filesystem2_spec.rb b/spec/unit/plugins/darwin/filesystem2_spec.rb
deleted file mode 100644
index 6ba89ac3..00000000
--- a/spec/unit/plugins/darwin/filesystem2_spec.rb
+++ /dev/null
@@ -1,139 +0,0 @@
-#
-# Author:: Phil Dibowitz (<phil@ipom.com>)
-# Copyright:: Copyright (c) 2015 Facebook, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require_relative "../../../spec_helper.rb"
-
-describe Ohai::System, "darwin filesystem2 plugin" do
- let (:plugin) { get_plugin("darwin/filesystem2") }
- before(:each) do
- allow(plugin).to receive(:collect_os).and_return(:darwin)
-
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
- end
-
- describe "when gathering filesystem usage data from df" do
- before(:each) do
- @stdout = <<-DF
-Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
-/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
-devfs 385 385 0 100% 666 0 100% /dev
-map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
-map -hosts 0 0 0 100% 0 0 100% /net
-map -static 0 0 0 100% 0 0 100% /mobile_symbol
-deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
-DF
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, ""))
- end
-
- it "should run df -i" do
- expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, ""))
- plugin.run
- end
-
- it "should set size to value from df -i" do
- plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%")
- end
-
- it "should set device and mount to value from df -i" do
- plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2")
- end
-
- it "should set inode info to value from df -i" do
- plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386")
- end
- end
-
- describe "when gathering mounted filesystem data from mount" do
- before(:each) do
- @stdout = <<-MOUNT
-/dev/disk0s2 on / (hfs, local, journaled)
-devfs on /dev (devfs, local, nobrowse)
-map /etc/auto.direct on /mnt/vol (autofs, automounted, nobrowse)
-map -hosts on /net (autofs, nosuid, automounted, nobrowse)
-map -static on /mobile_symbol (autofs, automounted, nobrowse)
-deweyfs@osxfuse0 on /mnt/dewey (osxfusefs, synchronous, nobrowse)
-MOUNT
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
- end
-
- it "should run mount" do
- expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
- plugin.run
- end
-
- it "should set values from mount" do
- plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs")
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq(%w{local journaled})
- end
- end
-
- describe "when gathering filesystem data with devices mounted more than once" do
- before(:each) do
- @dfstdout = <<-DF
-Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
-/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
-devfs 385 385 0 100% 666 0 100% /dev
-map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
-map -hosts 0 0 0 100% 0 0 100% /net
-map -static 0 0 0 100% 0 0 100% /mobile_symbol
-deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
-/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /another/mountpoint
-DF
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
- end
-
- it "should provide a devices view with all mountpoints" do
- plugin.run
- expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"])
- end
- end
-
- describe "when gathering filesystem data with double-mounts" do
- before(:each) do
- @dfstdout = <<-DF
-Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
-/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
-devfs 385 385 0 100% 666 0 100% /dev
-map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
-map -hosts 0 0 0 100% 0 0 100% /net
-map -static 0 0 0 100% 0 0 100% /mobile_symbol
-deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
-/dev/disk0s3 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
-/dev/disk0s4 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
-DF
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
- end
-
- it "should provide a mounts view with all devices" do
- plugin.run
- expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"])
- end
- end
-end
diff --git a/spec/unit/plugins/darwin/filesystem_spec.rb b/spec/unit/plugins/darwin/filesystem_spec.rb
index d97a89d9..378d6da9 100644
--- a/spec/unit/plugins/darwin/filesystem_spec.rb
+++ b/spec/unit/plugins/darwin/filesystem_spec.rb
@@ -27,6 +27,11 @@ describe Ohai::System, "darwin filesystem plugin" do
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
end
+ it "sets both filesystem and filesystem2 attributes" do
+ plugin.run
+ expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
+ end
+
describe "when gathering filesystem usage data from df" do
before(:each) do
@stdout = <<-DF
@@ -48,22 +53,23 @@ DF
it "should set size to value from df -i" do
plugin.run
- expect(plugin[:filesystem]["/dev/disk0s2"][:kb_size]).to eq(244277768)
- expect(plugin[:filesystem]["/dev/disk0s2"][:kb_used]).to eq(156848224)
- expect(plugin[:filesystem]["/dev/disk0s2"][:kb_available]).to eq(87173544)
- expect(plugin[:filesystem]["/dev/disk0s2"][:percent_used]).to eq("65%")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%")
end
- it "should set mount to value from df -i" do
+ it "should set device and mount to value from df -i" do
plugin.run
- expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2")
end
it "should set inode info to value from df -i" do
plugin.run
- expect(plugin[:filesystem]["/dev/disk0s2"][:total_inodes]).to eq("61069440")
- expect(plugin[:filesystem]["/dev/disk0s2"][:inodes_used]).to eq("39276054")
- expect(plugin[:filesystem]["/dev/disk0s2"][:inodes_available]).to eq("21793386")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386")
end
end
@@ -87,9 +93,52 @@ MOUNT
it "should set values from mount" do
plugin.run
- expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/")
- expect(plugin[:filesystem]["/dev/disk0s2"][:fs_type]).to eq("hfs")
- expect(plugin[:filesystem]["/dev/disk0s2"][:mount_options]).to eq(%w{local journaled})
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs")
+ expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq(%w{local journaled})
+ end
+ end
+
+ describe "when gathering filesystem data with devices mounted more than once" do
+ before(:each) do
+ @dfstdout = <<-DF
+Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
+/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
+devfs 385 385 0 100% 666 0 100% /dev
+map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
+map -hosts 0 0 0 100% 0 0 100% /net
+map -static 0 0 0 100% 0 0 100% /mobile_symbol
+deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
+/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /another/mountpoint
+DF
+ allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
+ end
+
+ it "should provide a devices view with all mountpoints" do
+ plugin.run
+ expect(plugin[:filesystem]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"])
+ end
+ end
+
+ describe "when gathering filesystem data with double-mounts" do
+ before(:each) do
+ @dfstdout = <<-DF
+Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
+/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
+devfs 385 385 0 100% 666 0 100% /dev
+map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
+map -hosts 0 0 0 100% 0 0 100% /net
+map -static 0 0 0 100% 0 0 100% /mobile_symbol
+deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
+/dev/disk0s3 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
+/dev/disk0s4 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
+DF
+ allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
+ end
+
+ it "should provide a mounts view with all devices" do
+ plugin.run
+ expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"])
end
end
end
diff --git a/spec/unit/plugins/linux/filesystem2_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb
index 33e26f49..f1880e3c 100644
--- a/spec/unit/plugins/linux/filesystem2_spec.rb
+++ b/spec/unit/plugins/linux/filesystem_spec.rb
@@ -19,7 +19,7 @@
require_relative "../../../spec_helper.rb"
describe Ohai::System, "Linux filesystem plugin" do
- let (:plugin) { get_plugin("linux/filesystem2") }
+ let (:plugin) { get_plugin("linux/filesystem") }
before(:each) do
allow(plugin).to receive(:collect_os).and_return(:linux)
@@ -52,9 +52,9 @@ describe Ohai::System, "Linux filesystem plugin" do
end
end
- it "sets both filesystem and filesystem_v2 attributes" do
+ it "sets both filesystem and filesystem2 attributes" do
plugin.run
- expect(plugin[:filesystem]).to eq(plugin[:filesystem_v2])
+ expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
end
describe "when gathering filesystem usage data from df" do
@@ -93,42 +93,42 @@ DFi
it "should set kb_size to value from df -P" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
end
it "should set kb_used to value from df -P" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
end
it "should set kb_available to value from df -P" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
end
it "should set percent_used to value from df -P" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
end
it "should set mount to value from df -P" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
it "should set total_inodes to value from df -iP" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
end
it "should set inodes_used to value from df -iP" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
end
it "should set inodes_available to value from df -iP" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
end
end
@@ -161,17 +161,17 @@ MOUNT
it "should set mount to value from mount" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
it "should set fs_type to value from mount" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
end
it "should set mount_options to an array of values from mount" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
end
end
@@ -227,9 +227,9 @@ BLKID_TYPE
it "should set kb_size to value from blkid" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
- expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
- expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
+ expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
+ expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
+ expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
end
end
@@ -287,14 +287,14 @@ BLKID_TYPE
it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
- expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
- expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
+ expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
+ expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
+ expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
end
it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
end
end
@@ -333,17 +333,17 @@ MOUNTS
it "should set mount to value from /proc/mounts" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
it "should set fs_type to value from /proc/mounts" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
end
it "should set mount_options to an array of values from /proc/mounts" do
plugin.run
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
end
end
@@ -390,9 +390,9 @@ BLKID_TYPE
it "should provide a devices view with all mountpoints" do
plugin.run
- expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
- expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
- expect(plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
+ expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
+ expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
+ expect(plugin[:filesystem]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
end
end
@@ -436,7 +436,7 @@ BLKID_TYPE
it "should provide a mounts view with all devices" do
plugin.run
- expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
+ expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
end
end
end