ohai 8.26.1 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -4
  3. data/Rakefile +14 -0
  4. data/lib/ohai/application.rb +1 -0
  5. data/lib/ohai/config.rb +2 -88
  6. data/lib/ohai/dsl/plugin.rb +0 -4
  7. data/lib/ohai/exception.rb +0 -1
  8. data/lib/ohai/loader.rb +11 -2
  9. data/lib/ohai/log.rb +3 -1
  10. data/lib/ohai/mixin/command.rb +1 -318
  11. data/lib/ohai/mixin/do_metadata.rb +47 -0
  12. data/lib/ohai/mixin/ec2_metadata.rb +2 -29
  13. data/lib/ohai/mixin/gce_metadata.rb +0 -37
  14. data/lib/ohai/mixin/http_helper.rb +56 -0
  15. data/lib/ohai/mixin/network_constants.rb +0 -5
  16. data/lib/ohai/plugins/cloud.rb +144 -157
  17. data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
  18. data/lib/ohai/plugins/digital_ocean.rb +24 -42
  19. data/lib/ohai/plugins/dmi.rb +81 -77
  20. data/lib/ohai/plugins/ec2.rb +33 -60
  21. data/lib/ohai/plugins/gce.rb +3 -1
  22. data/lib/ohai/plugins/hostname.rb +1 -16
  23. data/lib/ohai/plugins/linux/filesystem.rb +130 -81
  24. data/lib/ohai/plugins/linux/mdadm.rb +3 -45
  25. data/lib/ohai/plugins/linux/network.rb +1 -26
  26. data/lib/ohai/plugins/linux/platform.rb +4 -2
  27. data/lib/ohai/plugins/linux/virtualization.rb +1 -5
  28. data/lib/ohai/plugins/scala.rb +1 -13
  29. data/lib/ohai/plugins/solaris2/network.rb +1 -2
  30. data/lib/ohai/plugins/uptime.rb +0 -9
  31. data/lib/ohai/plugins/windows/cpu.rb +2 -1
  32. data/lib/ohai/plugins/windows/network.rb +1 -1
  33. data/lib/ohai/runner.rb +0 -5
  34. data/lib/ohai/system.rb +38 -8
  35. data/lib/ohai/version.rb +2 -2
  36. data/ohai.gemspec +1 -1
  37. data/spec/functional/application_spec.rb +0 -40
  38. data/spec/functional/plugins/powershell_spec.rb +1 -1
  39. data/spec/functional/plugins/root_group_spec.rb +1 -1
  40. data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
  41. data/spec/ohai_spec.rb +1 -1
  42. data/spec/support/integration_helper.rb +17 -0
  43. data/spec/support/platform_helpers.rb +17 -0
  44. data/spec/unit/application_spec.rb +0 -1
  45. data/spec/unit/config_spec.rb +0 -111
  46. data/spec/unit/dsl/plugin_spec.rb +1 -1
  47. data/spec/unit/hints_spec.rb +1 -1
  48. data/spec/unit/loader_spec.rb +26 -1
  49. data/spec/unit/mixin/command_spec.rb +1 -69
  50. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  51. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  52. data/spec/unit/plugin_config_spec.rb +0 -1
  53. data/spec/unit/plugins/abort_spec.rb +1 -1
  54. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  55. data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
  56. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  57. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  58. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  59. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  60. data/spec/unit/plugins/aix/os_spec.rb +1 -1
  61. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  62. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  63. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  64. data/spec/unit/plugins/azure_spec.rb +1 -1
  65. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  66. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  67. data/spec/unit/plugins/c_spec.rb +1 -1
  68. data/spec/unit/plugins/chef_spec.rb +1 -2
  69. data/spec/unit/plugins/cloud_spec.rb +210 -50
  70. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
  71. data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
  72. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  73. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  74. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  75. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  76. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  77. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  78. data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
  79. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  80. data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
  81. data/spec/unit/plugins/dmi_spec.rb +1 -1
  82. data/spec/unit/plugins/ec2_spec.rb +10 -62
  83. data/spec/unit/plugins/elixir_spec.rb +1 -1
  84. data/spec/unit/plugins/erlang_spec.rb +1 -1
  85. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  86. data/spec/unit/plugins/fail_spec.rb +1 -1
  87. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  88. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  89. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  90. data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
  91. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  92. data/spec/unit/plugins/gce_spec.rb +1 -1
  93. data/spec/unit/plugins/go_spec.rb +1 -1
  94. data/spec/unit/plugins/groovy_spec.rb +1 -1
  95. data/spec/unit/plugins/haskell_spec.rb +1 -1
  96. data/spec/unit/plugins/hostname_spec.rb +16 -41
  97. data/spec/unit/plugins/init_package_spec.rb +1 -1
  98. data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
  99. data/spec/unit/plugins/java_spec.rb +1 -1
  100. data/spec/unit/plugins/joyent_spec.rb +17 -1
  101. data/spec/unit/plugins/kernel_spec.rb +1 -1
  102. data/spec/unit/plugins/linode_spec.rb +1 -1
  103. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  104. data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
  105. data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
  106. data/spec/unit/plugins/linux/fips_spec.rb +1 -1
  107. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  108. data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
  109. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
  113. data/spec/unit/plugins/linux/memory_spec.rb +1 -1
  114. data/spec/unit/plugins/linux/network_spec.rb +3 -44
  115. data/spec/unit/plugins/linux/platform_spec.rb +4 -4
  116. data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
  117. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  118. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
  119. data/spec/unit/plugins/lua_spec.rb +1 -1
  120. data/spec/unit/plugins/mono_spec.rb +1 -1
  121. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  122. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  123. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  124. data/spec/unit/plugins/network_spec.rb +1 -1
  125. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  126. data/spec/unit/plugins/ohai_spec.rb +1 -1
  127. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  128. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  129. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  130. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  131. data/spec/unit/plugins/openstack_spec.rb +2 -3
  132. data/spec/unit/plugins/os_spec.rb +1 -1
  133. data/spec/unit/plugins/packages_spec.rb +1 -1
  134. data/spec/unit/plugins/passwd_spec.rb +17 -1
  135. data/spec/unit/plugins/perl_spec.rb +1 -1
  136. data/spec/unit/plugins/php_spec.rb +1 -1
  137. data/spec/unit/plugins/platform_spec.rb +1 -1
  138. data/spec/unit/plugins/powershell_spec.rb +1 -1
  139. data/spec/unit/plugins/python_spec.rb +1 -1
  140. data/spec/unit/plugins/rackspace_spec.rb +1 -2
  141. data/spec/unit/plugins/root_group_spec.rb +2 -2
  142. data/spec/unit/plugins/ruby_spec.rb +1 -1
  143. data/spec/unit/plugins/rust_spec.rb +1 -1
  144. data/spec/unit/plugins/scala_spec.rb +3 -37
  145. data/spec/unit/plugins/shard_spec.rb +1 -1
  146. data/spec/unit/plugins/shells_spec.rb +1 -1
  147. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  148. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  149. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  150. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  151. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  152. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  153. data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
  154. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  155. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  156. data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
  157. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  158. data/spec/unit/plugins/sysconf_spec.rb +1 -1
  159. data/spec/unit/plugins/timezone_spec.rb +1 -1
  160. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  161. data/spec/unit/plugins/vmware_spec.rb +2 -1
  162. data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
  163. data/spec/unit/plugins/windows/fips_spec.rb +1 -1
  164. data/spec/unit/plugins/windows/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  166. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  167. data/spec/unit/provides_map_spec.rb +1 -1
  168. data/spec/unit/runner_spec.rb +1 -1
  169. data/spec/unit/system_spec.rb +68 -76
  170. data/spec/unit/util/file_helper_spec.rb +1 -1
  171. data/spec/unit/util/ip_helper_spec.rb +1 -1
  172. metadata +6 -20
  173. data/lib/ohai/plugins/cloud_v2.rb +0 -315
  174. data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
  175. data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
  176. data/lib/ohai/plugins/linux/lspci.rb +0 -76
  177. data/lib/ohai/plugins/network_listeners.rb +0 -60
  178. data/lib/ohai/plugins/sigar/cpu.rb +0 -44
  179. data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
  180. data/lib/ohai/plugins/sigar/memory.rb +0 -39
  181. data/lib/ohai/plugins/sigar/network.rb +0 -168
  182. data/lib/ohai/plugins/sigar/network_route.rb +0 -64
  183. data/lib/ohai/plugins/sigar/platform.rb +0 -30
  184. data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
  185. data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
  186. data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
  187. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  188. data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
17
+ require_relative "../../spec_helper.rb"
18
18
 
19
19
  describe Ohai::System, "plugin elixir" do
20
20
  let(:plugin) { get_plugin("elixir") }
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
20
+ require_relative "../../spec_helper.rb"
21
21
 
22
22
  describe Ohai::System, "plugin erlang" do
23
23
  let(:plugin) { get_plugin("erlang") }
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
20
+ require_relative "../../spec_helper.rb"
21
21
  require "open-uri"
22
22
 
23
23
  describe Ohai::System, "plugin eucalyptus" do
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
20
+ require_relative "../../spec_helper.rb"
21
21
 
22
22
  tmp = ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp"
23
23
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
22
22
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "FreeBSD hostname plugin" do
22
22
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "FreeBSD kernel plugin" do
22
22
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "FreeBSD plugin os" do
22
22
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "FreeBSD plugin platform" do
22
22
  before(:each) do
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
18
+ require_relative "../../spec_helper.rb"
19
19
  require "open-uri"
20
20
 
21
21
  describe Ohai::System, "plugin gce" do
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
16
+ require_relative "../../spec_helper.rb"
17
17
 
18
18
  describe Ohai::System, "plugin go" do
19
19
  let(:plugin) { get_plugin("go") }
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
19
+ require_relative "../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "plugin groovy" do
22
22
  let(:plugin) { get_plugin("groovy") }
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
17
+ require_relative "../../spec_helper.rb"
18
18
 
19
19
  describe Ohai::System, "plugin haskell" do
20
20
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
+ require_relative "../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "hostname plugin" do
22
22
  before(:each) do
@@ -25,50 +25,25 @@ describe Ohai::System, "hostname plugin" do
25
25
  allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
26
26
  end
27
27
 
28
- context "when sigar is not installed" do
29
- before(:each) do
30
- allow(@plugin).to receive(:sigar_is_available?).and_return(false)
31
- expect(@plugin).not_to receive(:get_fqdn_from_sigar)
32
- allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
33
- end
34
- it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
35
-
36
- it "should use #resolve_fqdn to find the fqdn" do
37
- @plugin.run
38
- expect(@plugin[:fqdn]).to eq("katie.bethell")
39
- end
40
-
41
- it "should set the domain to everything after the first dot of the fqdn" do
42
- @plugin.run
43
- expect(@plugin[:domain]).to eq("bethell")
44
- end
45
-
46
- it "should set the [short] hostname to everything before the first dot of the fqdn" do
47
- @plugin.run
48
- expect(@plugin[:hostname]).to eq("katie")
49
- end
28
+ context "default behavior"
29
+ before(:each) do
30
+ allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
50
31
  end
32
+ it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
51
33
 
52
- context "when sigar is installed" do
53
- before(:each) do
54
- allow(@plugin).to receive(:sigar_is_available?).and_return(true)
55
- allow(@plugin).to receive(:get_fqdn_from_sigar).and_return("katie.bethell")
56
- end
57
- it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
58
- it "should set the fqdn to the returned value from sigar" do
59
- @plugin.run
60
- expect(@plugin[:fqdn]).to eq("katie.bethell")
61
- end
34
+ it "should use #resolve_fqdn to find the fqdn" do
35
+ @plugin.run
36
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
37
+ end
62
38
 
63
- it "should set the domain to everything after the first dot of the fqdn" do
64
- @plugin.run
65
- expect(@plugin[:domain]).to eq("bethell")
66
- end
39
+ it "should set the domain to everything after the first dot of the fqdn" do
40
+ @plugin.run
41
+ expect(@plugin[:domain]).to eq("bethell")
42
+ end
67
43
 
68
- it "should set the [short] hostname to everything before the first dot of the fqdn" do
69
- @plugin.run
70
- expect(@plugin[:hostname]).to eq("katie")
71
- end
44
+ it "should set the [short] hostname to everything before the first dot of the fqdn" do
45
+ @plugin.run
46
+ expect(@plugin[:hostname]).to eq("katie")
72
47
  end
73
48
 
74
49
  context "when a system has a bare hostname without a FQDN" do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
19
+ require_relative "../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "Init package" do
22
22
  let(:plugin) do
@@ -1,9 +1,21 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
2
-
3
- begin
4
- require "ipaddr_extensions"
5
- rescue LoadError
6
- end
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require_relative "../../spec_helper.rb"
18
+ require "ipaddr_extensions"
7
19
 
8
20
  describe Ohai::System, "plugin ip_scopes" do
9
21
  let(:plugin) { get_plugin("ip_scopes") }
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
20
+ require_relative "../../spec_helper.rb"
21
21
 
22
22
  describe Ohai::System, "plugin java (Java5 Client VM)" do
23
23
  let(:plugin) { get_plugin("java") }
@@ -1,4 +1,20 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require_relative "../../spec_helper.rb"
2
18
 
3
19
  describe Ohai::System, "plugin joyent" do
4
20
  let(:plugin) { get_plugin("joyent") }
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
+ require_relative "../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "plugin kernel" do
22
22
  before(:each) do
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
18
+ require_relative "../../spec_helper.rb"
19
19
 
20
20
  describe Ohai::System, "plugin linode" do
21
21
  let(:plugin) { get_plugin("linode") }
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
18
+ require_relative "../../../spec_helper.rb"
19
19
 
20
20
  describe Ohai::System, "Linux Block Device Plugin" do
21
21
  DISKS = {
@@ -17,8 +17,7 @@
17
17
  #
18
18
 
19
19
  require "tempfile"
20
-
21
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
+ require_relative "../../../spec_helper.rb"
22
21
 
23
22
  shared_examples "Common cpu info" do |total_cpu, real_cpu|
24
23
  describe "cpu" do
@@ -16,10 +16,10 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "Linux filesystem plugin" do
22
- let(:plugin) { get_plugin("linux/filesystem") }
22
+ let (:plugin) { get_plugin("linux/filesystem") }
23
23
  before(:each) do
24
24
  allow(plugin).to receive(:collect_os).and_return(:linux)
25
25
 
@@ -27,15 +27,10 @@ describe Ohai::System, "Linux filesystem plugin" do
27
27
  allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
28
28
  allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
29
29
  allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
30
- allow(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
31
- allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
32
- allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
30
+ allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, "", ""))
33
31
 
34
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE").
35
- and_return(mock_shell_out(0, "", ""))
36
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID").
37
- and_return(mock_shell_out(0, "", ""))
38
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
32
+ allow(plugin).to receive(:shell_out).
33
+ with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
39
34
  and_return(mock_shell_out(0, "", ""))
40
35
 
41
36
  allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
@@ -57,6 +52,11 @@ describe Ohai::System, "Linux filesystem plugin" do
57
52
  end
58
53
  end
59
54
 
55
+ it "sets both filesystem and filesystem2 attributes" do
56
+ plugin.run
57
+ expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
58
+ end
59
+
60
60
  describe "when gathering filesystem usage data from df" do
61
61
  before(:each) do
62
62
  @stdout = <<-DF
@@ -93,42 +93,42 @@ DFi
93
93
 
94
94
  it "should set kb_size to value from df -P" do
95
95
  plugin.run
96
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057")
96
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
97
97
  end
98
98
 
99
99
  it "should set kb_used to value from df -P" do
100
100
  plugin.run
101
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253")
101
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
102
102
  end
103
103
 
104
104
  it "should set kb_available to value from df -P" do
105
105
  plugin.run
106
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805")
106
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
107
107
  end
108
108
 
109
109
  it "should set percent_used to value from df -P" do
110
110
  plugin.run
111
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%")
111
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
112
112
  end
113
113
 
114
114
  it "should set mount to value from df -P" do
115
115
  plugin.run
116
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
116
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
117
117
  end
118
118
 
119
119
  it "should set total_inodes to value from df -iP" do
120
120
  plugin.run
121
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865")
121
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
122
122
  end
123
123
 
124
124
  it "should set inodes_used to value from df -iP" do
125
125
  plugin.run
126
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380")
126
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
127
127
  end
128
128
 
129
129
  it "should set inodes_available to value from df -iP" do
130
130
  plugin.run
131
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485")
131
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
132
132
  end
133
133
  end
134
134
 
@@ -161,228 +161,142 @@ MOUNT
161
161
 
162
162
  it "should set mount to value from mount" do
163
163
  plugin.run
164
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
164
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
165
165
  end
166
166
 
167
167
  it "should set fs_type to value from mount" do
168
168
  plugin.run
169
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
169
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
170
170
  end
171
171
 
172
172
  it "should set mount_options to an array of values from mount" do
173
173
  plugin.run
174
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime})
174
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
175
175
  end
176
176
  end
177
177
 
178
178
  describe "when gathering filesystem type data from blkid" do
179
179
  before(:each) do
180
- @stdout = <<-BLKID_TYPE
181
- /dev/sdb1: TYPE=\"linux_raid_member\"
182
- /dev/sdb2: TYPE=\"linux_raid_member\"
183
- /dev/sda1: TYPE=\"linux_raid_member\"
184
- /dev/sda2: TYPE=\"linux_raid_member\"
185
- /dev/md0: TYPE=\"ext3\"
186
- /dev/md1: TYPE=\"LVM2_member\"
187
- /dev/mapper/sys.vg-root.lv: TYPE=\"ext4\"
188
- /dev/mapper/sys.vg-swap.lv: TYPE=\"swap\"
189
- /dev/mapper/sys.vg-tmp.lv: TYPE=\"ext4\"
190
- /dev/mapper/sys.vg-usr.lv: TYPE=\"ext4\"
191
- /dev/mapper/sys.vg-var.lv: TYPE=\"ext4\"
192
- /dev/mapper/sys.vg-home.lv: TYPE=\"xfs\"
193
- /dev/mapper/debian--7-root: TYPE=\"ext4\"
194
- BLKID_TYPE
195
- allow(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
196
- end
197
-
198
- it "should run blkid -s TYPE" do
199
- expect(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
200
- plugin.run
201
- end
180
+ # blkid and lsblk output are coorelated with df/mount output, so the
181
+ # most full test of them actually requires we have both
182
+ @dfstdout = <<-DF
183
+ Filesystem 1024-blocks Used Available Capacity Mounted on
184
+ /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
185
+ tmpfs 2030944 0 2030944 0% /lib/init/rw
186
+ udev 2025576 228 2025348 1% /dev
187
+ tmpfs 2030944 2960 2027984 1% /dev/shm
188
+ /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
189
+ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
190
+ /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
191
+ /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
192
+ /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
193
+ /dev/md0 960492 36388 875312 4% /boot
194
+ DF
195
+ allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
202
196
 
203
- it "should set fs_type to value from blkid -s TYPE" do
204
- plugin.run
205
- expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
206
- end
207
- end
197
+ @inode_stdout = <<-DFi
198
+ Filesystem Inodes IUsed IFree IUse% Mounted on
199
+ /dev/xvda1 1310720 107407 1203313 9% /
200
+ /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
201
+ tmpfs 126922 273 126649 1% /run
202
+ none 126922 1 126921 1% /run/lock
203
+ none 126922 1 126921 1% /run/shm
204
+ DFi
205
+ allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
208
206
 
209
- describe "when gathering filesystem type data from lsblk" do
210
- before(:each) do
211
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
212
207
  @stdout = <<-BLKID_TYPE
213
- NAME="sdb1" FSTYPE="linux_raid_member"
214
- NAME="sdb2" FSTYPE="linux_raid_member"
215
- NAME="sda1" FSTYPE="linux_raid_member"
216
- NAME="sda2" FSTYPE="linux_raid_member"
217
- NAME="md0" FSTYPE="ext3"
218
- NAME="md1" FSTYPE="LVM2_member"
219
- NAME="sys.vg-root.lv" FSTYPE="ext4"
220
- NAME="sys.vg-swap.lv" FSTYPE="swap"
221
- NAME="sys.vg-tmp.lv" FSTYPE="ext4"
222
- NAME="sys.vg-usr.lv" FSTYPE="ext4"
223
- NAME="sys.vg-var.lv" FSTYPE="ext4"
224
- NAME="sys.vg-home.lv" FSTYPE="xfs"
225
- NAME="debian--7-root (dm-0)" FSTYPE="ext4"
208
+ /dev/sdb1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
209
+ /dev/sdb2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
210
+ /dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
211
+ /dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
212
+ /dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
213
+ /dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
214
+ /dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
215
+ /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
216
+ /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
217
+ /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
218
+ /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
219
+ /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
226
220
  BLKID_TYPE
227
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE").
228
- and_return(mock_shell_out(0, @stdout, ""))
221
+ allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, ""))
229
222
  end
230
223
 
231
- it "should run lsblk -P -n -o NAME,FSTYPE" do
232
- expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE").
233
- and_return(mock_shell_out(0, @stdout, ""))
224
+ it "should run blkid" do
234
225
  plugin.run
235
226
  end
236
227
 
237
- it "should set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do
228
+ it "should set kb_size to value from blkid" do
238
229
  plugin.run
239
- expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
240
- end
241
-
242
- it "should ignore extra info in name and set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do
243
- plugin.run
244
- expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:fs_type]).to eq("ext4")
230
+ expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
231
+ expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
232
+ expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
245
233
  end
246
234
  end
247
235
 
248
- describe "when gathering filesystem uuid data from blkid" do
236
+ describe "when gathering filesystem type data from lsblk" do
249
237
  before(:each) do
250
- @stdout = <<-BLKID_UUID
251
- /dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\"
252
- /dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\"
253
- /dev/sda1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\"
254
- /dev/sda2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\"
255
- /dev/md0: UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\"
256
- /dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\"
257
- /dev/mapper/sys.vg-root.lv: UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\"
258
- /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\"
259
- /dev/mapper/sys.vg-tmp.lv: UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\"
260
- /dev/mapper/sys.vg-usr.lv: UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\"
261
- /dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\"
262
- /dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\"
263
- /dev/mapper/debian--7-root: UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\"
264
- BLKID_UUID
265
- allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
266
- end
267
-
268
- it "should run blkid -s UUID" do
269
- expect(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
270
- plugin.run
271
- end
238
+ @dfstdout = <<-DF
239
+ Filesystem 1024-blocks Used Available Capacity Mounted on
240
+ /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
241
+ tmpfs 2030944 0 2030944 0% /lib/init/rw
242
+ udev 2025576 228 2025348 1% /dev
243
+ tmpfs 2030944 2960 2027984 1% /dev/shm
244
+ /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
245
+ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
246
+ /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
247
+ /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
248
+ /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
249
+ /dev/md0 960492 36388 875312 4% /boot
250
+ DF
251
+ allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
272
252
 
273
- it "should set uuid to value from blkid -s UUID" do
274
- plugin.run
275
- expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
276
- end
277
- end
253
+ @inode_stdout = <<-DFi
254
+ Filesystem Inodes IUsed IFree IUse% Mounted on
255
+ /dev/xvda1 1310720 107407 1203313 9% /
256
+ /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
257
+ tmpfs 126922 273 126649 1% /run
258
+ none 126922 1 126921 1% /run/lock
259
+ none 126922 1 126921 1% /run/shm
260
+ DFi
261
+ allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
278
262
 
279
- describe "when gathering filesystem uuid data from lsblk" do
280
- before(:each) do
281
263
  allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
282
- @stdout = <<-BLKID_UUID
283
- NAME="sdb1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5"
284
- NAME="sdb2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
285
- NAME="sda1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5"
286
- NAME="sda2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
287
- NAME="md0" UUID="37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32"
288
- NAME="md1" UUID="YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK"
289
- NAME="sys.vg-root.lv" UUID="7742d14b-80a3-4e97-9a32-478be9ea9aea"
290
- NAME="sys.vg-swap.lv" UUID="9bc2e515-8ddc-41c3-9f63-4eaebde9ce96"
291
- NAME="sys.vg-tmp.lv" UUID="74cf7eb9-428f-479e-9a4a-9943401e81e5"
292
- NAME="sys.vg-usr.lv" UUID="26ec33c5-d00b-4f88-a550-492def013bbc"
293
- NAME="sys.vg-var.lv" UUID="6b559c35-7847-4ae2-b512-c99012d3f5b3"
294
- NAME="sys.vg-home.lv" UUID="d6efda02-1b73-453c-8c74-7d8dee78fa5e"
295
- NAME="debian--7-root (dm-0)" UUID="09187faa-3512-4505-81af-7e86d2ccb99a"
296
- BLKID_UUID
297
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID").
298
- and_return(mock_shell_out(0, @stdout, ""))
299
- end
300
-
301
- it "should run lsblk -P -n -o NAME,UUID" do
302
- expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID").
264
+ @stdout = <<-BLKID_TYPE
265
+ NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
266
+ NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
267
+ NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
268
+ NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
269
+ NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
270
+ NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
271
+ NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
272
+ NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
273
+ NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
274
+ NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" FSTYPE=\"ext4\"
275
+ NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
276
+ NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
277
+ NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
278
+ BLKID_TYPE
279
+ allow(plugin).to receive(:shell_out).
280
+ with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
303
281
  and_return(mock_shell_out(0, @stdout, ""))
304
- plugin.run
305
- end
306
-
307
- it "should set uuid to value from lsblk -P -n -o NAME,UUID" do
308
- plugin.run
309
- expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq(
310
- "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
311
- )
312
- end
313
-
314
- it "should ignore extra info in name and set uuid to value from lsblk -P -n -o NAME,UUID" do
315
- plugin.run
316
- expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:uuid]).to eq(
317
- "09187faa-3512-4505-81af-7e86d2ccb99a"
318
- )
319
282
  end
320
- end
321
283
 
322
- describe "when gathering filesystem label data from blkid" do
323
- before(:each) do
324
- @stdout = <<-BLKID_LABEL
325
- /dev/sda1: LABEL=\"fuego:0\"
326
- /dev/sda2: LABEL=\"fuego:1\"
327
- /dev/sdb1: LABEL=\"fuego:0\"
328
- /dev/sdb2: LABEL=\"fuego:1\"
329
- /dev/md0: LABEL=\"/boot\"
330
- /dev/mapper/sys.vg-root.lv: LABEL=\"/\"
331
- /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\"
332
- /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\"
333
- /dev/mapper/sys.vg-var.lv: LABEL=\"/var\"
334
- /dev/mapper/sys.vg-home.lv: LABEL=\"/home\"
335
- /dev/mapper/debian--7-root: LABEL=\"root\"
336
- BLKID_LABEL
337
- allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
338
- end
339
-
340
- it "should run blkid -s LABEL" do
341
- expect(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
284
+ it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
342
285
  plugin.run
343
286
  end
344
287
 
345
- it "should set label to value from blkid -s LABEL" do
346
- plugin.run
347
- expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
348
- end
349
- end
350
-
351
- describe "when gathering filesystem label data from lsblk" do
352
- before(:each) do
353
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
354
- @stdout = <<-BLKID_LABEL
355
- NAME="sda1" LABEL="fuego:0"
356
- NAME="sda2" LABEL="fuego:1"
357
- NAME="sdb1" LABEL="fuego:0"
358
- NAME="sdb2" LABEL="fuego:1"
359
- NAME="md0" LABEL="/boot"
360
- NAME="sys.vg-root.lv" LABEL="/"
361
- NAME="sys.vg-tmp.lv" LABEL="/tmp"
362
- NAME="sys.vg-usr.lv" LABEL="/usr"
363
- NAME="sys.vg-var.lv" LABEL="/var"
364
- NAME="sys.vg-home.lv" LABEL="/home"
365
- NAME="debian--7-root (dm-0)" LABEL="root"
366
- BLKID_LABEL
367
- allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
368
- and_return(mock_shell_out(0, @stdout, ""))
369
- end
370
-
371
- it "should run lsblk -P -n -o NAME,LABEL" do
372
- expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
373
- and_return(mock_shell_out(0, @stdout, ""))
288
+ it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
374
289
  plugin.run
290
+ expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
291
+ expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
292
+ expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
375
293
  end
376
294
 
377
- it "should set label to value from lsblk -P -n -o NAME,LABEL" do
295
+ it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
378
296
  plugin.run
379
- expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
297
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
380
298
  end
381
299
 
382
- it "should ignore extra info in name and set label to value from lsblk -P -n -o NAME,LABEL" do
383
- plugin.run
384
- expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:label]).to eq("root")
385
- end
386
300
  end
387
301
 
388
302
  describe "when gathering data from /proc/mounts" do
@@ -419,18 +333,110 @@ MOUNTS
419
333
 
420
334
  it "should set mount to value from /proc/mounts" do
421
335
  plugin.run
422
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
336
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
423
337
  end
424
338
 
425
339
  it "should set fs_type to value from /proc/mounts" do
426
340
  plugin.run
427
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
341
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
428
342
  end
429
343
 
430
344
  it "should set mount_options to an array of values from /proc/mounts" do
431
345
  plugin.run
432
- expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
346
+ expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
433
347
  end
434
348
  end
435
349
 
350
+ describe "when gathering filesystem data with devices mounted more than once" do
351
+ before(:each) do
352
+ # there's a few different examples one can run into in this output:
353
+ # 1. A device physically mounted in more than one place: /home and /home2
354
+ # 2. A bind-mounted directory, which shows up as the same device in a
355
+ # subdir: / and /var/chroot
356
+ # 3. tmpfs in multiple places.
357
+ @dfstdout = <<-DF
358
+ Filesystem 1024-blocks Used Available Capacity Mounted on
359
+ /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
360
+ tmpfs 2030944 0 2030944 0% /lib/init/rw
361
+ udev 2025576 228 2025348 1% /dev
362
+ tmpfs 2030944 2960 2027984 1% /dev/shm
363
+ /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
364
+ /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2
365
+ /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot
366
+ DF
367
+ allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
368
+
369
+ @inode_stdout = <<-DFi
370
+ Filesystem Inodes IUsed IFree IUse% Mounted on
371
+ /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
372
+ tmpfs 126922 273 126649 1% /lib/init/rw
373
+ none 126922 1 126921 1% /dev/shm
374
+ udev 126922 1 126921 1% /dev
375
+ /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
376
+ /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2
377
+ /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot
378
+ DFi
379
+ allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
380
+
381
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
382
+ @stdout = <<-BLKID_TYPE
383
+ NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
384
+ NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
385
+ BLKID_TYPE
386
+ allow(plugin).to receive(:shell_out).
387
+ with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
388
+ and_return(mock_shell_out(0, @stdout, ""))
389
+ end
390
+
391
+ it "should provide a devices view with all mountpoints" do
392
+ plugin.run
393
+ expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
394
+ expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
395
+ expect(plugin[:filesystem]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
396
+ end
397
+ end
398
+
399
+ describe "when gathering filesystem data with double-mounts" do
400
+ before(:each) do
401
+ @dfstdout = <<-DF
402
+ Filesystem 1024-blocks Used Available Capacity Mounted on
403
+ /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
404
+ tmpfs 2030944 0 2030944 0% /lib/init/rw
405
+ udev 2025576 228 2025348 1% /dev
406
+ tmpfs 2030944 2960 2027984 1% /dev/shm
407
+ /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
408
+ /dev/sdb1 97605056 53563252 44041804 55% /mnt
409
+ /dev/sdc1 4805760 378716 4182924 9% /mnt
410
+ DF
411
+ allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
412
+
413
+ @inode_stdout = <<-DFi
414
+ Filesystem Inodes IUsed IFree IUse% Mounted on
415
+ /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
416
+ tmpfs 126922 273 126649 1% /lib/init/rw
417
+ none 126922 1 126921 1% /dev/shm
418
+ udev 126922 1 126921 1% /dev
419
+ /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
420
+ /dev/sdb1 60891136 4696030 56195106 8% /mnt
421
+ /dev/sdc1 1310720 107407 1203313 9% /mnt
422
+ DFi
423
+ allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
424
+
425
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
426
+ @stdout = <<-BLKID_TYPE
427
+ NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
428
+ NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
429
+ NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
430
+ NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
431
+ BLKID_TYPE
432
+ allow(plugin).to receive(:shell_out).
433
+ with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
434
+ and_return(mock_shell_out(0, @stdout, ""))
435
+ end
436
+
437
+ it "should provide a mounts view with all devices" do
438
+ plugin.run
439
+ expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
440
+ end
441
+ end
436
442
  end