ohai 6.24.2 → 7.0.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/lib/ohai.rb +1 -1
  2. data/lib/ohai/application.rb +5 -12
  3. data/lib/ohai/common/dmi.rb +126 -0
  4. data/lib/ohai/config.rb +9 -9
  5. data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
  6. data/lib/ohai/dsl/plugin.rb +186 -0
  7. data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
  8. data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
  9. data/lib/ohai/exception.rb +11 -2
  10. data/lib/ohai/hints.rb +48 -0
  11. data/lib/ohai/loader.rb +205 -0
  12. data/lib/ohai/mixin/command.rb +14 -18
  13. data/lib/ohai/mixin/constant_helper.rb +53 -0
  14. data/lib/ohai/mixin/gce_metadata.rb +0 -2
  15. data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
  16. data/lib/ohai/mixin/os.rb +59 -0
  17. data/lib/ohai/mixin/seconds_to_human.rb +48 -0
  18. data/lib/ohai/plugins/aix/cpu.rb +26 -22
  19. data/lib/ohai/plugins/aix/filesystem.rb +47 -48
  20. data/lib/ohai/plugins/aix/kernel.rb +11 -7
  21. data/lib/ohai/plugins/aix/memory.rb +8 -4
  22. data/lib/ohai/plugins/aix/network.rb +73 -82
  23. data/lib/ohai/plugins/aix/platform.rb +9 -6
  24. data/lib/ohai/plugins/aix/uptime.rb +14 -12
  25. data/lib/ohai/plugins/azure.rb +33 -11
  26. data/lib/ohai/plugins/c.rb +103 -78
  27. data/lib/ohai/plugins/chef.rb +20 -8
  28. data/lib/ohai/plugins/cloud.rb +234 -230
  29. data/lib/ohai/plugins/command.rb +6 -2
  30. data/lib/ohai/plugins/darwin/cpu.rb +10 -4
  31. data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
  32. data/lib/ohai/plugins/darwin/network.rb +157 -154
  33. data/lib/ohai/plugins/darwin/platform.rb +18 -16
  34. data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
  35. data/lib/ohai/plugins/dmi.rb +102 -102
  36. data/lib/ohai/plugins/ec2.rb +30 -28
  37. data/lib/ohai/plugins/erlang.rb +19 -16
  38. data/lib/ohai/plugins/eucalyptus.rb +37 -36
  39. data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
  40. data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
  41. data/lib/ohai/plugins/freebsd/memory.rb +35 -25
  42. data/lib/ohai/plugins/freebsd/network.rb +94 -89
  43. data/lib/ohai/plugins/freebsd/platform.rb +10 -4
  44. data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
  45. data/lib/ohai/plugins/gce.rb +30 -36
  46. data/lib/ohai/plugins/groovy.rb +14 -11
  47. data/lib/ohai/plugins/hostname.rb +132 -10
  48. data/lib/ohai/plugins/ip_scopes.rb +31 -16
  49. data/lib/ohai/plugins/java.rb +45 -21
  50. data/lib/ohai/plugins/kernel.rb +186 -19
  51. data/lib/ohai/plugins/keys.rb +6 -2
  52. data/lib/ohai/plugins/languages.rb +6 -2
  53. data/lib/ohai/plugins/linode.rb +38 -30
  54. data/lib/ohai/plugins/linux/block_device.rb +19 -15
  55. data/lib/ohai/plugins/linux/cpu.rb +42 -38
  56. data/lib/ohai/plugins/linux/filesystem.rb +70 -130
  57. data/lib/ohai/plugins/linux/lsb.rb +35 -35
  58. data/lib/ohai/plugins/linux/memory.rb +65 -61
  59. data/lib/ohai/plugins/linux/network.rb +343 -362
  60. data/lib/ohai/plugins/linux/platform.rb +90 -88
  61. data/lib/ohai/plugins/linux/virtualization.rb +95 -90
  62. data/lib/ohai/plugins/lua.rb +14 -10
  63. data/lib/ohai/plugins/mono.rb +17 -13
  64. data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
  65. data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
  66. data/lib/ohai/plugins/netbsd/memory.rb +59 -59
  67. data/lib/ohai/plugins/netbsd/network.rb +92 -88
  68. data/lib/ohai/plugins/netbsd/platform.rb +10 -3
  69. data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
  70. data/lib/ohai/plugins/network.rb +131 -130
  71. data/lib/ohai/plugins/network_listeners.rb +26 -22
  72. data/lib/ohai/plugins/nodejs.rb +14 -10
  73. data/lib/ohai/plugins/ohai.rb +11 -6
  74. data/lib/ohai/plugins/ohai_time.rb +6 -2
  75. data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
  76. data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
  77. data/lib/ohai/plugins/openbsd/memory.rb +59 -59
  78. data/lib/ohai/plugins/openbsd/network.rb +92 -88
  79. data/lib/ohai/plugins/openbsd/platform.rb +10 -4
  80. data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
  81. data/lib/ohai/plugins/openstack.rb +23 -21
  82. data/lib/ohai/plugins/os.rb +8 -32
  83. data/lib/ohai/plugins/passwd.rb +27 -22
  84. data/lib/ohai/plugins/perl.rb +21 -16
  85. data/lib/ohai/plugins/php.rb +15 -12
  86. data/lib/ohai/plugins/platform.rb +9 -9
  87. data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
  88. data/lib/ohai/plugins/python.rb +16 -12
  89. data/lib/ohai/plugins/rackspace.rb +82 -77
  90. data/lib/ohai/plugins/root_group.rb +13 -9
  91. data/lib/ohai/plugins/ruby.rb +50 -48
  92. data/lib/ohai/plugins/sigar/cpu.rb +21 -17
  93. data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
  94. data/lib/ohai/plugins/sigar/memory.rb +17 -14
  95. data/lib/ohai/plugins/sigar/network.rb +133 -67
  96. data/lib/ohai/plugins/sigar/network_route.rb +33 -28
  97. data/lib/ohai/plugins/sigar/platform.rb +10 -6
  98. data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
  99. data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
  100. data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
  101. data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
  102. data/lib/ohai/plugins/solaris2/network.rb +91 -86
  103. data/lib/ohai/plugins/solaris2/platform.rb +40 -36
  104. data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
  105. data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
  106. data/lib/ohai/plugins/ssh_host_key.rb +49 -45
  107. data/lib/ohai/plugins/uptime.rb +87 -25
  108. data/lib/ohai/plugins/virtualization.rb +59 -55
  109. data/lib/ohai/plugins/windows/cpu.rb +44 -40
  110. data/lib/ohai/plugins/windows/filesystem.rb +28 -22
  111. data/lib/ohai/plugins/windows/network.rb +88 -79
  112. data/lib/ohai/plugins/windows/platform.rb +10 -3
  113. data/lib/ohai/provides_map.rb +184 -0
  114. data/lib/ohai/runner.rb +109 -0
  115. data/lib/ohai/system.rb +103 -184
  116. data/lib/ohai/version.rb +4 -3
  117. data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
  118. data/spec/data/plugins/___lib___libc.so.6.output +135 -0
  119. data/spec/data/plugins/cc.output +135 -0
  120. data/spec/data/plugins/cl.output +135 -0
  121. data/spec/data/plugins/devenv.com.output +135 -0
  122. data/spec/data/plugins/env.output +71 -0
  123. data/spec/data/plugins/erl.output +144 -0
  124. data/spec/data/plugins/gcc.output +135 -0
  125. data/spec/data/plugins/groovy.output +159 -0
  126. data/spec/data/plugins/java.output +143 -0
  127. data/spec/data/plugins/lua.output +143 -0
  128. data/spec/data/plugins/messages.rb +8 -0
  129. data/spec/data/plugins/node.output +143 -0
  130. data/spec/data/plugins/perl.output +143 -0
  131. data/spec/data/plugins/php.output +143 -0
  132. data/spec/data/plugins/python.output +143 -0
  133. data/spec/data/plugins/uname.output +71 -0
  134. data/spec/data/plugins/v6message.rb +2 -0
  135. data/spec/data/plugins/v7message.rb +7 -0
  136. data/spec/data/plugins/what.output +135 -0
  137. data/spec/data/plugins/xlc.output +135 -0
  138. data/spec/spec_helper.rb +52 -18
  139. data/spec/support/integration_helper.rb +44 -0
  140. data/spec/unit/dsl/plugin_spec.rb +298 -0
  141. data/spec/unit/hints_spec.rb +65 -0
  142. data/spec/unit/loader_spec.rb +226 -0
  143. data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
  144. data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
  145. data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
  146. data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
  147. data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
  148. data/spec/unit/plugins/aix/network_spec.rb +66 -45
  149. data/spec/unit/plugins/aix/platform_spec.rb +11 -10
  150. data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
  151. data/spec/unit/plugins/azure_spec.rb +20 -21
  152. data/spec/unit/plugins/c_spec.rb +88 -87
  153. data/spec/unit/plugins/chef_spec.rb +5 -6
  154. data/spec/unit/plugins/cloud_spec.rb +81 -82
  155. data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
  156. data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
  157. data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
  158. data/spec/unit/plugins/darwin/network_spec.rb +375 -378
  159. data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
  160. data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
  161. data/spec/unit/plugins/dmi_spec.rb +7 -12
  162. data/spec/unit/plugins/ec2_spec.rb +70 -59
  163. data/spec/unit/plugins/erlang_spec.rb +18 -20
  164. data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
  165. data/spec/unit/plugins/fail_spec.rb +276 -23
  166. data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
  167. data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
  168. data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
  169. data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
  170. data/spec/unit/plugins/gce_spec.rb +19 -25
  171. data/spec/unit/plugins/groovy_spec.rb +10 -16
  172. data/spec/unit/plugins/hostname_spec.rb +45 -20
  173. data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
  174. data/spec/unit/plugins/java_spec.rb +145 -99
  175. data/spec/unit/plugins/kernel_spec.rb +51 -15
  176. data/spec/unit/plugins/linode_spec.rb +31 -29
  177. data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
  178. data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
  179. data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
  180. data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
  181. data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
  182. data/spec/unit/plugins/linux/network_spec.rb +196 -238
  183. data/spec/unit/plugins/linux/platform_spec.rb +186 -205
  184. data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
  185. data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
  186. data/spec/unit/plugins/lua_spec.rb +12 -15
  187. data/spec/unit/plugins/mono_spec.rb +10 -15
  188. data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
  189. data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
  190. data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
  191. data/spec/unit/plugins/network_spec.rb +358 -235
  192. data/spec/unit/plugins/nodejs_spec.rb +13 -15
  193. data/spec/unit/plugins/ohai_spec.rb +3 -4
  194. data/spec/unit/plugins/ohai_time_spec.rb +8 -9
  195. data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
  196. data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
  197. data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
  198. data/spec/unit/plugins/openstack_spec.rb +214 -0
  199. data/spec/unit/plugins/os_spec.rb +13 -16
  200. data/spec/unit/plugins/passwd_spec.rb +12 -13
  201. data/spec/unit/plugins/perl_spec.rb +20 -44
  202. data/spec/unit/plugins/php_spec.rb +20 -15
  203. data/spec/unit/plugins/platform_spec.rb +24 -29
  204. data/spec/unit/plugins/python_spec.rb +13 -17
  205. data/spec/unit/plugins/rackspace_spec.rb +90 -57
  206. data/spec/unit/plugins/root_group_spec.rb +17 -19
  207. data/spec/unit/plugins/ruby_spec.rb +15 -16
  208. data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
  209. data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
  210. data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
  211. data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
  212. data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
  213. data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
  214. data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
  215. data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
  216. data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
  217. data/spec/unit/provides_map_spec.rb +208 -0
  218. data/spec/unit/runner_spec.rb +488 -0
  219. data/spec/unit/system_spec.rb +639 -104
  220. metadata +151 -87
  221. checksums.yaml +0 -7
  222. data/lib/ohai/mixin/from_file.rb +0 -36
  223. data/lib/ohai/plugins/aix/ps.rb +0 -23
  224. data/lib/ohai/plugins/darwin/kernel.rb +0 -37
  225. data/lib/ohai/plugins/darwin/ps.rb +0 -23
  226. data/lib/ohai/plugins/darwin/uptime.rb +0 -32
  227. data/lib/ohai/plugins/dmi_common.rb +0 -121
  228. data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
  229. data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
  230. data/lib/ohai/plugins/freebsd/ps.rb +0 -24
  231. data/lib/ohai/plugins/hpux/cpu.rb +0 -19
  232. data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
  233. data/lib/ohai/plugins/hpux/hostname.rb +0 -19
  234. data/lib/ohai/plugins/hpux/memory.rb +0 -19
  235. data/lib/ohai/plugins/hpux/network.rb +0 -19
  236. data/lib/ohai/plugins/hpux/platform.rb +0 -19
  237. data/lib/ohai/plugins/hpux/ps.rb +0 -23
  238. data/lib/ohai/plugins/hpux/uptime.rb +0 -19
  239. data/lib/ohai/plugins/linux/hostname.rb +0 -40
  240. data/lib/ohai/plugins/linux/ps.rb +0 -23
  241. data/lib/ohai/plugins/linux/uptime.rb +0 -28
  242. data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
  243. data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
  244. data/lib/ohai/plugins/netbsd/ps.rb +0 -24
  245. data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
  246. data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
  247. data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
  248. data/lib/ohai/plugins/openbsd/ps.rb +0 -24
  249. data/lib/ohai/plugins/sigar/hostname.rb +0 -28
  250. data/lib/ohai/plugins/sigar/uptime.rb +0 -27
  251. data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
  252. data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
  253. data/lib/ohai/plugins/solaris2/ps.rb +0 -23
  254. data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
  255. data/lib/ohai/plugins/windows/hostname.rb +0 -33
  256. data/lib/ohai/plugins/windows/kernel.rb +0 -58
  257. data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
  258. data/lib/ohai/plugins/windows/uptime.rb +0 -23
  259. data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -22,15 +22,15 @@ require 'ohai/mixin/ec2_metadata'
22
22
  describe Ohai::Mixin::Ec2Metadata do
23
23
  let(:mixin) {
24
24
  metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata)
25
- http_client = mock("Net::HTTP client")
26
- http_client.stub!(:get).and_return(response)
27
- metadata_object.stub!(:http_client).and_return(http_client)
25
+ http_client = double("Net::HTTP client")
26
+ http_client.stub(:get).and_return(response)
27
+ metadata_object.stub(:http_client).and_return(http_client)
28
28
  metadata_object
29
29
  }
30
30
 
31
31
  context "#best_api_version" do
32
32
  context "with a sorted list of metadata versions" do
33
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
33
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
34
34
 
35
35
  it "returns the most recent version" do
36
36
  mixin.best_api_version.should == "2012-01-12"
@@ -38,7 +38,7 @@ describe Ohai::Mixin::Ec2Metadata do
38
38
  end
39
39
 
40
40
  context "with an unsorted list of metadata versions" do
41
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", :code => "200") }
41
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", :code => "200") }
42
42
 
43
43
  it "returns the most recent version (using string sort)" do
44
44
  mixin.best_api_version.should == "2011-05-01"
@@ -46,7 +46,7 @@ describe Ohai::Mixin::Ec2Metadata do
46
46
  end
47
47
 
48
48
  context "when no supported versions are found" do
49
- let(:response) { mock("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
49
+ let(:response) { double("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
50
50
 
51
51
  it "raises an error" do
52
52
  lambda { mixin.best_api_version}.should raise_error
@@ -54,7 +54,7 @@ describe Ohai::Mixin::Ec2Metadata do
54
54
  end
55
55
 
56
56
  context "when the response code is 404" do
57
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "404") }
57
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "404") }
58
58
 
59
59
  it "raises an error" do
60
60
  lambda { mixin.best_api_version}.should raise_error
@@ -62,7 +62,7 @@ describe Ohai::Mixin::Ec2Metadata do
62
62
  end
63
63
 
64
64
  context "when the response code is unexpected" do
65
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
65
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
66
66
 
67
67
  it "raises an error" do
68
68
  lambda { mixin.best_api_version}.should raise_error
@@ -72,7 +72,7 @@ describe Ohai::Mixin::Ec2Metadata do
72
72
 
73
73
  context "#metadata_get" do
74
74
  context "when the response code is unexpected" do
75
- let(:response) { mock("Net::HTTP Response", :body => "", :code => "418") }
75
+ let(:response) { double("Net::HTTP Response", :body => "", :code => "418") }
76
76
 
77
77
  it "raises an error" do
78
78
  lambda { mixin.metadata_get('', '2012-01-12') }.should raise_error(RuntimeError)
@@ -31,51 +31,50 @@ smt_threads 2 Processor SMT threads False
31
31
  state enable Processor state False
32
32
  type PowerPC_POWER5 Processor type False
33
33
  LSATTR_EL
34
- @ohai = Ohai::System.new
35
- @ohai.stub!(:require_plugin).and_return(true)
36
- @ohai[:os] = "aix"
34
+ @plugin = get_plugin("aix/cpu")
35
+ @plugin.stub(:collect_os).and_return(:aix)
37
36
 
38
- @ohai.stub(:from).with("lsdev -Cc processor").and_return(@lsdev_Cc_processor)
39
- @ohai.stub(:from).with("lsattr -El proc0").and_return(@lsattr_El_proc0)
40
- @ohai._require_plugin("aix::cpu")
37
+ @plugin.stub(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
38
+ @plugin.stub(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
39
+ @plugin.run
41
40
  end
42
41
 
43
42
 
44
43
  it "sets the vendor id to IBM" do
45
- @ohai[:cpu][:vendor_id].should == "IBM"
44
+ @plugin[:cpu][:vendor_id].should == "IBM"
46
45
  end
47
46
 
48
47
  it "sets the available attribute" do
49
- @ohai[:cpu][:available].should == 1
48
+ @plugin[:cpu][:available].should == 1
50
49
  end
51
50
 
52
51
  it "sets the total number of devices" do
53
- @ohai[:cpu][:total].should == 2
52
+ @plugin[:cpu][:total].should == 2
54
53
  end
55
54
 
56
55
  it "detects the model" do
57
- @ohai[:cpu][:model].should == "PowerPC_POWER5"
56
+ @plugin[:cpu][:model].should == "PowerPC_POWER5"
58
57
  end
59
58
 
60
59
  it "detects the mhz" do
61
- @ohai[:cpu][:mhz].should == 1615570
60
+ @plugin[:cpu][:mhz].should == 1615570
62
61
  end
63
62
 
64
63
  it "detects the status of the device" do
65
- @ohai[:cpu][:proc0][:status].should == "Available"
64
+ @plugin[:cpu][:proc0][:status].should == "Available"
66
65
  end
67
66
 
68
67
  it "detects the location of the device" do
69
- @ohai[:cpu][:proc0][:location].should == "00-00"
68
+ @plugin[:cpu][:proc0][:location].should == "00-00"
70
69
  end
71
70
 
72
71
  context "lsattr -El device_name" do
73
72
  it "detects all the attributes of the device" do
74
- @ohai[:cpu][:proc0][:frequency].should == "1654344000"
75
- @ohai[:cpu][:proc0][:smt_enabled].should == "true"
76
- @ohai[:cpu][:proc0][:smt_threads].should == "2"
77
- @ohai[:cpu][:proc0][:state].should == "enable"
78
- @ohai[:cpu][:proc0][:type].should == "PowerPC_POWER5"
73
+ @plugin[:cpu][:proc0][:frequency].should == "1654344000"
74
+ @plugin[:cpu][:proc0][:smt_enabled].should == "true"
75
+ @plugin[:cpu][:proc0][:smt_threads].should == "2"
76
+ @plugin[:cpu][:proc0][:state].should == "enable"
77
+ @plugin[:cpu][:proc0][:type].should == "PowerPC_POWER5"
79
78
  end
80
79
  end
81
80
  end
@@ -45,66 +45,68 @@ DF_P
45
45
  192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
46
46
  MOUNT
47
47
 
48
- @ohai = Ohai::System.new
49
- @ohai.stub(:require_plugin).and_return(true)
50
- @ohai[:filesystem] = Mash.new
51
- @ohai.stub(:popen4).with("df -P").and_yield(nil, StringIO.new, StringIO.new(@df_P), nil)
52
- @ohai.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new(@mount), nil)
53
- @ohai._require_plugin("aix::filesystem")
48
+ @plugin = get_plugin("aix/filesystem")
49
+ @plugin.stub(:collect_os).and_return(:aix)
50
+ @plugin[:filesystem] = Mash.new
51
+ @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil))
52
+ @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil))
53
+
54
+ @plugin.run
54
55
  end
55
56
 
56
57
  describe "df -P" do
57
58
 
58
59
  it "returns the filesystem block size" do
59
- @ohai[:filesystem]["/dev/hd4"]['kb_size'].should == "786432"
60
+ @plugin[:filesystem]["/dev/hd4"]['kb_size'].should == "786432"
60
61
  end
61
62
 
62
63
  it "returns the filesystem used space in kb" do
63
- @ohai[:filesystem]["/dev/hd4"]['kb_used'].should == "495632"
64
+ @plugin[:filesystem]["/dev/hd4"]['kb_used'].should == "495632"
64
65
  end
65
66
 
66
67
  it "returns the filesystem available space in kb" do
67
- @ohai[:filesystem]["/dev/hd4"]['kb_available'].should == "290800"
68
+ @plugin[:filesystem]["/dev/hd4"]['kb_available'].should == "290800"
68
69
  end
69
70
 
70
71
  it "returns the filesystem capacity in percentage" do
71
- @ohai[:filesystem]["/dev/hd4"]['percent_used'].should == "64%"
72
+ @plugin[:filesystem]["/dev/hd4"]['percent_used'].should == "64%"
72
73
  end
73
74
 
74
75
  it "returns the filesystem mounted location" do
75
- @ohai[:filesystem]["/dev/hd4"]['mount'].should == "/"
76
+ @plugin[:filesystem]["/dev/hd4"]['mount'].should == "/"
76
77
  end
77
78
  end
78
79
 
79
80
  describe "mount" do
80
81
 
81
82
  it "returns the filesystem mount location" do
82
- @ohai[:filesystem]["/dev/hd4"]['mount'].should == "/"
83
+ @plugin[:filesystem]["/dev/hd4"]['mount'].should == "/"
83
84
  end
84
85
 
85
86
  it "returns the filesystem type" do
86
- @ohai[:filesystem]["/dev/hd4"]['fs_type'].should == "jfs2"
87
+ @plugin[:filesystem]["/dev/hd4"]['fs_type'].should == "jfs2"
87
88
  end
88
89
 
89
90
  it "returns the filesystem mount options" do
90
- @ohai[:filesystem]["/dev/hd4"]['mount_options'].should == "rw,log=/dev/hd8"
91
+ @plugin[:filesystem]["/dev/hd4"]['mount_options'].should == "rw,log=/dev/hd8"
91
92
  end
92
93
 
93
94
  # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
94
95
  context "having node values" do
95
96
  before do
96
- @ohai.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new("192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys"), nil)
97
+ @plugin.stub(: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))
97
98
  end
99
+
98
100
  it "returns the filesystem mount location" do
99
- @ohai[:filesystem]["192.168.1.11:/stage/middleware"]['mount'].should == "/stage/middleware"
101
+ @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount'].should == "/stage/middleware"
100
102
  end
101
103
 
102
104
  it "returns the filesystem type" do
103
- @ohai[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type'].should == "nfs3"
105
+ @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type'].should == "nfs3"
104
106
  end
105
107
 
106
108
  it "returns the filesystem mount options" do
107
- @ohai[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options'].should == "ro,bg,hard,intr,sec=sys"
109
+ @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options'].should == "ro,bg,hard,intr,sec=sys"
108
110
  end
109
111
  end
110
112
  end
@@ -19,10 +19,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
19
 
20
20
  describe Ohai::System, "Aix hostname plugin" do
21
21
  before(:each) do
22
- @ohai = Ohai::System.new
23
- @ohai.stub(:from).with("hostname").and_return("aix_admin")
24
- @ohai._require_plugin("aix::hostname")
22
+ @plugin = get_plugin("hostname")
23
+ @plugin.stub(:collect_os).and_return(:aix)
24
+ @plugin.stub(:from_cmd).with("hostname").and_return("aix_admin")
25
+ @plugin.run
25
26
  end
26
27
 
27
- it_should_check_from("aix::hostname", "hostname", "hostname", "aix_admin")
28
+ it "should set the machinename" do
29
+ @plugin[:machinename].should eql("aix_admin")
30
+ end
28
31
  end
32
+
@@ -19,33 +19,34 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
19
 
20
20
  describe Ohai::System, "AIX kernel plugin" do
21
21
  before(:each) do
22
- @ohai = Ohai::System.new
23
- @ohai.stub(:from).with("uname -s").and_return("AIX")
24
- @ohai.stub(:from).with("uname -r").and_return(1)
25
- @ohai.stub(:from).with("uname -v").and_return(6)
26
- @ohai.stub(:from).with("uname -p").and_return("powerpc")
22
+ @plugin = get_plugin("aix/kernel")
23
+ @plugin.stub(:collect_os).and_return(:aix)
24
+ @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
25
+ @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
26
+ @plugin.stub(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
27
+ @plugin.stub(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
27
28
  @modules = Mash.new
28
- @ohai[:kernel].stub(:modules).and_return(@modules)
29
- @ohai._require_plugin("aix::kernel")
29
+ @plugin.stub(:modules).and_return(@modules)
30
+ @plugin.run
30
31
  end
31
32
 
32
33
  it "uname -s detects the name" do
33
- @ohai[:kernel][:name].should == "aix"
34
+ @plugin[:kernel][:name].should == "aix"
34
35
  end
35
36
 
36
37
  it "uname -r detects the release" do
37
- @ohai[:kernel][:release].should == 1
38
+ @plugin[:kernel][:release].should == "1"
38
39
  end
39
40
 
40
41
  it "uname -v detects the version" do
41
- @ohai[:kernel][:version].should == 6
42
+ @plugin[:kernel][:version].should == "6"
42
43
  end
43
44
 
44
45
  it "uname -p detects the machine" do
45
- @ohai[:kernel][:machine].should == "powerpc"
46
+ @plugin[:kernel][:machine].should == "powerpc"
46
47
  end
47
48
 
48
49
  it "detects the modules" do
49
- @ohai[:kernel][:modules].should == @modules
50
+ @plugin[:kernel][:modules].should == @modules
50
51
  end
51
52
  end
@@ -71,68 +71,78 @@ bucket: 0 contains: 0 entries
71
71
  There are 6 entries in the arp table.
72
72
  ARP_AN
73
73
 
74
- @ohai = Ohai::System.new
75
- @ohai.stub(:require_plugin).and_return(true)
76
- @ohai[:network] = Mash.new
77
- @ohai.stub(:popen4).with("route -n get 0").and_yield(nil, StringIO.new, StringIO.new(@route_n_get_0), nil)
78
- @ohai.stub(:popen4).with("lsdev -Cc if").and_yield(nil, StringIO.new, StringIO.new(@lsdev_Cc_if), nil)
79
- @ohai.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new(@ifconfig_en0), nil)
80
- @ohai.stub(:popen4).with("entstat -d en0 | grep \"Hardware Address\"").and_yield(nil, StringIO.new, StringIO.new("Hardware Address: be:42:80:00:b0:05"), nil)
81
- @ohai.stub(:popen4).with("netstat -nrf inet").and_yield(nil, StringIO.new, StringIO.new(@netstat_nrf_inet), nil)
82
- @ohai.stub(:popen4).with("netstat -nrf inet6").and_yield(nil, StringIO.new, StringIO.new("::1%1 ::1%1 UH 1 109392 en0 - -"), nil)
83
- @ohai.stub(:popen4).with("arp -an").and_yield(nil, StringIO.new, StringIO.new(@aix_arp_an), nil)
84
- @ohai._require_plugin("aix::network")
74
+ @plugin = get_plugin("aix/network")
75
+ @plugin.stub(:collect_os).and_return(:aix)
76
+ @plugin[:network] = Mash.new
77
+ @plugin.stub(:shell_out).with("route -n get 0").and_return(mock_shell_out(0, @route_n_get_0, nil))
78
+ @plugin.stub(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
79
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil))
80
+ @plugin.stub(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
81
+ @plugin.stub(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
82
+ @plugin.stub(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
83
+ @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
85
84
  end
86
85
 
87
86
  describe "run" do
87
+ before do
88
+ @plugin.run
89
+ end
88
90
 
89
91
  it "detects network information" do
90
- @ohai['network'].should_not be_nil
92
+ @plugin['network'].should_not be_nil
91
93
  end
92
94
 
93
95
  it "detects the interfaces" do
94
- @ohai['network']['interfaces'].keys.sort.should == ["en0"]
96
+ @plugin['network']['interfaces'].keys.sort.should == ["en0"]
95
97
  end
96
98
 
97
99
  it "detects the ip addresses of the interfaces" do
98
- @ohai['network']['interfaces']['en0']['addresses'].keys.should include('172.29.174.58')
100
+ @plugin['network']['interfaces']['en0']['addresses'].keys.should include('172.29.174.58')
99
101
  end
100
102
  end
101
103
 
102
104
  describe "route -n get 0" do
105
+ before do
106
+ @plugin.run
107
+ end
103
108
 
104
109
  it "returns the default gateway of the system's network" do
105
- @ohai[:network][:default_gateway].should == '172.29.128.13'
110
+ @plugin[:network][:default_gateway].should == '172.29.128.13'
106
111
  end
107
112
 
108
113
  it "returns the default interface of the system's network" do
109
- @ohai[:network][:default_interface].should == 'en0'
114
+ @plugin[:network][:default_interface].should == 'en0'
110
115
  end
111
116
  end
112
117
 
113
118
  describe "lsdev -Cc if" do
114
-
115
119
  it "detects the state of the interfaces in the system" do
116
- @ohai['network']['interfaces']['en0'][:state].should == "up"
120
+ @plugin.run
121
+ @plugin['network']['interfaces']['en0'][:state].should == "up"
117
122
  end
118
123
 
119
124
  it "detects the description of the interfaces in the system" do
120
- @ohai['network']['interfaces']['en0'][:description].should == "Standard Ethernet Network Interface"
125
+ @plugin.run
126
+ @plugin['network']['interfaces']['en0'][:description].should == "Standard Ethernet Network Interface"
121
127
  end
122
128
 
123
129
  describe "ifconfig interface" do
124
130
  it "detects the CHAIN network flag" do
125
- @ohai['network']['interfaces']['en0'][:flags].should include('CHAIN')
131
+ @plugin.run
132
+ @plugin['network']['interfaces']['en0'][:flags].should include('CHAIN')
126
133
  end
127
134
 
128
135
  it "detects the metric network flag" do
129
- @ohai['network']['interfaces']['en0'][:metric].should == '1'
136
+ @plugin.run
137
+ @plugin['network']['interfaces']['en0'][:metric].should == '1'
130
138
  end
131
139
 
132
140
  context "inet entries" do
133
141
  before do
134
- @inet_entry = @ohai['network']['interfaces']['en0'][:addresses]["172.29.174.58"]
142
+ @plugin.run
143
+ @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.58"]
135
144
  end
145
+
136
146
  it "detects the family" do
137
147
  @inet_entry[:family].should == 'inet'
138
148
  end
@@ -146,23 +156,24 @@ ARP_AN
146
156
  end
147
157
 
148
158
  it "detects all key-values" do
149
- @ohai['network']['interfaces']['en0'][:tcp_sendspace].should == "262144"
150
- @ohai['network']['interfaces']['en0'][:tcp_recvspace].should == "262144"
151
- @ohai['network']['interfaces']['en0'][:rfc1323].should == "1"
159
+ @plugin['network']['interfaces']['en0'][:tcp_sendspace].should == "262144"
160
+ @plugin['network']['interfaces']['en0'][:tcp_recvspace].should == "262144"
161
+ @plugin['network']['interfaces']['en0'][:rfc1323].should == "1"
152
162
  end
153
163
 
154
164
  # For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255
155
165
  context "with no netmask in the output" do
156
166
  before do
157
- @inet_entry = @ohai['network']['interfaces']['en0'][:addresses]["172.29.174.59"]
158
- @ohai.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet 172.29.174.59 broadcast 172.29.191.255"), nil)
167
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
159
168
  end
160
169
 
161
170
  it "detects the default prefixlen" do
171
+ @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"]
162
172
  @inet_entry[:prefixlen].should == '32'
163
173
  end
164
174
 
165
175
  it "detects the default netmask" do
176
+ @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"]
166
177
  @inet_entry[:netmask].should == '255.255.255.255'
167
178
  end
168
179
  end
@@ -170,8 +181,9 @@ ARP_AN
170
181
 
171
182
  context "inet6 entries" do
172
183
  before do
173
- @inet_entry = @ohai['network']['interfaces']['en0'][:addresses]["::1%1"]
174
- @ohai.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet6 ::1%1/0"), nil)
184
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet6 ::1%1/0", nil))
185
+ @plugin.run
186
+ @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["::1%1"]
175
187
  end
176
188
 
177
189
  it "detects the prefixlen" do
@@ -186,7 +198,8 @@ ARP_AN
186
198
 
187
199
  context "entstat -d interface" do
188
200
  before do
189
- @inet_interface_addresses = @ohai['network']['interfaces']['en0'][:addresses]["BE:42:80:00:B0:05"]
201
+ @plugin.run
202
+ @inet_interface_addresses = @plugin['network']['interfaces']['en0'][:addresses]["BE:42:80:00:B0:05"]
190
203
  end
191
204
  it "detects the family" do
192
205
  @inet_interface_addresses[:family].should == 'lladdr'
@@ -195,64 +208,72 @@ ARP_AN
195
208
  end
196
209
 
197
210
  describe "netstat -nrf family" do
198
- context "inet" do
211
+ before do
212
+ @plugin.run
213
+ end
199
214
 
215
+ context "inet" do
200
216
  it "detects the route destinations" do
201
- @ohai['network']['interfaces']['en0'][:routes][0][:destination].should == "default"
202
- @ohai['network']['interfaces']['en0'][:routes][1][:destination].should == "172.29.128.0"
217
+ @plugin['network']['interfaces']['en0'][:routes][0][:destination].should == "default"
218
+ @plugin['network']['interfaces']['en0'][:routes][1][:destination].should == "172.29.128.0"
203
219
  end
204
220
 
205
221
  it "detects the route family" do
206
- @ohai['network']['interfaces']['en0'][:routes][0][:family].should == "inet"
222
+ @plugin['network']['interfaces']['en0'][:routes][0][:family].should == "inet"
207
223
  end
208
224
 
209
225
  it "detects the route gateway" do
210
- @ohai['network']['interfaces']['en0'][:routes][0][:via].should == "172.29.128.13"
226
+ @plugin['network']['interfaces']['en0'][:routes][0][:via].should == "172.29.128.13"
211
227
  end
212
228
 
213
229
  it "detects the route flags" do
214
- @ohai['network']['interfaces']['en0'][:routes][0][:flags].should == "UG"
230
+ @plugin['network']['interfaces']['en0'][:routes][0][:flags].should == "UG"
215
231
  end
216
232
  end
217
233
 
218
234
  context "inet6" do
219
235
 
220
236
  it "detects the route destinations" do
221
- @ohai['network']['interfaces']['en0'][:routes][4][:destination].should == "::1%1"
237
+ @plugin['network']['interfaces']['en0'][:routes][4][:destination].should == "::1%1"
222
238
  end
223
239
 
224
240
  it "detects the route family" do
225
- @ohai['network']['interfaces']['en0'][:routes][4][:family].should == "inet6"
241
+ @plugin['network']['interfaces']['en0'][:routes][4][:family].should == "inet6"
226
242
  end
227
243
 
228
244
  it "detects the route gateway" do
229
- @ohai['network']['interfaces']['en0'][:routes][4][:via].should == "::1%1"
245
+ @plugin['network']['interfaces']['en0'][:routes][4][:via].should == "::1%1"
230
246
  end
231
247
 
232
248
  it "detects the route flags" do
233
- @ohai['network']['interfaces']['en0'][:routes][4][:flags].should == "UH"
249
+ @plugin['network']['interfaces']['en0'][:routes][4][:flags].should == "UH"
234
250
  end
235
251
  end
236
252
  end
237
253
 
238
254
  describe "arp -an" do
239
-
255
+ before do
256
+ @plugin.run
257
+ end
240
258
  it "supresses the hostname entries" do
241
- @ohai['network']['arp'][0][:remote_host].should == "?"
259
+ @plugin['network']['arp'][0][:remote_host].should == "?"
242
260
  end
243
261
 
244
262
  it "detects the remote ip entry" do
245
- @ohai['network']['arp'][0][:remote_ip].should == "172.29.131.16"
263
+ @plugin['network']['arp'][0][:remote_ip].should == "172.29.131.16"
246
264
  end
247
265
 
248
266
  it "detects the remote mac entry" do
249
- @ohai['network']['arp'][0][:remote_mac].should == "6e:87:70:0:40:3"
267
+ @plugin['network']['arp'][0][:remote_mac].should == "6e:87:70:0:40:3"
250
268
  end
251
269
  end
252
270
 
253
271
  describe "hex_to_dec_netmask method" do
272
+ before do
273
+ @plugin.run
274
+ end
254
275
  it "converts a netmask from hexadecimal form to decimal form" do
255
- @ohai.hex_to_dec_netmask('0xffff0000').should == "255.255.0.0"
276
+ @plugin.hex_to_dec_netmask('0xffff0000').should == "255.255.0.0"
256
277
  end
257
278
  end
258
279
  end