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,32 +22,27 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
22
22
  describe Ohai::System, "plugin mono" do
23
23
 
24
24
  before(:each) do
25
- @ohai = Ohai::System.new
26
- @ohai[:languages] = Mash.new
27
- @ohai.stub!(:require_plugin).and_return(true)
28
- @status = 0
25
+ @plugin = get_plugin("mono")
26
+ @plugin[:languages] = Mash.new
29
27
  @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
30
- @stderr = ""
31
- @ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr])
28
+ @plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
32
29
  end
33
30
 
34
31
  it "should get the mono version from running mono -V" do
35
- @ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([0, "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n", ""])
36
- @ohai._require_plugin("mono")
32
+ @plugin.should_receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
33
+ @plugin.run
37
34
  end
38
35
 
39
36
  it "should set languages[:mono][:version]" do
40
- @ohai._require_plugin("mono")
41
- @ohai.languages[:mono][:version].should eql("1.2.6")
37
+ @plugin.run
38
+ @plugin.languages[:mono][:version].should eql("1.2.6")
42
39
  end
43
40
 
44
41
  it "should not set the languages[:mono] tree up if mono command fails" do
45
- @status = 1
46
42
  @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
47
- @stderr = ""
48
- @ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr])
49
- @ohai._require_plugin("mono")
50
- @ohai.languages.should_not have_key(:mono)
43
+ @plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
44
+ @plugin.run
45
+ @plugin.languages.should_not have_key(:mono)
51
46
  end
52
47
 
53
48
  end
@@ -21,14 +21,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
 
22
22
  describe Ohai::System, "NetBSD hostname plugin" do
23
23
  before(:each) do
24
- @ohai = Ohai::System.new
25
- @ohai.stub!(:require_plugin).and_return(true)
26
- @ohai[:os] = "netbsd"
27
- @ohai.stub!(:from).with("hostname -s").and_return("katie")
28
- @ohai.stub!(:from).with("hostname").and_return("katie.bethell")
24
+ @plugin = get_plugin("hostname")
25
+ @plugin.stub(:collect_os).and_return(:netbsd)
26
+ @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
27
+ @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
28
+ @plugin.stub(:resolve_fqdn).and_return("katie.bethell")
29
29
  end
30
30
 
31
- it_should_check_from("netbsd::hostname", "hostname", "hostname -s", "katie")
31
+ it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
32
32
 
33
- it_should_check_from("netbsd::hostname", "fqdn", "hostname", "katie.bethell")
33
+ it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
34
+
35
+ it "should use #resolve_fqdn to find the fqdn" do
36
+ @plugin.run
37
+ @plugin[:fqdn].should == "katie.bethell"
38
+ end
39
+
40
+ it "should set the domain to everything after the first dot of the fqdn" do
41
+ @plugin.run
42
+ @plugin[:domain].should == "bethell"
43
+ end
34
44
  end
@@ -21,16 +21,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
 
22
22
  describe Ohai::System, "NetBSD kernel plugin" do
23
23
  before(:each) do
24
- @ohai = Ohai::System.new
25
- @ohai.stub!(:require_plugin).and_return(true)
26
- @ohai.stub!(:from).with("uname -i").and_return("foo")
27
- @ohai.stub!(:from_with_regex).with("sysctl kern.securelevel").and_return("kern.securelevel: 1")
28
- @ohai[:kernel] = Mash.new
29
- @ohai[:kernel][:name] = "netbsd"
24
+ @plugin = get_plugin("kernel")
25
+ @plugin.stub(:collect_os).and_return(:netbsd)
26
+ @plugin.stub(:init_kernel).and_return({})
27
+ @plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
28
+ @plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
29
+ @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/bin/modstat" )}").and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
30
30
  end
31
31
 
32
32
  it "should set the kernel_os to the kernel_name value" do
33
- @ohai._require_plugin("netbsd::kernel")
34
- @ohai[:kernel][:os].should == @ohai[:kernel][:name]
33
+ @plugin.run
34
+ @plugin[:kernel][:os].should == @plugin[:kernel][:name]
35
35
  end
36
36
  end
@@ -16,25 +16,23 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
-
20
19
  require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
20
 
22
21
  describe Ohai::System, "NetBSD plugin platform" do
23
22
  before(:each) do
24
- @ohai = Ohai::System.new
25
- @ohai.stub!(:require_plugin).and_return(true)
26
- @ohai.stub!(:from).with("uname -s").and_return("NetBSD")
27
- @ohai.stub!(:from).with("uname -r").and_return("4.5")
28
- @ohai[:os] = "netbsd"
23
+ @plugin = get_plugin("netbsd/platform")
24
+ @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
25
+ @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
26
+ @plugin.stub(:collect_os).and_return(:netbsd)
29
27
  end
30
28
 
31
29
  it "should set platform to lowercased lsb[:id]" do
32
- @ohai._require_plugin("netbsd::platform")
33
- @ohai[:platform].should == "netbsd"
30
+ @plugin.run
31
+ @plugin[:platform].should == "netbsd"
34
32
  end
35
33
 
36
34
  it "should set platform_version to lsb[:release]" do
37
- @ohai._require_plugin("netbsd::platform")
38
- @ohai[:platform_version].should == "4.5"
35
+ @plugin.run
36
+ @plugin[:platform_version].should == "4.5"
39
37
  end
40
38
  end
@@ -20,11 +20,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
20
20
 
21
21
  def it_does_not_fail
22
22
  it "doesn't fail" do
23
- Ohai::Log.should_receive(:warn).any_number_of_times
23
+ Ohai::Log.stub(:warn)
24
24
  Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/)
25
- @ohai._require_plugin("network")
26
- %w[ ipaddress, macaddress, ip6address ].each do |attribute|
27
- @ohai.should have_key(attribute)
25
+ @plugin.run
26
+ %w{ ipaddress macaddress ip6address }.each do |attribute|
27
+ @plugin.should have_key(attribute)
28
28
  end
29
29
  end
30
30
  end
@@ -32,6 +32,143 @@ end
32
32
  describe Ohai::System, "Network Plugin" do
33
33
 
34
34
  basic_data = {
35
+ "freebsd" => {
36
+ "network" => {
37
+ "interfaces" => {
38
+ "vr0" => {
39
+ "type" => "vr",
40
+ "number" => "0",
41
+ "flags" => ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"],
42
+ "addresses" => {
43
+ "00:00:24:c9:5e:b8" => {"family" => "lladdr"},
44
+ "fe80::200:24ff:fec9:5eb8" => {
45
+ "family" => "inet6",
46
+ "zoneid" => "vr0",
47
+ "prefixlen" => "64",
48
+ "scopeid" => "0x1"
49
+ },
50
+ "76.91.1.255" => {
51
+ "family" => "inet",
52
+ "netmask" => "255.255.252.0",
53
+ "broadcast" => "255.255.255.255"
54
+ }
55
+ },
56
+ "arp" => {
57
+ "76.91.1.255" => "00:00:24:c9:5e:b8",
58
+ "76.91.0.1" => "00:01:5c:24:8c:01"
59
+ }
60
+ },
61
+ "vr1" => {
62
+ "type" => "vr",
63
+ "number" => "1",
64
+ "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
65
+ "addresses" => {
66
+ "00:00:24:c9:5e:b9" => {"family" => "lladdr"},
67
+ "fe80::200:24ff:fec9:5eb9" => {
68
+ "family" => "inet6",
69
+ "zoneid" => "vr1",
70
+ "prefixlen" => "64",
71
+ "scopeid" => "0x2"
72
+ }
73
+ }
74
+ },
75
+ "vr2" => {
76
+ "type" => "vr",
77
+ "number" => "2",
78
+ "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
79
+ "addresses" => {
80
+ "00:00:24:c9:5e:ba" => {"family" => "lladdr"},
81
+ "fe80::200:24ff:fec9:5eba" => {
82
+ "family" => "inet6",
83
+ "zoneid" => "vr2",
84
+ "prefixlen" => "64",
85
+ "scopeid" => "0x3"
86
+ }
87
+ }
88
+ },
89
+ "vr3" => {
90
+ "type" => "vr",
91
+ "number" => "3",
92
+ "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
93
+ "addresses" => {
94
+ "00:00:24:c9:5e:bb" => {"family" => "lladdr"},
95
+ "fe80::200:24ff:fec9:5ebb" => {
96
+ "family" => "inet6",
97
+ "zoneid" => "vr3",
98
+ "prefixlen" => "64",
99
+ "scopeid" => "0x4"
100
+ }
101
+ }
102
+ },
103
+ "ipfw0" => {
104
+ # OHAI-492: Ensure network plugin works with interfaces without addresses.
105
+ "type" => "ipfw",
106
+ "number" => "0",
107
+ "flags" => ["UP", "SIMPLEX", "MULTICAST"]
108
+ },
109
+ "lo0" => {
110
+ "type" => "lo",
111
+ "number" => "0",
112
+ "flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"],
113
+ "addresses" => {
114
+ "127.0.0.1" => {"family" => "inet", "netmask" => "255.0.0.0"},
115
+ "::1" => {"family" => "inet6", "prefixlen" => "128"},
116
+ "fe80::1" => {
117
+ "family" => "inet6",
118
+ "zoneid" => "lo0",
119
+ "prefixlen" => "64",
120
+ "scopeid" => "0x8"
121
+ }
122
+ }
123
+ },
124
+ "bridge0" => {
125
+ "type" => "bridge",
126
+ "number" => "0",
127
+ "flags" => ["LEARNING", "DISCOVER", "AUTOEDGE", "AUTOPTP"],
128
+ "addresses" => {
129
+ "02:20:6f:d2:c4:00" => {"family"=>"lladdr"},
130
+ "192.168.2.1" => {
131
+ "family" => "inet",
132
+ "netmask" => "255.255.255.0",
133
+ "broadcast" => "192.168.2.255"
134
+ },
135
+ "2001:470:d:cb4::1" => {"family" => "inet6", "prefixlen" => "64"},
136
+ "fe80::cafe:babe:dead:beef" => {
137
+ "family" => "inet6",
138
+ "zoneid" => "bridge0",
139
+ "prefixlen" => "64",
140
+ "scopeid" => "0x9"
141
+ }
142
+ },
143
+ "arp" => {
144
+ "192.168.2.142" => "60:67:20:75:a2:0c",
145
+ "192.168.2.205" => "c0:c1:c0:f9:40:ed",
146
+ "192.168.2.160" => "cc:3a:61:cf:67:13",
147
+ "192.168.2.1" => "02:20:6f:d2:c4:00",
148
+ "192.168.2.135" => "f8:0c:f3:d7:c6:b6",
149
+ "192.168.2.165" => "f8:8f:ca:24:49:ad",
150
+ "192.168.2.158" => "48:5d:60:1f:ea:d1",
151
+ "192.168.2.150" => "60:a4:4c:60:b3:d9"
152
+ }
153
+ },
154
+ "gif0" => {
155
+ "type" => "gif",
156
+ "number" => "0",
157
+ "flags" => ["UP", "POINTOPOINT", "RUNNING", "MULTICAST"],
158
+ "addresses" => {
159
+ "fe80::200:24ff:fec9:5eb8" => {
160
+ "family" => "inet6",
161
+ "zoneid" => "gif0",
162
+ "prefixlen" => "64",
163
+ "scopeid" => "0xa"
164
+ }
165
+ }
166
+ }
167
+ },
168
+ "default_gateway" => "76.91.0.1",
169
+ "default_interface" => "vr0"
170
+ }
171
+ },
35
172
  "linux" => {
36
173
  "network" => {
37
174
  # pp Hash[node['network']] from shef to get the network data
@@ -149,84 +286,76 @@ describe Ohai::System, "Network Plugin" do
149
286
 
150
287
  describe "with linux" do
151
288
  before(:each) do
152
- @ohai = Ohai::System.new
153
- @ohai.stub!(:require_plugin).twice.and_return(true)
154
- @ohai["network"] = basic_data["linux"]["network"]
289
+ @plugin = get_plugin("network")
290
+ @plugin["network"] = basic_data["linux"]["network"]
155
291
  end
156
292
 
157
293
  describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
158
294
  describe "simple setup" do
159
295
  it_does_not_fail
160
296
 
161
- it "logs 2 debug messages" do
162
- Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
163
- Ohai::Log.should_receive(:debug).with(/^\[inet\] Using default/).once
164
- Ohai::Log.should_receive(:debug).with(/^\[inet6\] Using default/).once
165
- @ohai._require_plugin("network")
166
- end
167
-
168
297
  it "detects {ip,ip6,mac}address" do
169
- @ohai._require_plugin("network")
170
- @ohai["ipaddress"].should == "192.168.66.33"
171
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
172
- @ohai["ip6address"].should == "3ffe:1111:2222::33"
298
+ @plugin.run
299
+ @plugin["ipaddress"].should == "192.168.66.33"
300
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
301
+ @plugin["ip6address"].should == "3ffe:1111:2222::33"
173
302
  end
174
303
  end
175
304
 
176
305
  describe "default ipv4 and ipv6 gateway on different interfaces" do
177
306
  describe "both interfaces have an ARP" do
178
307
  before do
179
- @ohai["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
180
- @ohai["network"]["default_inet6_interface"] = "eth1"
308
+ @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
309
+ @plugin["network"]["default_inet6_interface"] = "eth1"
181
310
  end
182
311
 
183
312
  it_does_not_fail
184
313
 
185
314
  it "detects {ip,ip6}address" do
186
- @ohai._require_plugin("network")
187
- @ohai["ipaddress"].should == "192.168.66.33"
188
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
315
+ @plugin.run
316
+ @plugin["ipaddress"].should == "192.168.66.33"
317
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
189
318
  end
190
319
 
191
320
  it "set macaddress from the ipv4 setup" do
192
- @ohai._require_plugin("network")
193
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
321
+ @plugin.run
322
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
194
323
  end
195
324
 
196
325
  it "informs about this setup" do
197
326
  Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
198
- Ohai::Log.should_receive(:debug).any_number_of_times
199
- @ohai._require_plugin("network")
327
+ Ohai::Log.stub(:debug)
328
+ @plugin.run
200
329
  end
201
330
  end
202
331
 
203
332
  describe "ipv4 interface has no ARP" do
204
333
  before do
205
- @ohai["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,kv| kv["family"] == "lladdr" }
334
+ @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,kv| kv["family"] == "lladdr" }
206
335
  # not really checked by this pluging
207
- @ohai["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
208
- @ohai["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
209
- @ohai["network"]["default_inet6_interface"] = "eth1"
336
+ @plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
337
+ @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
338
+ @plugin["network"]["default_inet6_interface"] = "eth1"
210
339
  end
211
340
 
212
341
  it_does_not_fail
213
342
 
214
343
  it "detects {ip,ip6}address" do
215
- @ohai._require_plugin("network")
216
- @ohai["ipaddress"].should == "192.168.66.33"
217
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
344
+ @plugin.run
345
+ @plugin["ipaddress"].should == "192.168.66.33"
346
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
218
347
  end
219
348
 
220
349
  it "doesn't set macaddress, ipv4 setup is valid and has precedence over ipv6" do
221
350
  Ohai::Log.should_not_receive(:warn).with(/^unable to detect macaddress/)
222
- @ohai._require_plugin("network")
223
- @ohai["macaddress"].should be_nil
351
+ @plugin.run
352
+ @plugin["macaddress"].should be_nil
224
353
  end
225
354
 
226
355
  it "informs about this setup" do
227
356
  Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
228
- Ohai::Log.should_receive(:debug).any_number_of_times
229
- @ohai._require_plugin("network")
357
+ Ohai::Log.stub(:debug)
358
+ @plugin.run
230
359
  end
231
360
  end
232
361
  end
@@ -234,61 +363,56 @@ describe Ohai::System, "Network Plugin" do
234
363
  describe "conflicting results from the linux::network plugin" do
235
364
  describe "default interface doesn't match the default_gateway" do
236
365
  before do
237
- @ohai["network"]["default_interface"] = "eth1"
238
- @ohai["network"]["default_inet6_interface"] = "eth1"
366
+ @plugin["network"]["default_interface"] = "eth1"
367
+ @plugin["network"]["default_inet6_interface"] = "eth1"
239
368
  end
240
369
 
241
370
  it_does_not_fail
242
371
 
243
372
  it "picks {ip,ip6,mac}address" do
244
- Ohai::Log.should_receive(:warn).any_number_of_times
245
- @ohai._require_plugin("network")
246
- @ohai["ipaddress"].should == "192.168.99.11"
247
- @ohai["macaddress"].should == "00:16:3E:2F:36:80"
248
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
373
+ Ohai::Log.stub(:warn)
374
+ @plugin.run
375
+ @plugin["ipaddress"].should == "192.168.99.11"
376
+ @plugin["macaddress"].should == "00:16:3E:2F:36:80"
377
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
249
378
  end
250
379
 
251
380
  it "warns about this conflict" do
252
381
  Ohai::Log.should_receive(:warn).with(/^\[inet\] no ipaddress\/mask on eth1/).once
253
382
  Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
254
- @ohai._require_plugin("network")
383
+ @plugin.run
255
384
  end
256
385
  end
257
386
 
258
387
  describe "there's a default gateway, none of the configured ip/mask theorically allows to reach it" do
259
388
  before do
260
- @ohai["network"]["default_gateway"] = "172.16.12.42"
261
- @ohai["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
389
+ @plugin["network"]["default_gateway"] = "172.16.12.42"
390
+ @plugin["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
262
391
  end
263
392
 
264
393
  it "picks {ip,ip6,mac}address" do
265
- Ohai::Log.should_receive(:warn).any_number_of_times
266
- @ohai._require_plugin("network")
267
- @ohai["ipaddress"].should == "192.168.66.33"
268
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
269
- @ohai["ip6address"].should == "3ffe:1111:2222::33"
394
+ Ohai::Log.stub(:warn)
395
+ @plugin.run
396
+ @plugin["ipaddress"].should == "192.168.66.33"
397
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
398
+ @plugin["ip6address"].should == "3ffe:1111:2222::33"
270
399
  end
271
400
 
272
- it "warns about this conflict" do
273
- Ohai::Log.should_receive(:warn).with(/^\[inet\] no ipaddress\/mask on eth0/).once
274
- Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ipaddress\/mask on eth0/).once
275
- @ohai._require_plugin("network")
276
- end
277
401
  end
278
402
 
279
403
  describe "no ip address for the given default interface/gateway" do
280
404
  before do
281
- @ohai["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
405
+ @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
282
406
  end
283
407
 
284
408
  it_does_not_fail
285
409
 
286
410
  it "doesn't detect {ip,ip6,mac}address" do
287
- Ohai::Log.should_receive(:warn).any_number_of_times
288
- @ohai._require_plugin("network")
289
- @ohai["ipaddress"].should be_nil
290
- @ohai["macaddress"].should be_nil
291
- @ohai["ip6address"].should be_nil
411
+ Ohai::Log.stub(:warn)
412
+ @plugin.run
413
+ @plugin["ipaddress"].should be_nil
414
+ @plugin["macaddress"].should be_nil
415
+ @plugin["ip6address"].should be_nil
292
416
  end
293
417
 
294
418
  it "warns about this conflict" do
@@ -297,17 +421,17 @@ describe Ohai::System, "Network Plugin" do
297
421
  Ohai::Log.should_receive(:warn).with(/^\[inet\] no ip address on eth0/).once
298
422
  Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
299
423
  Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ip address on eth0/).once
300
- @ohai._require_plugin("network")
424
+ @plugin.run
301
425
  end
302
426
  end
303
427
 
304
428
  describe "no ip at all" do
305
429
  before do
306
- @ohai["network"]["default_gateway"] = nil
307
- @ohai["network"]["default_interface"] = nil
308
- @ohai["network"]["default_inet6_gateway"] = nil
309
- @ohai["network"]["default_inet6_interface"] = nil
310
- @ohai["network"]["interfaces"].each do |i,iv|
430
+ @plugin["network"]["default_gateway"] = nil
431
+ @plugin["network"]["default_interface"] = nil
432
+ @plugin["network"]["default_inet6_gateway"] = nil
433
+ @plugin["network"]["default_inet6_interface"] = nil
434
+ @plugin["network"]["interfaces"].each do |i,iv|
311
435
  iv["addresses"].delete_if{|k,kv| %w[inet inet6].include? kv["family"]}
312
436
  end
313
437
  end
@@ -315,18 +439,18 @@ describe Ohai::System, "Network Plugin" do
315
439
  it_does_not_fail
316
440
 
317
441
  it "doesn't detect {ip,ip6,mac}address" do
318
- Ohai::Log.should_receive(:warn).any_number_of_times
319
- @ohai._require_plugin("network")
320
- @ohai["ipaddress"].should be_nil
321
- @ohai["macaddress"].should be_nil
322
- @ohai["ip6address"].should be_nil
442
+ Ohai::Log.stub(:warn)
443
+ @plugin.run
444
+ @plugin["ipaddress"].should be_nil
445
+ @plugin["macaddress"].should be_nil
446
+ @plugin["ip6address"].should be_nil
323
447
  end
324
448
 
325
449
  it "should warn about it" do
326
450
  Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
327
451
  Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
328
452
  Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
329
- @ohai._require_plugin("network")
453
+ @plugin.run
330
454
  end
331
455
  end
332
456
  end
@@ -334,7 +458,7 @@ describe Ohai::System, "Network Plugin" do
334
458
  describe "several ipaddresses matching the default route" do
335
459
  describe "bigger prefix not set on the default interface" do
336
460
  before do
337
- @ohai["network"]["interfaces"]["eth2"] = {
461
+ @plugin["network"]["interfaces"]["eth2"] = {
338
462
  "flags" => ["BROADCAST", "MULTICAST", "UP"],
339
463
  "number" => "2",
340
464
  "addresses" => {
@@ -363,23 +487,23 @@ describe Ohai::System, "Network Plugin" do
363
487
  it_does_not_fail
364
488
 
365
489
  it "sets {ip,ip6,mac}address correctly" do
366
- @ohai._require_plugin("network")
367
- @ohai["ipaddress"].should == "192.168.66.33"
368
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
369
- @ohai["ip6address"].should == "3ffe:1111:2222::33"
490
+ @plugin.run
491
+ @plugin["ipaddress"].should == "192.168.66.33"
492
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
493
+ @plugin["ip6address"].should == "3ffe:1111:2222::33"
370
494
  end
371
495
  end
372
496
 
373
497
  describe "bigger prefix set on the default interface" do
374
498
  before do
375
- @ohai["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
499
+ @plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
376
500
  "scope" => "Global",
377
501
  "netmask" => "255.255.255.128",
378
502
  "broadcast" => "192.168.66.127",
379
503
  "prefixlen" => "25",
380
504
  "family" => "inet"
381
505
  }
382
- @ohai["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
506
+ @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
383
507
  "prefixlen" => "64",
384
508
  "family" => "inet6",
385
509
  "scope" => "Global"
@@ -389,16 +513,16 @@ describe Ohai::System, "Network Plugin" do
389
513
  it_does_not_fail
390
514
 
391
515
  it "sets {ip,ip6,mac}address correctly" do
392
- @ohai._require_plugin("network")
393
- @ohai["ipaddress"].should == "192.168.66.99"
394
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
395
- @ohai["ip6address"].should == "3ffe:1111:2222:0:4444::1"
516
+ @plugin.run
517
+ @plugin["ipaddress"].should == "192.168.66.99"
518
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
519
+ @plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
396
520
  end
397
521
  end
398
522
 
399
523
  describe "smallest ip not set on the default_interface" do
400
524
  before do
401
- @ohai["network"]["interfaces"]["eth2"] = {
525
+ @plugin["network"]["interfaces"]["eth2"] = {
402
526
  "flags" => ["BROADCAST", "MULTICAST", "UP"],
403
527
  "number" => "2",
404
528
  "addresses" => {
@@ -427,23 +551,23 @@ describe Ohai::System, "Network Plugin" do
427
551
  it_does_not_fail
428
552
 
429
553
  it "sets {ip,ip6,mac}address correctly" do
430
- @ohai._require_plugin("network")
431
- @ohai["ipaddress"].should == "192.168.66.33"
432
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
433
- @ohai["ip6address"].should == "3ffe:1111:2222::33"
554
+ @plugin.run
555
+ @plugin["ipaddress"].should == "192.168.66.33"
556
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
557
+ @plugin["ip6address"].should == "3ffe:1111:2222::33"
434
558
  end
435
559
  end
436
560
 
437
561
  describe "smallest ip set on the default_interface" do
438
562
  before do
439
- @ohai["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
563
+ @plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
440
564
  "scope" => "Global",
441
565
  "netmask" => "255.255.255.0",
442
566
  "broadcast" => "192.168.66.255",
443
567
  "prefixlen" => "24",
444
568
  "family" => "inet"
445
569
  }
446
- @ohai["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
570
+ @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
447
571
  "prefixlen" => "48",
448
572
  "family" => "inet6",
449
573
  "scope" => "Global"
@@ -453,10 +577,10 @@ describe Ohai::System, "Network Plugin" do
453
577
  it_does_not_fail
454
578
 
455
579
  it "sets {ip,ip6,mac}address correctly" do
456
- @ohai._require_plugin("network")
457
- @ohai["ipaddress"].should == "192.168.66.32"
458
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
459
- @ohai["ip6address"].should == "3ffe:1111:2222::32"
580
+ @plugin.run
581
+ @plugin["ipaddress"].should == "192.168.66.32"
582
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
583
+ @plugin["ip6address"].should == "3ffe:1111:2222::32"
460
584
  end
461
585
  end
462
586
  end
@@ -464,12 +588,12 @@ describe Ohai::System, "Network Plugin" do
464
588
  describe "no default route" do
465
589
  describe "first interface is not the best choice" do
466
590
  before do
467
- @ohai["network"]["default_gateway"] = nil
468
- @ohai["network"]["default_interface"] = nil
469
- @ohai["network"]["default_inet6_gateway"] = nil
470
- @ohai["network"]["default_inet6_interface"] = nil
591
+ @plugin["network"]["default_gateway"] = nil
592
+ @plugin["network"]["default_interface"] = nil
593
+ @plugin["network"]["default_inet6_gateway"] = nil
594
+ @plugin["network"]["default_inet6_interface"] = nil
471
595
  # removing inet* addresses from eth0, to complicate things a bit
472
- @ohai["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
596
+ @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
473
597
  end
474
598
 
475
599
  it_does_not_fail
@@ -477,22 +601,22 @@ describe Ohai::System, "Network Plugin" do
477
601
  it "picks {ip,mac,ip6}address from the first interface" do
478
602
  Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
479
603
  Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
480
- Ohai::Log.should_receive(:debug).any_number_of_times
481
- @ohai._require_plugin("network")
482
- @ohai["ipaddress"].should == "192.168.99.11"
483
- @ohai["macaddress"].should == "00:16:3E:2F:36:80"
484
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
604
+ Ohai::Log.stub(:debug)
605
+ @plugin.run
606
+ @plugin["ipaddress"].should == "192.168.99.11"
607
+ @plugin["macaddress"].should == "00:16:3E:2F:36:80"
608
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
485
609
  end
486
610
  end
487
611
 
488
612
  describe "can choose from addresses with different scopes" do
489
613
  before do
490
- @ohai["network"]["default_gateway"] = nil
491
- @ohai["network"]["default_interface"] = nil
492
- @ohai["network"]["default_inet6_gateway"] = nil
493
- @ohai["network"]["default_inet6_interface"] = nil
614
+ @plugin["network"]["default_gateway"] = nil
615
+ @plugin["network"]["default_interface"] = nil
616
+ @plugin["network"]["default_inet6_gateway"] = nil
617
+ @plugin["network"]["default_inet6_interface"] = nil
494
618
  # just changing scopes to lInK for eth0 addresses
495
- @ohai["network"]["interfaces"]["eth0"]["addresses"].each{|k,v| v[:scope]="lInK" if %w[inet inet6].include? v["family"]}
619
+ @plugin["network"]["interfaces"]["eth0"]["addresses"].each{|k,v| v[:scope]="lInK" if %w[inet inet6].include? v["family"]}
496
620
  end
497
621
 
498
622
  it_does_not_fail
@@ -500,11 +624,11 @@ describe Ohai::System, "Network Plugin" do
500
624
  it "prefers global scope addressses to set {ip,mac,ip6}address" do
501
625
  Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
502
626
  Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
503
- Ohai::Log.should_receive(:debug).any_number_of_times
504
- @ohai._require_plugin("network")
505
- @ohai["ipaddress"].should == "192.168.99.11"
506
- @ohai["macaddress"].should == "00:16:3E:2F:36:80"
507
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
627
+ Ohai::Log.stub(:debug)
628
+ @plugin.run
629
+ @plugin["ipaddress"].should == "192.168.99.11"
630
+ @plugin["macaddress"].should == "00:16:3E:2F:36:80"
631
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
508
632
  end
509
633
  end
510
634
  end
@@ -512,36 +636,29 @@ describe Ohai::System, "Network Plugin" do
512
636
  describe "link level default route" do
513
637
  describe "simple setup" do
514
638
  before do
515
- @ohai["network"]["default_gateway"] = "0.0.0.0"
516
- @ohai["network"]["default_interface"] = "eth1"
517
- @ohai["network"]["default_inet6_gateway"] = "::"
518
- @ohai["network"]["default_inet6_interface"] = "eth1"
639
+ @plugin["network"]["default_gateway"] = "0.0.0.0"
640
+ @plugin["network"]["default_interface"] = "eth1"
641
+ @plugin["network"]["default_inet6_gateway"] = "::"
642
+ @plugin["network"]["default_inet6_interface"] = "eth1"
519
643
  end
520
644
 
521
645
  it_does_not_fail
522
646
 
523
- it "displays debug messages" do
524
- Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
525
- Ohai::Log.should_receive(:debug).with(/^link level default inet /).once
526
- Ohai::Log.should_receive(:debug).with(/^link level default inet6 /).once
527
- @ohai._require_plugin("network")
528
- end
529
-
530
647
  it "picks {ip,mac,ip6}address from the default interface" do
531
- @ohai._require_plugin("network")
532
- @ohai["ipaddress"].should == "192.168.99.11"
533
- @ohai["macaddress"].should == "00:16:3E:2F:36:80"
534
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
648
+ @plugin.run
649
+ @plugin["ipaddress"].should == "192.168.99.11"
650
+ @plugin["macaddress"].should == "00:16:3E:2F:36:80"
651
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
535
652
  end
536
653
  end
537
654
 
538
655
  describe "can choose from addresses with different scopes" do
539
656
  before do
540
- @ohai["network"]["default_gateway"] = "0.0.0.0"
541
- @ohai["network"]["default_interface"] = "eth1"
542
- @ohai["network"]["default_inet6_gateway"] = "::"
543
- @ohai["network"]["default_inet6_interface"] = "eth1"
544
- @ohai["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
657
+ @plugin["network"]["default_gateway"] = "0.0.0.0"
658
+ @plugin["network"]["default_interface"] = "eth1"
659
+ @plugin["network"]["default_inet6_gateway"] = "::"
660
+ @plugin["network"]["default_inet6_interface"] = "eth1"
661
+ @plugin["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
545
662
  "scope" => "host",
546
663
  "netmask" => "255.255.255.255",
547
664
  "prefixlen" => "32",
@@ -551,25 +668,18 @@ describe Ohai::System, "Network Plugin" do
551
668
 
552
669
  it_does_not_fail
553
670
 
554
- it "displays debug messages" do
555
- Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
556
- Ohai::Log.should_receive(:debug).with(/^link level default inet /).once
557
- Ohai::Log.should_receive(:debug).with(/^link level default inet6 /).once
558
- @ohai._require_plugin("network")
559
- end
560
-
561
671
  it "picks {ip,mac,ip6}address from the default interface" do
562
- @ohai._require_plugin("network")
563
- @ohai["ipaddress"].should == "192.168.99.11"
564
- @ohai["macaddress"].should == "00:16:3E:2F:36:80"
565
- @ohai["ip6address"].should == "3ffe:1111:3333::1"
672
+ @plugin.run
673
+ @plugin["ipaddress"].should == "192.168.99.11"
674
+ @plugin["macaddress"].should == "00:16:3E:2F:36:80"
675
+ @plugin["ip6address"].should == "3ffe:1111:3333::1"
566
676
  end
567
677
  end
568
678
  end
569
679
 
570
680
  describe "point to point address" do
571
681
  before do
572
- @ohai["network"]["interfaces"]["eth2"] = {
682
+ @plugin["network"]["interfaces"]["eth2"] = {
573
683
  "flags" => ["POINTOPOINT", "BROADCAST", "MULTICAST", "UP"],
574
684
  "number" => "2",
575
685
  "addresses" => {
@@ -594,27 +704,27 @@ describe Ohai::System, "Network Plugin" do
594
704
  }
595
705
  }
596
706
  }
597
- @ohai["network"]["default_gateway"] = "192.168.99.126"
598
- @ohai["network"]["default_interface"] = "eth2"
599
- @ohai["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
600
- @ohai["network"]["default_inet6_interface"] = "eth2"
707
+ @plugin["network"]["default_gateway"] = "192.168.99.126"
708
+ @plugin["network"]["default_interface"] = "eth2"
709
+ @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
710
+ @plugin["network"]["default_inet6_interface"] = "eth2"
601
711
  end
602
712
 
603
713
  it_does_not_fail
604
714
 
605
715
  it "picks {ip,mac,ip6}address from the default interface" do
606
- @ohai._require_plugin("network")
607
- @ohai["ipaddress"].should == "192.168.66.99"
608
- @ohai["macaddress"].should == "00:16:3E:2F:36:81"
609
- @ohai["ip6address"].should == "3ffe:1111:2222:0:4444::1"
716
+ @plugin.run
717
+ @plugin["ipaddress"].should == "192.168.66.99"
718
+ @plugin["macaddress"].should == "00:16:3E:2F:36:81"
719
+ @plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
610
720
  end
611
721
  end
612
722
 
613
723
  describe "ipv6 only node" do
614
724
  before do
615
- @ohai["network"]["default_gateway"] = nil
616
- @ohai["network"]["default_interface"] = nil
617
- @ohai["network"]["interfaces"].each do |i,iv|
725
+ @plugin["network"]["default_gateway"] = nil
726
+ @plugin["network"]["default_interface"] = nil
727
+ @plugin["network"]["interfaces"].each do |i,iv|
618
728
  iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
619
729
  end
620
730
  end
@@ -622,28 +732,28 @@ describe Ohai::System, "Network Plugin" do
622
732
  it_does_not_fail
623
733
 
624
734
  it "can't detect ipaddress" do
625
- Ohai::Log.should_receive(:warn).any_number_of_times
626
- @ohai._require_plugin("network")
627
- @ohai["ipaddress"].should be_nil
735
+ Ohai::Log.stub(:warn)
736
+ @plugin.run
737
+ @plugin["ipaddress"].should be_nil
628
738
  end
629
739
 
630
740
  it "warns about not being able to set {ip,mac}address (ipv4)" do
631
741
  Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
632
742
  Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
633
- @ohai._require_plugin("network")
743
+ @plugin.run
634
744
  end
635
745
 
636
746
  it "sets {ip6,mac}address" do
637
- Ohai::Log.should_receive(:warn).any_number_of_times
638
- @ohai._require_plugin("network")
639
- @ohai["ip6address"].should == "3ffe:1111:2222::33"
640
- @ohai["macaddress"].should == "00:16:3E:2F:36:79"
747
+ Ohai::Log.stub(:warn)
748
+ @plugin.run
749
+ @plugin["ip6address"].should == "3ffe:1111:2222::33"
750
+ @plugin["macaddress"].should == "00:16:3E:2F:36:79"
641
751
  end
642
752
 
643
753
  it "informs about macaddress being set using the ipv6 setup" do
644
754
  Ohai::Log.should_receive(:debug).with(/^macaddress set to 00:16:3E:2F:36:79 from the ipv6 setup/).once
645
- Ohai::Log.should_receive(:debug).any_number_of_times
646
- @ohai._require_plugin("network")
755
+ Ohai::Log.stub(:debug)
756
+ @plugin.run
647
757
  end
648
758
  end
649
759
 
@@ -652,16 +762,17 @@ describe Ohai::System, "Network Plugin" do
652
762
  basic_data.keys.sort.each do |os|
653
763
  describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
654
764
  before(:each) do
655
- @ohai = Ohai::System.new
656
- @ohai.stub!(:require_plugin).twice.and_return(true)
657
- @ohai["network"] = basic_data[os]["network"]
765
+ @plugin["network"] = basic_data[os]["network"]
658
766
  end
659
767
 
660
768
  describe "{ip,mac}address are already set" do
661
769
  before do
662
- @ohai["ipaddress"] = "10.11.12.13"
663
- @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
770
+ @plugin["ipaddress"] = "10.11.12.13"
771
+ @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
664
772
  @expected_results = {
773
+ "freebsd" => {
774
+ "ip6address" => "::1"
775
+ },
665
776
  "linux" => {
666
777
  "ip6address" => "3ffe:1111:2222::33"
667
778
  },
@@ -674,22 +785,26 @@ describe Ohai::System, "Network Plugin" do
674
785
  it_does_not_fail
675
786
 
676
787
  it "detects ip6address" do
677
- @ohai._require_plugin("network")
678
- @ohai["ip6address"].should == @expected_results[os]["ip6address"]
788
+ @plugin.run
789
+ @plugin["ip6address"].should == @expected_results[os]["ip6address"]
679
790
  end
680
791
 
681
792
  it "doesn't overwrite {ip,mac}address" do
682
- @ohai._require_plugin("network")
683
- @ohai["ipaddress"].should == "10.11.12.13"
684
- @ohai["macaddress"].should == "00:AA:BB:CC:DD:EE"
793
+ @plugin.run
794
+ @plugin["ipaddress"].should == "10.11.12.13"
795
+ @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
685
796
  end
686
797
  end
687
798
 
688
799
  describe "ip6address is already set" do
689
800
  describe "node has ipv4 and ipv6" do
690
801
  before do
691
- @ohai["ip6address"] = "3ffe:8888:9999::1"
802
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
692
803
  @expected_results = {
804
+ "freebsd" => {
805
+ "ipaddress" => "76.91.1.255",
806
+ "macaddress" => "00:00:24:c9:5e:b8"
807
+ },
693
808
  "linux" => {
694
809
  "ipaddress" => "192.168.66.33",
695
810
  "macaddress" => "00:16:3E:2F:36:79"
@@ -704,51 +819,53 @@ describe Ohai::System, "Network Plugin" do
704
819
  it_does_not_fail
705
820
 
706
821
  it "detects {ip,mac}address" do
707
- @ohai._require_plugin("network")
708
- @ohai["ipaddress"].should == @expected_results[os]["ipaddress"]
709
- @ohai["macaddress"].should == @expected_results[os]["macaddress"]
822
+ @plugin.run
823
+ @plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
824
+ @plugin["macaddress"].should == @expected_results[os]["macaddress"]
710
825
  end
711
826
 
712
827
  it "doesn't overwrite ip6address" do
713
- @ohai._require_plugin("network")
714
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
828
+ @plugin.run
829
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
715
830
  end
716
831
  end
717
832
 
718
833
  describe "ipv6 only node" do
719
834
  before do
720
- @ohai["network"]["default_gateway"] = nil
721
- @ohai["network"]["default_interface"] = nil
722
- @ohai["network"]["interfaces"].each do |i,iv|
723
- iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
835
+ @plugin["network"]["default_gateway"] = nil
836
+ @plugin["network"]["default_interface"] = nil
837
+ @plugin["network"]["interfaces"].each do |i,iv|
838
+ if iv.has_key? "addresses"
839
+ iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
840
+ end
724
841
  end
725
- @ohai["ip6address"] = "3ffe:8888:9999::1"
842
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
726
843
  end
727
844
 
728
845
  it_does_not_fail
729
846
 
730
847
  it "can't detect ipaddress (ipv4)" do
731
- Ohai::Log.should_receive(:warn).any_number_of_times
732
- @ohai._require_plugin("network")
733
- @ohai["ipaddress"].should be_nil
848
+ Ohai::Log.stub(:warn)
849
+ @plugin.run
850
+ @plugin["ipaddress"].should be_nil
734
851
  end
735
852
 
736
853
  it "can't detect macaddress either" do
737
- Ohai::Log.should_receive(:warn).any_number_of_times
738
- @ohai._require_plugin("network")
739
- @ohai["macaddress"].should be_nil
854
+ Ohai::Log.stub(:warn)
855
+ @plugin.run
856
+ @plugin["macaddress"].should be_nil
740
857
  end
741
858
 
742
859
  it "warns about not being able to set {ip,mac}address" do
743
860
  Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
744
861
  Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
745
- @ohai._require_plugin("network")
862
+ @plugin.run
746
863
  end
747
864
 
748
865
  it "doesn't overwrite ip6address" do
749
- Ohai::Log.should_receive(:warn).any_number_of_times
750
- @ohai._require_plugin("network")
751
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
866
+ Ohai::Log.stub(:warn)
867
+ @plugin.run
868
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
752
869
  end
753
870
  end
754
871
  end
@@ -756,9 +873,13 @@ describe Ohai::System, "Network Plugin" do
756
873
  describe "{mac,ip6}address are already set" do
757
874
  describe "valid ipv4 setup" do
758
875
  before do
759
- @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
760
- @ohai["ip6address"] = "3ffe:8888:9999::1"
876
+ @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
877
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
761
878
  @expected_results = {
879
+ "freebsd" => {
880
+ "ipaddress" => "76.91.1.255",
881
+ "macaddress" => "00:00:24:c9:5e:b8"
882
+ },
762
883
  "linux" => {
763
884
  "ipaddress" => "192.168.66.33",
764
885
  "macaddress" => "00:16:3E:2F:36:79"
@@ -773,75 +894,77 @@ describe Ohai::System, "Network Plugin" do
773
894
  it_does_not_fail
774
895
 
775
896
  it "detects ipaddress and overwrite macaddress" do
776
- @ohai._require_plugin("network")
777
- @ohai["ipaddress"].should == @expected_results[os]["ipaddress"]
778
- @ohai["macaddress"].should == @expected_results[os]["macaddress"]
897
+ @plugin.run
898
+ @plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
899
+ @plugin["macaddress"].should == @expected_results[os]["macaddress"]
779
900
  end
780
901
 
781
902
  it "doesn't overwrite ip6address" do
782
- @ohai._require_plugin("network")
783
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
903
+ @plugin.run
904
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
784
905
  end
785
906
  end
786
907
 
787
908
  describe "ipv6 only node" do
788
909
  before do
789
- @ohai["network"]["default_gateway"] = nil
790
- @ohai["network"]["default_interface"] = nil
791
- @ohai["network"]["interfaces"].each do |i,iv|
792
- iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
910
+ @plugin["network"]["default_gateway"] = nil
911
+ @plugin["network"]["default_interface"] = nil
912
+ @plugin["network"]["interfaces"].each do |i,iv|
913
+ if iv.has_key? "addresses"
914
+ iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
915
+ end
793
916
  end
794
- @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
795
- @ohai["ip6address"] = "3ffe:8888:9999::1"
917
+ @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
918
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
796
919
  end
797
920
 
798
921
  it_does_not_fail
799
922
 
800
923
  it "can't set ipaddress" do
801
- Ohai::Log.should_receive(:warn).any_number_of_times
802
- @ohai._require_plugin("network")
803
- @ohai["ipaddress"].should be_nil
924
+ Ohai::Log.stub(:warn)
925
+ @plugin.run
926
+ @plugin["ipaddress"].should be_nil
804
927
  end
805
928
 
806
929
  it "doesn't overwrite {ip6,mac}address" do
807
- Ohai::Log.should_receive(:warn).any_number_of_times
808
- @ohai._require_plugin("network")
809
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
810
- @ohai["macaddress"].should == "00:AA:BB:CC:DD:EE"
930
+ Ohai::Log.stub(:warn)
931
+ @plugin.run
932
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
933
+ @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
811
934
  end
812
935
  end
813
936
  end
814
937
 
815
938
  describe "{ip,mac,ip6}address are already set" do
816
939
  before do
817
- @ohai["ipaddress"] = "10.11.12.13"
818
- @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
819
- @ohai["ip6address"] = "3ffe:8888:9999::1"
940
+ @plugin["ipaddress"] = "10.11.12.13"
941
+ @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
942
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
820
943
  end
821
944
 
822
945
  it_does_not_fail
823
946
 
824
947
  it "doesn't overwrite {ip,mac,ip6}address" do
825
- @ohai._require_plugin("network")
826
- @ohai["ipaddress"].should == "10.11.12.13"
827
- @ohai["macaddress"].should == "00:AA:BB:CC:DD:EE"
828
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
948
+ @plugin.run
949
+ @plugin["ipaddress"].should == "10.11.12.13"
950
+ @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
951
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
829
952
  end
830
953
  end
831
954
 
832
955
  describe "{ip,ip6}address are already set" do
833
956
  before do
834
- @ohai["ipaddress"] = "10.11.12.13"
835
- @ohai["ip6address"] = "3ffe:8888:9999::1"
957
+ @plugin["ipaddress"] = "10.11.12.13"
958
+ @plugin["ip6address"] = "3ffe:8888:9999::1"
836
959
  end
837
960
 
838
961
  it_does_not_fail
839
962
 
840
963
  it "doesn't overwrite {ip,mac,ip6}address" do
841
- @ohai._require_plugin("network")
842
- @ohai["ipaddress"].should == "10.11.12.13"
843
- @ohai["macaddress"].should == nil
844
- @ohai["ip6address"].should == "3ffe:8888:9999::1"
964
+ @plugin.run
965
+ @plugin["ipaddress"].should == "10.11.12.13"
966
+ @plugin["macaddress"].should == nil
967
+ @plugin["ip6address"].should == "3ffe:8888:9999::1"
845
968
  end
846
969
  end
847
970