ohai 8.8.1 → 8.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +1 -1
  4. data/Rakefile +6 -0
  5. data/bin/ohai +2 -2
  6. data/lib/ohai.rb +4 -4
  7. data/lib/ohai/config.rb +2 -2
  8. data/lib/ohai/dsl.rb +2 -2
  9. data/lib/ohai/dsl/plugin.rb +3 -3
  10. data/lib/ohai/dsl/plugin/versionvi.rb +3 -3
  11. data/lib/ohai/dsl/plugin/versionvii.rb +2 -2
  12. data/lib/ohai/exception.rb +2 -2
  13. data/lib/ohai/hints.rb +2 -2
  14. data/lib/ohai/loader.rb +1 -1
  15. data/lib/ohai/log.rb +2 -2
  16. data/lib/ohai/mixin/command.rb +2 -2
  17. data/lib/ohai/mixin/constant_helper.rb +2 -2
  18. data/lib/ohai/mixin/dmi_decode.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +3 -3
  20. data/lib/ohai/mixin/network_constants.rb +4 -4
  21. data/lib/ohai/mixin/os.rb +2 -2
  22. data/lib/ohai/mixin/seconds_to_human.rb +4 -4
  23. data/lib/ohai/mixin/string.rb +4 -4
  24. data/lib/ohai/plugin_config.rb +1 -1
  25. data/lib/ohai/plugins/aix/cpu.rb +35 -29
  26. data/lib/ohai/plugins/aix/filesystem.rb +58 -40
  27. data/lib/ohai/plugins/aix/kernel.rb +3 -2
  28. data/lib/ohai/plugins/aix/memory.rb +4 -3
  29. data/lib/ohai/plugins/aix/network.rb +6 -4
  30. data/lib/ohai/plugins/aix/os.rb +30 -0
  31. data/lib/ohai/plugins/aix/platform.rb +3 -2
  32. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  33. data/lib/ohai/plugins/aix/virtualization.rb +115 -5
  34. data/lib/ohai/plugins/azure.rb +1 -1
  35. data/lib/ohai/plugins/bsd/filesystem.rb +1 -1
  36. data/lib/ohai/plugins/command.rb +4 -4
  37. data/lib/ohai/plugins/darwin/cpu.rb +5 -3
  38. data/lib/ohai/plugins/darwin/filesystem.rb +4 -4
  39. data/lib/ohai/plugins/darwin/filesystem2.rb +4 -4
  40. data/lib/ohai/plugins/darwin/memory.rb +6 -5
  41. data/lib/ohai/plugins/darwin/network.rb +2 -2
  42. data/lib/ohai/plugins/darwin/platform.rb +2 -2
  43. data/lib/ohai/plugins/darwin/system_profiler.rb +2 -2
  44. data/lib/ohai/plugins/dragonflybsd/os.rb +2 -2
  45. data/lib/ohai/plugins/ec2.rb +3 -3
  46. data/lib/ohai/plugins/erlang.rb +3 -3
  47. data/lib/ohai/plugins/eucalyptus.rb +3 -3
  48. data/lib/ohai/plugins/freebsd/cpu.rb +8 -4
  49. data/lib/ohai/plugins/freebsd/os.rb +2 -2
  50. data/lib/ohai/plugins/hostname.rb +12 -4
  51. data/lib/ohai/plugins/init_package.rb +2 -8
  52. data/lib/ohai/plugins/java.rb +2 -2
  53. data/lib/ohai/plugins/kernel.rb +5 -4
  54. data/lib/ohai/plugins/keys.rb +3 -3
  55. data/lib/ohai/plugins/languages.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +3 -3
  57. data/lib/ohai/plugins/linux/cpu.rb +2 -2
  58. data/lib/ohai/plugins/linux/filesystem.rb +2 -2
  59. data/lib/ohai/plugins/linux/filesystem2.rb +3 -3
  60. data/lib/ohai/plugins/linux/lsb.rb +2 -2
  61. data/lib/ohai/plugins/linux/memory.rb +2 -2
  62. data/lib/ohai/plugins/linux/network.rb +141 -59
  63. data/lib/ohai/plugins/linux/platform.rb +6 -1
  64. data/lib/ohai/plugins/linux/virtualization.rb +1 -1
  65. data/lib/ohai/plugins/network.rb +49 -42
  66. data/lib/ohai/plugins/ohai_time.rb +4 -4
  67. data/lib/ohai/plugins/openstack.rb +2 -2
  68. data/lib/ohai/plugins/os.rb +2 -2
  69. data/lib/ohai/plugins/packages.rb +122 -0
  70. data/lib/ohai/plugins/perl.rb +5 -5
  71. data/lib/ohai/plugins/platform.rb +2 -2
  72. data/lib/ohai/plugins/powershell.rb +2 -2
  73. data/lib/ohai/plugins/ps.rb +2 -2
  74. data/lib/ohai/plugins/python.rb +1 -1
  75. data/lib/ohai/plugins/rackspace.rb +13 -0
  76. data/lib/ohai/plugins/ruby.rb +6 -6
  77. data/lib/ohai/plugins/sigar/network_route.rb +1 -1
  78. data/lib/ohai/plugins/solaris2/filesystem.rb +1 -1
  79. data/lib/ohai/plugins/solaris2/network.rb +1 -1
  80. data/lib/ohai/plugins/solaris2/platform.rb +1 -1
  81. data/lib/ohai/plugins/solaris2/virtualization.rb +5 -5
  82. data/lib/ohai/plugins/solaris2/zpools.rb +2 -2
  83. data/lib/ohai/plugins/ssh_host_key.rb +2 -2
  84. data/lib/ohai/plugins/uptime.rb +4 -4
  85. data/lib/ohai/plugins/virtualbox.rb +1 -1
  86. data/lib/ohai/plugins/virtualization.rb +7 -7
  87. data/lib/ohai/plugins/vmware.rb +1 -1
  88. data/lib/ohai/plugins/windows/filesystem.rb +1 -1
  89. data/lib/ohai/plugins/windows/network.rb +1 -1
  90. data/lib/ohai/plugins/windows/platform.rb +1 -1
  91. data/lib/ohai/plugins/windows/virtualization.rb +1 -1
  92. data/lib/ohai/provides_map.rb +3 -3
  93. data/lib/ohai/runner.rb +2 -2
  94. data/lib/ohai/system.rb +2 -2
  95. data/lib/ohai/util/file_helper.rb +1 -1
  96. data/lib/ohai/util/win32.rb +1 -1
  97. data/lib/ohai/util/win32/group_helper.rb +1 -1
  98. data/lib/ohai/version.rb +3 -3
  99. data/spec/data/plugins/dpkg-query.output +1087 -0
  100. data/spec/data/plugins/lslpp.output +49 -0
  101. data/spec/data/plugins/pkginfo.output +50 -0
  102. data/spec/data/plugins/pkglist.output +24 -0
  103. data/spec/data/plugins/rpmquery.output +388 -0
  104. data/spec/functional/application_spec.rb +1 -1
  105. data/spec/functional/loader_spec.rb +1 -1
  106. data/spec/functional/plugins/powershell_spec.rb +1 -1
  107. data/spec/functional/plugins/root_group_spec.rb +2 -2
  108. data/spec/ohai_spec.rb +6 -6
  109. data/spec/unit/application_spec.rb +1 -1
  110. data/spec/unit/config_spec.rb +1 -1
  111. data/spec/unit/dsl/plugin_spec.rb +2 -2
  112. data/spec/unit/hints_spec.rb +2 -2
  113. data/spec/unit/loader_spec.rb +2 -2
  114. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  115. data/spec/unit/plugin_config_spec.rb +1 -1
  116. data/spec/unit/plugins/aix/cpu_spec.rb +68 -40
  117. data/spec/unit/plugins/aix/filesystem_spec.rb +152 -50
  118. data/spec/unit/plugins/aix/hostname_spec.rb +5 -3
  119. data/spec/unit/plugins/aix/kernel_spec.rb +2 -1
  120. data/spec/unit/plugins/aix/memory_spec.rb +7 -5
  121. data/spec/unit/plugins/aix/network_spec.rb +17 -1
  122. data/spec/unit/plugins/aix/os_spec.rb +35 -0
  123. data/spec/unit/plugins/aix/platform_spec.rb +5 -4
  124. data/spec/unit/plugins/aix/uptime_spec.rb +2 -1
  125. data/spec/unit/plugins/aix/virtualization_spec.rb +269 -3
  126. data/spec/unit/plugins/azure_spec.rb +1 -1
  127. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  128. data/spec/unit/plugins/bsd/virtualization_spec.rb +2 -2
  129. data/spec/unit/plugins/chef_spec.rb +8 -8
  130. data/spec/unit/plugins/darwin/cpu_spec.rb +8 -3
  131. data/spec/unit/plugins/darwin/hostname_spec.rb +2 -2
  132. data/spec/unit/plugins/darwin/kernel_spec.rb +4 -4
  133. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  134. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  135. data/spec/unit/plugins/darwin/platform_spec.rb +6 -6
  136. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -1
  137. data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
  138. data/spec/unit/plugins/ec2_spec.rb +3 -3
  139. data/spec/unit/plugins/erlang_spec.rb +3 -3
  140. data/spec/unit/plugins/eucalyptus_spec.rb +2 -2
  141. data/spec/unit/plugins/fail_spec.rb +6 -6
  142. data/spec/unit/plugins/freebsd/cpu_spec.rb +19 -4
  143. data/spec/unit/plugins/freebsd/hostname_spec.rb +2 -2
  144. data/spec/unit/plugins/freebsd/kernel_spec.rb +4 -4
  145. data/spec/unit/plugins/freebsd/platform_spec.rb +7 -7
  146. data/spec/unit/plugins/hostname_spec.rb +2 -2
  147. data/spec/unit/plugins/init_package_spec.rb +12 -2
  148. data/spec/unit/plugins/java_spec.rb +5 -5
  149. data/spec/unit/plugins/kernel_spec.rb +4 -2
  150. data/spec/unit/plugins/linux/block_device_spec.rb +75 -0
  151. data/spec/unit/plugins/linux/cpu_spec.rb +2 -2
  152. data/spec/unit/plugins/linux/filesystem2_spec.rb +14 -14
  153. data/spec/unit/plugins/linux/filesystem_spec.rb +1 -1
  154. data/spec/unit/plugins/linux/hostname_spec.rb +2 -2
  155. data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
  156. data/spec/unit/plugins/linux/lsb_spec.rb +17 -17
  157. data/spec/unit/plugins/linux/network_spec.rb +80 -11
  158. data/spec/unit/plugins/linux/platform_spec.rb +20 -1
  159. data/spec/unit/plugins/linux/uptime_spec.rb +8 -8
  160. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -1
  161. data/spec/unit/plugins/lua_spec.rb +2 -2
  162. data/spec/unit/plugins/netbsd/hostname_spec.rb +2 -2
  163. data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
  164. data/spec/unit/plugins/netbsd/platform_spec.rb +2 -2
  165. data/spec/unit/plugins/network_spec.rb +110 -37
  166. data/spec/unit/plugins/nodejs_spec.rb +2 -2
  167. data/spec/unit/plugins/ohai_spec.rb +5 -5
  168. data/spec/unit/plugins/ohai_time_spec.rb +8 -8
  169. data/spec/unit/plugins/openbsd/hostname_spec.rb +2 -2
  170. data/spec/unit/plugins/openbsd/kernel_spec.rb +4 -4
  171. data/spec/unit/plugins/openbsd/platform_spec.rb +6 -6
  172. data/spec/unit/plugins/openstack_spec.rb +2 -2
  173. data/spec/unit/plugins/os_spec.rb +11 -11
  174. data/spec/unit/plugins/packages_spec.rb +241 -0
  175. data/spec/unit/plugins/perl_spec.rb +3 -3
  176. data/spec/unit/plugins/php_spec.rb +2 -2
  177. data/spec/unit/plugins/platform_spec.rb +2 -2
  178. data/spec/unit/plugins/python_spec.rb +3 -3
  179. data/spec/unit/plugins/rackspace_spec.rb +7 -0
  180. data/spec/unit/plugins/ruby_spec.rb +3 -3
  181. data/spec/unit/plugins/sigar/network_route_spec.rb +1 -1
  182. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  183. data/spec/unit/plugins/solaris2/filesystem.rb +1 -1
  184. data/spec/unit/plugins/solaris2/network_spec.rb +3 -3
  185. data/spec/unit/plugins/solaris2/platform_spec.rb +5 -5
  186. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  187. data/spec/unit/plugins/ssh_host_keys_spec.rb +2 -2
  188. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  189. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  190. data/spec/unit/provides_map_spec.rb +2 -2
  191. data/spec/unit/runner_spec.rb +2 -2
  192. data/spec/unit/system_spec.rb +3 -3
  193. data/spec/unit/util/file_helper_spec.rb +1 -1
  194. metadata +13 -3
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Claire McQuin <claire@chef.io>
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc.
3
3
  #
4
4
  # License:: Apache License, Version 2.0
5
5
  #
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Edwards (<adamed@getchef.com>)
2
+ # Author:: Adam Edwards (<adamed@chef.io>)
3
3
  #
4
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc.
5
5
  #
6
6
  # License:: Apache License, Version 2.0
7
7
  #
data/spec/ohai_spec.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,9 +19,9 @@
19
19
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
20
20
 
21
21
  describe Ohai do
22
-
22
+
23
23
  it "should have a version constant defined" do
24
24
  expect(Ohai::VERSION).to be_a_kind_of(String)
25
25
  end
26
-
26
+
27
27
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Claire McQuin <claire@chef.io>
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Claire McQuin (<claire@chef.io>)
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Claire McQuin (<claire@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: Claire McQuin (<claire@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Serdar Sutay (<serdar@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: Serdar Sutay (<serdar@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Claire McQuin (<claire@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: Claire McQuin (<claire@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Bryan McLellan <btm@loftninjas.org>
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Author:: Isa Farnik (<isa@chef.io>)
4
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
5
  # License:: Apache License, Version 2.0
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,62 +39,89 @@ CPU 1 runs at 1654 MHz
38
39
  CPU 2 runs at 1654 MHz
39
40
  CPU 3 runs at 1654 MHz
40
41
  PMCYCLES_M
41
-
42
+
42
43
  @plugin = get_plugin("aix/cpu")
43
44
  allow(@plugin).to receive(:collect_os).and_return(:aix)
44
45
 
45
46
  allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
46
47
  allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
47
48
  allow(@plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil))
48
- @plugin.run
49
49
  end
50
50
 
51
+ context "when run on an LPAR" do
52
+ before do
53
+ allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
54
+ @plugin.run
55
+ end
51
56
 
52
- it "sets the vendor id to IBM" do
53
- expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
54
- end
57
+ it "sets the vendor id to IBM" do
58
+ expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
59
+ end
55
60
 
56
- it "sets the available attribute" do
57
- expect(@plugin[:cpu][:available]).to eq(1)
58
- end
61
+ it "sets the available attribute" do
62
+ expect(@plugin[:cpu][:available]).to eq(1)
63
+ end
59
64
 
60
- it "sets the total number of processors" do
61
- expect(@plugin[:cpu][:total]).to eq(4)
62
- end
63
-
64
- it "sets the real number of processors" do
65
- expect(@plugin[:cpu][:real]).to eq(2)
66
- end
67
-
68
- it "sets the number of cores" do
69
- #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
70
- #on AIX number of cores and processors are considered same
71
- expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real])
72
- end
65
+ it "sets the total number of processors" do
66
+ expect(@plugin[:cpu][:total]).to eq(4)
67
+ end
73
68
 
74
- it "detects the model" do
75
- expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
76
- end
69
+ it "sets the real number of processors" do
70
+ expect(@plugin[:cpu][:real]).to eq(2)
71
+ end
77
72
 
78
- it "detects the mhz" do
79
- expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
80
- end
73
+ it "sets the number of cores" do
74
+ #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
75
+ #on AIX number of cores and processors are considered same
76
+ expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real])
77
+ end
81
78
 
82
- it "detects the status of the device" do
83
- expect(@plugin[:cpu]["0"][:status]).to eq("Available")
84
- end
79
+ it "detects the model" do
80
+ expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
81
+ end
85
82
 
86
- it "detects the location of the device" do
87
- expect(@plugin[:cpu]["0"][:location]).to eq("00-00")
83
+ it "detects the mhz" do
84
+ expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
85
+ end
86
+
87
+ it "detects the status of the device" do
88
+ expect(@plugin[:cpu]["0"][:status]).to eq("Available")
89
+ end
90
+
91
+ it "detects the location of the device" do
92
+ expect(@plugin[:cpu]["0"][:location]).to eq("00-00")
93
+ end
94
+
95
+ context "lsattr -El device_name" do
96
+ it "detects all the attributes of the device" do
97
+ expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
98
+ expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true")
99
+ expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2")
100
+ expect(@plugin[:cpu]["0"][:state]).to eq("enable")
101
+ expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
102
+ end
103
+ end
88
104
  end
89
105
 
90
- context "lsattr -El device_name" do
91
- it "detects all the attributes of the device" do
92
- expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
93
- expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true")
94
- expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2")
95
- expect(@plugin[:cpu]["0"][:state]).to eq("enable")
96
- expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
106
+ context "when run on a WPAR" do
107
+ before do
108
+ allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "120", nil))
109
+ @plugin.run
110
+ end
111
+
112
+ it "sets the total number of processors" do
113
+ expect(@plugin[:cpu][:total]).to eq(4)
114
+ end
115
+
116
+ it "doesn't set the real number of CPUs" do
117
+ expect(@plugin[:cpu][:real]).to be_nil
118
+ end
119
+
120
+ it "doesn't set mhz of a processor it can't see" do
121
+ # I'm so sorry
122
+ expect {
123
+ expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
124
+ }.to raise_error(NoMethodError)
97
125
  end
98
126
  end
99
127
  end
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Author:: Isa Farnik (<isa@chef.io>)
4
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
5
  # License:: Apache License, Version 2.0
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,20 +19,45 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
18
19
 
19
20
  describe Ohai::System, "AIX filesystem plugin" do
20
21
  before(:each) do
21
- @df_P = <<-DF_P
22
- Filesystem 512-blocks Used Available Capacity Mounted on
23
- /dev/hd4 786432 495632 290800 64% /
24
- /dev/hd2 10485760 8743200 1742560 84% /usr
25
- /dev/hd9var 2621440 1152952 1468488 44% /var
26
- /dev/hd3 2621440 541928 2079512 21% /tmp
27
- /dev/hd1 8650752 6098080 2552672 71% /home
28
- /dev/hd11admin 262144 760 261384 1% /admin
29
- /proc - - - - /proc
30
- /dev/hd10opt 3407872 1744384 1663488 52% /opt
31
- 192.168.1.11:/stage/middleware 314572800 177025952 137546848 57% /stage/middleware
32
- DF_P
33
-
34
- @mount = <<-MOUNT
22
+ @df_Pk_LPAR = <<-DF_PK
23
+ Filesystem 1024-blocks Used Available Capacity Mounted on
24
+ /dev/hd4 2097152 219796 1877356 11% /
25
+ /dev/hd2 5242880 2416828 2826052 47% /usr
26
+ /dev/hd9var 5242880 395540 4847340 8% /var
27
+ /dev/hd3 5242880 1539508 3703372 30% /tmp
28
+ /dev/hd1 10485760 1972 10483788 1% /home
29
+ /dev/hd11admin 131072 380 130692 1% /admin
30
+ /proc - - - - /proc
31
+ /dev/hd10opt 5242880 1286720 3956160 25% /opt
32
+ /dev/livedump 262144 368 261776 1% /var/adm/ras/livedump
33
+ /dev/fslv00 524288 45076 479212 9% /wpars/sink-thinker-541ba3
34
+ /dev/fslv01 2097152 8956 2088196 1% /wpars/sink-thinker-541ba3/home
35
+ /dev/fslv02 5242880 1307352 3935528 25% /wpars/sink-thinker-541ba3/opt
36
+ /proc - - - - /wpars/sink-thinker-541ba3/proc
37
+ /dev/fslv03 1048576 168840 879736 17% /wpars/sink-thinker-541ba3/tmp
38
+ /dev/fslv04 5242880 2725040 2517840 52% /wpars/sink-thinker-541ba3/usr
39
+ /dev/fslv05 524288 76000 448288 15% /wpars/sink-thinker-541ba3/var
40
+ /dev/fslv07 10485760 130872 10354888 2% /wpars/toolchain-tester-5c969f
41
+ /dev/fslv08 5242880 39572 5203308 1% /wpars/toolchain-tester-5c969f/home
42
+ /dev/fslv09 5242880 1477164 3765716 29% /wpars/toolchain-tester-5c969f/opt
43
+ /proc - - - - /wpars/toolchain-tester-5c969f/proc
44
+ /dev/fslv10 5242880 42884 5199996 1% /wpars/toolchain-tester-5c969f/tmp
45
+ /dev/fslv11 5242880 2725048 2517832 52% /wpars/toolchain-tester-5c969f/usr
46
+ /dev/fslv12 10485760 272376 10213384 3% /wpars/toolchain-tester-5c969f/var
47
+ DF_PK
48
+
49
+ @df_Pk_WPAR = <<-DF_PK
50
+ Filesystem 1024-blocks Used Available Capacity Mounted on
51
+ Global 10485760 130872 10354888 2% /
52
+ Global 5242880 39572 5203308 1% /home
53
+ Global 5242880 1477164 3765716 29% /opt
54
+ Global - - - - /proc
55
+ Global 5242880 42884 5199996 1% /tmp
56
+ Global 5242880 2725048 2517832 52% /usr
57
+ Global 10485760 272376 10213384 3% /var
58
+ DF_PK
59
+
60
+ @mount_LPAR = <<-MOUNT
35
61
  node mounted mounted over vfs date options
36
62
  -------- --------------- --------------- ------ ------------ ---------------
37
63
  /dev/hd4 / jfs2 Jul 17 13:22 rw,log=/dev/hd8
@@ -43,70 +69,146 @@ DF_P
43
69
  /proc /proc procfs Jul 17 13:22 rw
44
70
  /dev/hd10opt /opt jfs2 Jul 17 13:22 rw,log=/dev/hd8
45
71
  192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
72
+ MOUNT
73
+
74
+ @mount_WPAR = <<-MOUNT
75
+ node mounted mounted over vfs date options
76
+ -------- --------------- --------------- ------ ------------ ---------------
77
+ Global / jfs2 Nov 23 21:03 rw,log=NULL
78
+ Global /home jfs2 Nov 23 21:03 rw,log=NULL
79
+ Global /opt jfs2 Nov 23 21:03 rw,log=NULL
80
+ Global /proc namefs Nov 23 21:03 rw
81
+ Global /tmp jfs2 Nov 23 21:03 rw,log=NULL
82
+ Global /usr jfs2 Nov 23 21:03 rw,log=NULL
83
+ Global /var jfs2 Nov 23 21:03 rw,log=NULL
84
+ 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
46
85
  MOUNT
47
86
 
48
87
  @plugin = get_plugin("aix/filesystem")
49
88
  allow(@plugin).to receive(:collect_os).and_return(:aix)
50
89
  @plugin[:filesystem] = Mash.new
51
- allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil))
52
- allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil))
53
-
54
- @plugin.run
55
90
  end
56
91
 
57
- describe "df -P" do
58
-
59
- it "returns the filesystem block size" do
60
- expect(@plugin[:filesystem]["/dev/hd4"]['kb_size']).to eq("786432")
92
+ context 'when run within an LPAR' do
93
+ before do
94
+ allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_LPAR, nil))
95
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_LPAR, nil))
96
+ @plugin.run
61
97
  end
62
98
 
63
- it "returns the filesystem used space in kb" do
64
- expect(@plugin[:filesystem]["/dev/hd4"]['kb_used']).to eq("495632")
65
- end
99
+ describe "df -Pk" do
66
100
 
67
- it "returns the filesystem available space in kb" do
68
- expect(@plugin[:filesystem]["/dev/hd4"]['kb_available']).to eq("290800")
69
- end
101
+ it "returns the filesystem block size" do
102
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_size']).to eq("2097152")
103
+ end
70
104
 
71
- it "returns the filesystem capacity in percentage" do
72
- expect(@plugin[:filesystem]["/dev/hd4"]['percent_used']).to eq("64%")
73
- end
105
+ it "returns the filesystem used space in kb" do
106
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_used']).to eq("219796")
107
+ end
74
108
 
75
- it "returns the filesystem mounted location" do
76
- expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
77
- end
78
- end
109
+ it "returns the filesystem available space in kb" do
110
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_available']).to eq("1877356")
111
+ end
79
112
 
80
- describe "mount" do
113
+ it "returns the filesystem capacity in percentage" do
114
+ expect(@plugin[:filesystem]["/dev/hd4"]['percent_used']).to eq("11%")
115
+ end
81
116
 
82
- it "returns the filesystem mount location" do
83
- expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
117
+ it "returns the filesystem mounted location" do
118
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
119
+ end
84
120
  end
85
121
 
86
- it "returns the filesystem type" do
87
- expect(@plugin[:filesystem]["/dev/hd4"]['fs_type']).to eq("jfs2")
122
+ describe "mount" do
123
+
124
+ it "returns the filesystem mount location" do
125
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
126
+ end
127
+
128
+ it "returns the filesystem type" do
129
+ expect(@plugin[:filesystem]["/dev/hd4"]['fs_type']).to eq("jfs2")
130
+ end
131
+
132
+ it "returns the filesystem mount options" do
133
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount_options']).to eq(["rw", "log=/dev/hd8"])
134
+ end
135
+
136
+ # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
137
+ context "having node values" do
138
+
139
+ it "returns the filesystem mount location" do
140
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware")
141
+ end
142
+
143
+ it "returns the filesystem type" do
144
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3")
145
+ end
146
+
147
+ it "returns the filesystem mount options" do
148
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
149
+ end
150
+ end
88
151
  end
152
+ end
89
153
 
90
- it "returns the filesystem mount options" do
91
- expect(@plugin[:filesystem]["/dev/hd4"]['mount_options']).to eq("rw,log=/dev/hd8")
154
+ context 'when run within a WPAR' do
155
+ before do
156
+ allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_WPAR, nil))
157
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_WPAR, nil))
158
+ @plugin.run
92
159
  end
93
160
 
94
- # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
95
- context "having node values" do
96
- before do
97
- allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys", nil))
161
+ describe "df -Pk" do
162
+
163
+ it "returns the filesystem block size" do
164
+ expect(@plugin[:filesystem]["Global:/"]['kb_size']).to eq("10485760")
165
+ end
166
+
167
+ it "returns the filesystem used space in kb" do
168
+ expect(@plugin[:filesystem]["Global:/"]['kb_used']).to eq("130872")
169
+ end
170
+
171
+ it "returns the filesystem available space in kb" do
172
+ expect(@plugin[:filesystem]["Global:/"]['kb_available']).to eq("10354888")
173
+ end
174
+
175
+ it "returns the filesystem capacity in percentage" do
176
+ expect(@plugin[:filesystem]["Global:/"]['percent_used']).to eq("2%")
98
177
  end
99
178
 
179
+ it "returns the filesystem mounted location" do
180
+ expect(@plugin[:filesystem]["Global:/"]['mount']).to eq("/")
181
+ end
182
+ end
183
+
184
+ describe "mount" do
185
+
100
186
  it "returns the filesystem mount location" do
101
- expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware")
187
+ expect(@plugin[:filesystem]["Global:/"]['mount']).to eq("/")
102
188
  end
103
189
 
104
190
  it "returns the filesystem type" do
105
- expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3")
191
+ expect(@plugin[:filesystem]["Global:/"]['fs_type']).to eq("jfs2")
106
192
  end
107
193
 
108
194
  it "returns the filesystem mount options" do
109
- expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq("ro,bg,hard,intr,sec=sys")
195
+ expect(@plugin[:filesystem]["Global:/"]['mount_options']).to eq(["rw", "log=NULL"])
196
+ end
197
+
198
+ # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
199
+ context "having node values" do
200
+
201
+ it "returns the filesystem mount location" do
202
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware")
203
+ end
204
+
205
+ it "returns the filesystem type" do
206
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3")
207
+ end
208
+
209
+ it "returns the filesystem mount options" do
210
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
211
+ end
110
212
  end
111
213
  end
112
214
  end