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
@@ -6,9 +6,9 @@
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,41 +21,34 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
 
22
22
  describe Ohai::System, "Linux hostname plugin" do
23
23
  before(:each) do
24
- @ohai = Ohai::System.new
25
- @ohai.stub!(:require_plugin).and_return(true)
26
- @ohai[:os] = "linux"
27
- @ohai.stub!(:from).with("hostname -s").and_return("katie")
28
- @ohai.stub!(:from).with("hostname --fqdn").and_return("katie.bethell")
24
+ @plugin = get_plugin("hostname")
25
+ @plugin.stub(:collect_os).and_return(:linux)
26
+ @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
27
+ @plugin.stub(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
28
+ @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
29
29
  end
30
30
 
31
31
  it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
32
-
32
+
33
33
  it_should_check_from("linux::hostname", "fqdn", "hostname --fqdn", "katie.bethell")
34
34
 
35
- describe "when domain name is unset" do
35
+ it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
36
+
37
+ describe "when domain name is unset" do
36
38
  before(:each) do
37
- @ohai.should_receive(:from).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
39
+ @plugin.should_receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
38
40
  end
39
41
 
40
42
  it "should not raise an error" do
41
- lambda { @ohai._require_plugin("linux::hostname") }.should_not raise_error
43
+ lambda { @plugin.run }.should_not raise_error
42
44
  end
43
45
 
44
46
  it "should not set fqdn" do
45
- @ohai._require_plugin("linux::hostname")
46
- @ohai.fqdn.should == nil
47
+ @plugin.run
48
+ @plugin.fqdn.should == nil
47
49
  end
50
+
48
51
  end
49
52
 
50
- describe "when hostname --fqdn is emtpy" do
51
- before(:each) do
52
- @ohai.stub!(:from).with("hostname --fqdn").
53
- and_return("", "katie.bethell")
54
- end
55
- it "should call it twice" do
56
- @ohai._require_plugin("linux::hostname")
57
- @ohai.fqdn.should == "katie.bethell"
58
- end
59
- end
60
53
  end
61
54
 
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
3
+ # Author:: Theodore Nordsieck (<theo@opscode.com>)
4
+ # Copyright:: Copyright (c) 2008-2013 Opscode, Inc.
4
5
  # License:: Apache License, Version 2.0
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,16 +17,29 @@
16
17
  # limitations under the License.
17
18
  #
18
19
 
19
-
20
20
  require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
 
22
22
  describe Ohai::System, "Linux kernel plugin" do
23
23
  before(:each) do
24
- @ohai = Ohai::System.new
25
- @ohai._require_plugin("kernel")
26
- @ohai.stub!(:require_plugin).and_return(true)
27
- @ohai.stub!(:from).with("uname -o").and_return("Linux")
24
+ @env_lsmod = <<-ENV_LSMOD
25
+ Module Size Used by
26
+ dm_crypt 22321 0
27
+ psmouse 81038 0
28
+ acpiphp 23314 0
29
+ microcode 18286 0
30
+ serio_raw 13031 0
31
+ virtio_balloon 13168 0
32
+ floppy 55441 0
33
+ ENV_LSMOD
34
+ @plugin = get_plugin("kernel")
35
+ @plugin.stub(:collect_os).and_return(:linux)
36
+ @plugin.stub(:init_kernel).and_return({})
37
+ @plugin.stub(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
38
+ @plugin.stub(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
39
+ @plugin.should_receive(:shell_out).with("env lsmod").at_least(1).times
40
+ @plugin.run
28
41
  end
29
42
 
30
- it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", "Linux")
31
- end
43
+ it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""])
44
+
45
+ end
@@ -23,128 +23,126 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
23
23
 
24
24
  describe Ohai::System, "Linux lsb plugin" do
25
25
  before(:each) do
26
- @ohai = Ohai::System.new
27
- @ohai[:os] = "linux"
28
- @ohai.stub!(:require_plugin).and_return(true)
29
- @ohai.extend(SimpleFromFile)
26
+ @plugin = get_plugin("linux/lsb")
27
+ @plugin.stub(:collect_os).and_return(:linux)
30
28
  end
31
29
 
32
30
  describe "on systems with /etc/lsb-release" do
33
31
  before(:each) do
34
- @mock_file = mock("/etc/lsb-release")
35
- @mock_file.stub!(:each).
32
+ @double_file = double("/etc/lsb-release")
33
+ @double_file.stub(:each).
36
34
  and_yield("DISTRIB_ID=Ubuntu").
37
35
  and_yield("DISTRIB_RELEASE=8.04").
38
36
  and_yield("DISTRIB_CODENAME=hardy").
39
37
  and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
40
- File.stub!(:open).with("/etc/lsb-release").and_return(@mock_file)
41
- File.stub!(:exists?).with("/etc/lsb-release").and_return(true)
38
+ File.stub(:open).with("/etc/lsb-release").and_return(@double_file)
39
+ File.stub(:exists?).with("/etc/lsb-release").and_return(true)
42
40
  end
43
41
 
44
42
  it "should set lsb[:id]" do
45
- @ohai._require_plugin("linux::lsb")
46
- @ohai[:lsb][:id].should == "Ubuntu"
43
+ @plugin.run
44
+ @plugin[:lsb][:id].should == "Ubuntu"
47
45
  end
48
46
 
49
47
  it "should set lsb[:release]" do
50
- @ohai._require_plugin("linux::lsb")
51
- @ohai[:lsb][:release].should == "8.04"
48
+ @plugin.run
49
+ @plugin[:lsb][:release].should == "8.04"
52
50
  end
53
51
 
54
52
  it "should set lsb[:codename]" do
55
- @ohai._require_plugin("linux::lsb")
56
- @ohai[:lsb][:codename].should == "hardy"
53
+ @plugin.run
54
+ @plugin[:lsb][:codename].should == "hardy"
57
55
  end
58
56
 
59
57
  it "should set lsb[:description]" do
60
- @ohai._require_plugin("linux::lsb")
61
- @ohai[:lsb][:description].should == "Ubuntu 8.04"
58
+ @plugin.run
59
+ @plugin[:lsb][:description].should == "Ubuntu 8.04"
62
60
  end
63
61
  end
64
62
 
65
63
  describe "on systems with /usr/bin/lsb_release" do
66
64
  before(:each) do
67
- File.stub!(:exists?).with("/etc/lsb-release").and_return(false)
68
- File.stub!(:exists?).with("/usr/bin/lsb_release").and_return(true)
65
+ File.stub(:exists?).with("/etc/lsb-release").and_return(false)
66
+ File.stub(:exists?).with("/usr/bin/lsb_release").and_return(true)
69
67
 
70
- @stdin = mock("STDIN", { :close => true })
68
+ @stdin = double("STDIN", { :close => true })
71
69
  @pid = 10
72
- @stderr = mock("STDERR")
73
- @stdout = mock("STDOUT")
70
+ @stderr = double("STDERR")
71
+ @stdout = double("STDOUT")
74
72
  @status = 0
75
73
 
76
74
  end
77
75
 
78
76
  describe "on Centos 5.4 correctly" do
79
77
  before(:each) do
80
- @stdout.stub!(:each).
81
- and_yield("LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch").
82
- and_yield("Distributor ID: CentOS").
83
- and_yield("Description: CentOS release 5.4 (Final)").
84
- and_yield("Release: 5.4").
85
- and_yield("Codename: Final")
86
-
87
- @ohai.stub!(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
78
+ @stdout = <<-LSB_RELEASE
79
+ LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
80
+ Distributor ID: CentOS
81
+ Description: CentOS release 5.4 (Final)
82
+ Release: 5.4
83
+ Codename: Final
84
+ LSB_RELEASE
85
+ @plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
88
86
  end
89
87
 
90
88
  it "should set lsb[:id]" do
91
- @ohai._require_plugin("linux::lsb")
92
- @ohai[:lsb][:id].should == "CentOS"
89
+ @plugin.run
90
+ @plugin[:lsb][:id].should == "CentOS"
93
91
  end
94
92
 
95
93
  it "should set lsb[:release]" do
96
- @ohai._require_plugin("linux::lsb")
97
- @ohai[:lsb][:release].should == "5.4"
94
+ @plugin.run
95
+ @plugin[:lsb][:release].should == "5.4"
98
96
  end
99
97
 
100
98
  it "should set lsb[:codename]" do
101
- @ohai._require_plugin("linux::lsb")
102
- @ohai[:lsb][:codename].should == "Final"
99
+ @plugin.run
100
+ @plugin[:lsb][:codename].should == "Final"
103
101
  end
104
102
 
105
103
  it "should set lsb[:description]" do
106
- @ohai._require_plugin("linux::lsb")
107
- @ohai[:lsb][:description].should == "CentOS release 5.4 (Final)"
104
+ @plugin.run
105
+ @plugin[:lsb][:description].should == "CentOS release 5.4 (Final)"
108
106
  end
109
107
  end
110
108
 
111
109
  describe "on Fedora 14 correctly" do
112
110
  before(:each) do
113
- @stdout.stub!(:each).
114
- and_yield("LSB Version: :core-4.0-ia32:core-4.0-noarch").
115
- and_yield("Distributor ID: Fedora").
116
- and_yield("Description: Fedora release 14 (Laughlin)").
117
- and_yield("Release: 14").
118
- and_yield("Codename: Laughlin")
119
-
120
- @ohai.stub!(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
111
+ @stdout = <<-LSB_RELEASE
112
+ LSB Version: :core-4.0-ia32:core-4.0-noarch
113
+ Distributor ID: Fedora
114
+ Description: Fedora release 14 (Laughlin)
115
+ Release: 14
116
+ Codename: Laughlin
117
+ LSB_RELEASE
118
+ @plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
121
119
  end
122
120
 
123
121
  it "should set lsb[:id]" do
124
- @ohai._require_plugin("linux::lsb")
125
- @ohai[:lsb][:id].should == "Fedora"
122
+ @plugin.run
123
+ @plugin[:lsb][:id].should == "Fedora"
126
124
  end
127
125
 
128
126
  it "should set lsb[:release]" do
129
- @ohai._require_plugin("linux::lsb")
130
- @ohai[:lsb][:release].should == "14"
127
+ @plugin.run
128
+ @plugin[:lsb][:release].should == "14"
131
129
  end
132
130
 
133
131
  it "should set lsb[:codename]" do
134
- @ohai._require_plugin("linux::lsb")
135
- @ohai[:lsb][:codename].should == "Laughlin"
132
+ @plugin.run
133
+ @plugin[:lsb][:codename].should == "Laughlin"
136
134
  end
137
135
 
138
136
  it "should set lsb[:description]" do
139
- @ohai._require_plugin("linux::lsb")
140
- @ohai[:lsb][:description].should == "Fedora release 14 (Laughlin)"
137
+ @plugin.run
138
+ @plugin[:lsb][:description].should == "Fedora release 14 (Laughlin)"
141
139
  end
142
140
  end
143
141
  end
144
142
 
145
143
  it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
146
- File.stub!(:exists?).with("/etc/lsb-release").and_return(false)
147
- File.stub!(:exists?).with("/usr/bin/lsb_release").and_return(false)
148
- @ohai.attribute?(:lsb).should be(false)
144
+ File.stub(:exists?).with("/etc/lsb-release").and_return(false)
145
+ File.stub(:exists?).with("/usr/bin/lsb_release").and_return(false)
146
+ @plugin.attribute?(:lsb).should be(false)
149
147
  end
150
148
  end
@@ -25,28 +25,17 @@ rescue LoadError => e
25
25
  raise e
26
26
  end
27
27
 
28
- def prepare_data
29
- @ifconfig_lines = @linux_ifconfig.split("\n")
30
- @route_lines = @linux_route_n.split("\n")
31
- @arp_lines = @linux_arp_an.split("\n")
32
- @ipaddr_lines = @linux_ip_addr.split("\n")
33
- @iplink_lines = @linux_ip_link_s_d.split("\n")
34
- @ipneighbor_lines = @linux_ip_neighbor_show.split("\n")
35
- @ipneighbor_lines_inet6 = @linux_ip_inet6_neighbor_show.split("\n")
36
- @ip_route_lines = @linux_ip_route.split("\n")
37
- @ip_route_inet6_lines = @linux_ip_route_inet6.split("\n")
38
- end
39
-
40
28
  def do_stubs
41
- @ohai.stub!(:from).with("route -n \| grep -m 1 ^0.0.0.0").and_return(@route_lines.last)
42
- @ohai.stub!(:popen4).with("ifconfig -a").and_yield(nil, @stdin_ifconfig, @ifconfig_lines, nil)
43
- @ohai.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil)
44
- @ohai.stub!(:popen4).with("ip -f inet neigh show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil)
45
- @ohai.stub!(:popen4).with("ip -f inet6 neigh show").and_yield(nil, @stdin_ipneighbor_inet6, @ipneighbor_lines_inet6, nil)
46
- @ohai.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil)
47
- @ohai.stub!(:popen4).with("ip -d -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil)
48
- @ohai.stub!(:popen4).with("ip -o -f inet route show").and_yield(nil, @stdin_ip_route, @ip_route_lines, nil)
49
- @ohai.stub!(:popen4).with("ip -o -f inet6 route show").and_yield(nil, @stdin_ip_route_inet6, @ip_route_inet6_lines, nil)
29
+ @plugin.stub(:collect_os).and_return(:linux)
30
+ @plugin.stub(:shell_out).with("ip addr").and_return(mock_shell_out(0, @linux_ip_addr, ""))
31
+ @plugin.stub(:shell_out).with("ip -d -s link").and_return(mock_shell_out(0, @linux_ip_link_s_d, ""))
32
+ @plugin.stub(:shell_out).with("ip -f inet neigh show").and_return(mock_shell_out(0, @linux_ip_neighbor_show, ""))
33
+ @plugin.stub(:shell_out).with("ip -f inet6 neigh show").and_return(mock_shell_out(0, @linux_ip_inet6_neighbor_show, ""))
34
+ @plugin.stub(:shell_out).with("ip -f inet route show").and_return(mock_shell_out(0, @linux_ip_route, ""))
35
+ @plugin.stub(:shell_out).with("ip -f inet6 route show").and_return(mock_shell_out(0, @linux_ip_route_inet6, ""))
36
+ @plugin.stub(:shell_out).with("route -n").and_return(mock_shell_out(0, @linux_route_n, ""))
37
+ @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @linux_ifconfig, ""))
38
+ @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @linux_arp_an, ""))
50
39
  end
51
40
 
52
41
  describe Ohai::System, "Linux Network Plugin" do
@@ -256,7 +245,6 @@ NEIGHBOR_SHOW
256
245
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
257
246
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
258
247
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
259
- 10.5.4.0/24 \\ nexthop via 10.5.4.1 dev eth0 weight 1\\ nexthop via 10.5.4.2 dev eth0 weight 1
260
248
  default via 10.116.201.1 dev eth0
261
249
  IP_ROUTE_SCOPE
262
250
 
@@ -267,208 +255,192 @@ fe80::/64 dev eth0.11 proto kernel metric 256
267
255
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
268
256
  IP_ROUTE_SCOPE
269
257
 
270
- @stdin_ifconfig = StringIO.new
271
- @stdin_arp = StringIO.new
272
- @stdin_ipaddr = StringIO.new
273
- @stdin_iplink = StringIO.new
274
- @stdin_ipneighbor = StringIO.new
275
- @stdin_ipneighbor_inet6 = StringIO.new
276
- @stdin_ip_route = StringIO.new
277
- @stdin_ip_route_inet6 = StringIO.new
278
-
279
- prepare_data
280
-
281
- @ohai = Ohai::System.new
282
- @ohai.stub!(:require_plugin).and_return(true)
283
-
284
- @ohai.stub(:popen4).with("ifconfig -a")
285
- @ohai.stub(:popen4).with("arp -an")
286
-
287
- Ohai::Log.should_receive(:warn).with(/unable to detect/).exactly(3).times
288
- @ohai._require_plugin("network")
258
+ @plugin = get_plugin("linux/network")
259
+ @plugin.stub(:shell_out).with("ifconfig -a").and_return([0, @linux_ifconfig, ""])
260
+ @plugin.stub(:shell_out).with("arp -an").and_return([0, @linux_arp_an, ""])
289
261
  end
290
262
 
291
263
  ["ifconfig","iproute2"].each do |network_method|
292
264
 
293
265
  describe "gathering IP layer address info via #{network_method}" do
294
266
  before do
295
- File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
267
+ File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
296
268
  do_stubs
297
269
  end
298
270
 
299
271
  it "completes the run" do
300
272
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
301
- @ohai._require_plugin("linux::network")
302
- @ohai['network'].should_not be_nil
273
+ @plugin.run
274
+ @plugin['network'].should_not be_nil
303
275
  end
304
276
 
305
277
  it "detects the interfaces" do
306
- @ohai._require_plugin("linux::network")
307
- @ohai['network']['interfaces'].keys.sort.should == ["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "foo:veth0@eth0", "lo", "tun0", "venet0", "venet0:0"]
278
+ @plugin.run
279
+ @plugin['network']['interfaces'].keys.sort.should == ["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "foo:veth0@eth0", "lo", "tun0", "venet0", "venet0:0"]
308
280
  end
309
281
 
310
282
  it "detects the ipv4 addresses of the ethernet interface" do
311
- @ohai._require_plugin("linux::network")
312
- @ohai['network']['interfaces']['eth0']['addresses'].keys.should include('10.116.201.76')
313
- @ohai['network']['interfaces']['eth0']['addresses']['10.116.201.76']['netmask'].should == '255.255.255.0'
314
- @ohai['network']['interfaces']['eth0']['addresses']['10.116.201.76']['broadcast'].should == '10.116.201.255'
315
- @ohai['network']['interfaces']['eth0']['addresses']['10.116.201.76']['family'].should == 'inet'
283
+ @plugin.run
284
+ @plugin['network']['interfaces']['eth0']['addresses'].keys.should include('10.116.201.76')
285
+ @plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['netmask'].should == '255.255.255.0'
286
+ @plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['broadcast'].should == '10.116.201.255'
287
+ @plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['family'].should == 'inet'
316
288
  end
317
289
 
318
290
  it "detects the ipv4 addresses of an ethernet subinterface" do
319
- @ohai._require_plugin("linux::network")
320
- @ohai['network']['interfaces']['eth0.11']['addresses'].keys.should include('192.168.0.16')
321
- @ohai['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['netmask'].should == '255.255.255.0'
322
- @ohai['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['broadcast'].should == '192.168.0.255'
323
- @ohai['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['family'].should == 'inet'
291
+ @plugin.run
292
+ @plugin['network']['interfaces']['eth0.11']['addresses'].keys.should include('192.168.0.16')
293
+ @plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['netmask'].should == '255.255.255.0'
294
+ @plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['broadcast'].should == '192.168.0.255'
295
+ @plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['family'].should == 'inet'
324
296
  end
325
297
 
326
298
  it "detects the ipv6 addresses of the ethernet interface" do
327
- @ohai._require_plugin("linux::network")
328
- @ohai['network']['interfaces']['eth0']['addresses'].keys.should include('fe80::1031:3dff:fe02:bea2')
329
- @ohai['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['scope'].should == 'Link'
330
- @ohai['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['prefixlen'].should == '64'
331
- @ohai['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['family'].should == 'inet6'
299
+ @plugin.run
300
+ @plugin['network']['interfaces']['eth0']['addresses'].keys.should include('fe80::1031:3dff:fe02:bea2')
301
+ @plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['scope'].should == 'Link'
302
+ @plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['prefixlen'].should == '64'
303
+ @plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['family'].should == 'inet6'
332
304
  end
333
305
 
334
306
  it "detects the ipv6 addresses of an ethernet subinterface" do
335
- @ohai._require_plugin("linux::network")
307
+ @plugin.run
336
308
  %w[ 1111:2222:3333:4444::2 1111:2222:3333:4444::3 ].each do |addr|
337
- @ohai['network']['interfaces']['eth0.11']['addresses'].keys.should include(addr)
338
- @ohai['network']['interfaces']['eth0.11']['addresses'][addr]['scope'].should == 'Global'
339
- @ohai['network']['interfaces']['eth0.11']['addresses'][addr]['prefixlen'].should == '64'
340
- @ohai['network']['interfaces']['eth0.11']['addresses'][addr]['family'].should == 'inet6'
309
+ @plugin['network']['interfaces']['eth0.11']['addresses'].keys.should include(addr)
310
+ @plugin['network']['interfaces']['eth0.11']['addresses'][addr]['scope'].should == 'Global'
311
+ @plugin['network']['interfaces']['eth0.11']['addresses'][addr]['prefixlen'].should == '64'
312
+ @plugin['network']['interfaces']['eth0.11']['addresses'][addr]['family'].should == 'inet6'
341
313
  end
342
314
  end
343
315
 
344
316
  it "detects the mac addresses of the ethernet interface" do
345
- @ohai._require_plugin("linux::network")
346
- @ohai['network']['interfaces']['eth0']['addresses'].keys.should include('12:31:3D:02:BE:A2')
347
- @ohai['network']['interfaces']['eth0']['addresses']['12:31:3D:02:BE:A2']['family'].should == 'lladdr'
317
+ @plugin.run
318
+ @plugin['network']['interfaces']['eth0']['addresses'].keys.should include('12:31:3D:02:BE:A2')
319
+ @plugin['network']['interfaces']['eth0']['addresses']['12:31:3D:02:BE:A2']['family'].should == 'lladdr'
348
320
  end
349
321
 
350
322
  it "detects the encapsulation type of the ethernet interface" do
351
- @ohai._require_plugin("linux::network")
352
- @ohai['network']['interfaces']['eth0']['encapsulation'].should == 'Ethernet'
323
+ @plugin.run
324
+ @plugin['network']['interfaces']['eth0']['encapsulation'].should == 'Ethernet'
353
325
  end
354
326
 
355
327
  it "detects the flags of the ethernet interface" do
356
- @ohai._require_plugin("linux::network")
328
+ @plugin.run
357
329
  if network_method == "ifconfig"
358
- @ohai['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','MULTICAST','RUNNING','UP']
330
+ @plugin['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','MULTICAST','RUNNING','UP']
359
331
  else
360
- @ohai['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','LOWER_UP','MULTICAST','UP']
332
+ @plugin['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','LOWER_UP','MULTICAST','UP']
361
333
  end
362
334
  end
363
335
 
364
336
  it "detects the number of the ethernet interface" do
365
- @ohai._require_plugin("linux::network")
366
- @ohai['network']['interfaces']['eth0']['number'].should == "0"
337
+ @plugin.run
338
+ @plugin['network']['interfaces']['eth0']['number'].should == "0"
367
339
  end
368
340
 
369
341
  it "detects the mtu of the ethernet interface" do
370
- @ohai._require_plugin("linux::network")
371
- @ohai['network']['interfaces']['eth0']['mtu'].should == "1500"
342
+ @plugin.run
343
+ @plugin['network']['interfaces']['eth0']['mtu'].should == "1500"
372
344
  end
373
345
 
374
346
  it "detects the ipv4 addresses of the loopback interface" do
375
- @ohai._require_plugin("linux::network")
376
- @ohai['network']['interfaces']['lo']['addresses'].keys.should include('127.0.0.1')
377
- @ohai['network']['interfaces']['lo']['addresses']['127.0.0.1']['netmask'].should == '255.0.0.0'
378
- @ohai['network']['interfaces']['lo']['addresses']['127.0.0.1']['family'].should == 'inet'
347
+ @plugin.run
348
+ @plugin['network']['interfaces']['lo']['addresses'].keys.should include('127.0.0.1')
349
+ @plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['netmask'].should == '255.0.0.0'
350
+ @plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['family'].should == 'inet'
379
351
  end
380
352
 
381
353
  it "detects the ipv6 addresses of the loopback interface" do
382
- @ohai._require_plugin("linux::network")
383
- @ohai['network']['interfaces']['lo']['addresses'].keys.should include('::1')
384
- @ohai['network']['interfaces']['lo']['addresses']['::1']['scope'].should == 'Node'
385
- @ohai['network']['interfaces']['lo']['addresses']['::1']['prefixlen'].should == '128'
386
- @ohai['network']['interfaces']['lo']['addresses']['::1']['family'].should == 'inet6'
354
+ @plugin.run
355
+ @plugin['network']['interfaces']['lo']['addresses'].keys.should include('::1')
356
+ @plugin['network']['interfaces']['lo']['addresses']['::1']['scope'].should == 'Node'
357
+ @plugin['network']['interfaces']['lo']['addresses']['::1']['prefixlen'].should == '128'
358
+ @plugin['network']['interfaces']['lo']['addresses']['::1']['family'].should == 'inet6'
387
359
  end
388
360
 
389
361
  it "detects the encapsulation type of the loopback interface" do
390
- @ohai._require_plugin("linux::network")
391
- @ohai['network']['interfaces']['lo']['encapsulation'].should == 'Loopback'
362
+ @plugin.run
363
+ @plugin['network']['interfaces']['lo']['encapsulation'].should == 'Loopback'
392
364
  end
393
365
 
394
366
  it "detects the flags of the ethernet interface" do
395
- @ohai._require_plugin("linux::network")
367
+ @plugin.run
396
368
  if network_method == "ifconfig"
397
- @ohai['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','RUNNING','UP']
369
+ @plugin['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','RUNNING','UP']
398
370
  else
399
- @ohai['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','LOWER_UP','UP']
371
+ @plugin['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','LOWER_UP','UP']
400
372
  end
401
373
  end
402
374
 
403
375
 
404
376
  it "detects the mtu of the loopback interface" do
405
- @ohai._require_plugin("linux::network")
406
- @ohai['network']['interfaces']['lo']['mtu'].should == "16436"
377
+ @plugin.run
378
+ @plugin['network']['interfaces']['lo']['mtu'].should == "16436"
407
379
  end
408
380
 
409
381
  it "detects the arp entries" do
410
- @ohai._require_plugin("linux::network")
411
- @ohai['network']['interfaces']['eth0']['arp']['10.116.201.1'].should == 'fe:ff:ff:ff:ff:ff'
382
+ @plugin.run
383
+ @plugin['network']['interfaces']['eth0']['arp']['10.116.201.1'].should == 'fe:ff:ff:ff:ff:ff'
412
384
  end
413
385
 
414
386
  end
415
387
 
416
388
  describe "gathering interface counters via #{network_method}" do
417
389
  before do
418
- File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
390
+ File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
419
391
  do_stubs
420
- @ohai._require_plugin("linux::network")
392
+ @plugin.run
421
393
  end
422
394
 
423
395
  it "detects the ethernet counters" do
424
- @ohai['counters']['network']['interfaces']['eth0']['tx']['bytes'].should == "691785313"
425
- @ohai['counters']['network']['interfaces']['eth0']['tx']['packets'].should == "1919690"
426
- @ohai['counters']['network']['interfaces']['eth0']['tx']['collisions'].should == "0"
427
- @ohai['counters']['network']['interfaces']['eth0']['tx']['queuelen'].should == "1000"
428
- @ohai['counters']['network']['interfaces']['eth0']['tx']['errors'].should == "0"
429
- @ohai['counters']['network']['interfaces']['eth0']['tx']['carrier'].should == "0"
430
- @ohai['counters']['network']['interfaces']['eth0']['tx']['drop'].should == "0"
396
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['bytes'].should == "691785313"
397
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['packets'].should == "1919690"
398
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['collisions'].should == "0"
399
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['queuelen'].should == "1000"
400
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['errors'].should == "0"
401
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['carrier'].should == "0"
402
+ @plugin['counters']['network']['interfaces']['eth0']['tx']['drop'].should == "0"
431
403
 
432
- @ohai['counters']['network']['interfaces']['eth0']['rx']['bytes'].should == "1392844460"
433
- @ohai['counters']['network']['interfaces']['eth0']['rx']['packets'].should == "2659966"
434
- @ohai['counters']['network']['interfaces']['eth0']['rx']['errors'].should == "0"
435
- @ohai['counters']['network']['interfaces']['eth0']['rx']['overrun'].should == "0"
436
- @ohai['counters']['network']['interfaces']['eth0']['rx']['drop'].should == "0"
404
+ @plugin['counters']['network']['interfaces']['eth0']['rx']['bytes'].should == "1392844460"
405
+ @plugin['counters']['network']['interfaces']['eth0']['rx']['packets'].should == "2659966"
406
+ @plugin['counters']['network']['interfaces']['eth0']['rx']['errors'].should == "0"
407
+ @plugin['counters']['network']['interfaces']['eth0']['rx']['overrun'].should == "0"
408
+ @plugin['counters']['network']['interfaces']['eth0']['rx']['drop'].should == "0"
437
409
  end
438
410
 
439
411
  it "detects the loopback counters" do
440
- @ohai['counters']['network']['interfaces']['lo']['tx']['bytes'].should == "35224"
441
- @ohai['counters']['network']['interfaces']['lo']['tx']['packets'].should == "524"
442
- @ohai['counters']['network']['interfaces']['lo']['tx']['collisions'].should == "0"
443
- @ohai['counters']['network']['interfaces']['lo']['tx']['errors'].should == "0"
444
- @ohai['counters']['network']['interfaces']['lo']['tx']['carrier'].should == "0"
445
- @ohai['counters']['network']['interfaces']['lo']['tx']['drop'].should == "0"
446
-
447
- @ohai['counters']['network']['interfaces']['lo']['rx']['bytes'].should == "35224"
448
- @ohai['counters']['network']['interfaces']['lo']['rx']['packets'].should == "524"
449
- @ohai['counters']['network']['interfaces']['lo']['rx']['errors'].should == "0"
450
- @ohai['counters']['network']['interfaces']['lo']['rx']['overrun'].should == "0"
451
- @ohai['counters']['network']['interfaces']['lo']['rx']['drop'].should == "0"
412
+ @plugin['counters']['network']['interfaces']['lo']['tx']['bytes'].should == "35224"
413
+ @plugin['counters']['network']['interfaces']['lo']['tx']['packets'].should == "524"
414
+ @plugin['counters']['network']['interfaces']['lo']['tx']['collisions'].should == "0"
415
+ @plugin['counters']['network']['interfaces']['lo']['tx']['errors'].should == "0"
416
+ @plugin['counters']['network']['interfaces']['lo']['tx']['carrier'].should == "0"
417
+ @plugin['counters']['network']['interfaces']['lo']['tx']['drop'].should == "0"
418
+
419
+ @plugin['counters']['network']['interfaces']['lo']['rx']['bytes'].should == "35224"
420
+ @plugin['counters']['network']['interfaces']['lo']['rx']['packets'].should == "524"
421
+ @plugin['counters']['network']['interfaces']['lo']['rx']['errors'].should == "0"
422
+ @plugin['counters']['network']['interfaces']['lo']['rx']['overrun'].should == "0"
423
+ @plugin['counters']['network']['interfaces']['lo']['rx']['drop'].should == "0"
452
424
  end
453
425
  end
454
426
 
455
427
  describe "setting the node's default IP address attribute with #{network_method}" do
456
428
  before do
457
- File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
429
+ File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
458
430
  do_stubs
459
431
  end
460
432
 
461
433
  describe "without a subinterface" do
462
434
  before do
463
- @ohai._require_plugin("linux::network")
435
+ @plugin.run
464
436
  end
465
437
 
466
438
  it "finds the default interface by asking which iface has the default route" do
467
- @ohai['network']['default_interface'].should == 'eth0'
439
+ @plugin['network']['default_interface'].should == 'eth0'
468
440
  end
469
441
 
470
442
  it "finds the default gateway by asking which iface has the default route" do
471
- @ohai['network']['default_gateway'].should == '10.116.201.1'
443
+ @plugin['network']['default_gateway'].should == '10.116.201.1'
472
444
  end
473
445
  end
474
446
 
@@ -484,18 +456,17 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
484
456
  10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
485
457
  0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
486
458
  ROUTE_N
487
- prepare_data
488
459
  do_stubs
489
460
 
490
- @ohai._require_plugin("linux::network")
461
+ @plugin.run
491
462
  end
492
463
 
493
464
  it "finds the default interface by asking which iface has the default route" do
494
- @ohai['network']['default_interface'].should == 'eth0'
465
+ @plugin['network']['default_interface'].should == 'eth0'
495
466
  end
496
467
 
497
468
  it "finds the default interface by asking which iface has the default route" do
498
- @ohai['network']['default_gateway'].should == '0.0.0.0'
469
+ @plugin['network']['default_gateway'].should == '0.0.0.0'
499
470
  end
500
471
  end
501
472
 
@@ -512,18 +483,17 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
512
483
  0.0.0.0 192.168.0.15 0.0.0.0 UG 0 0 0 eth0.11
513
484
  ROUTE_N
514
485
 
515
- prepare_data
516
486
  do_stubs
517
487
 
518
- @ohai._require_plugin("linux::network")
488
+ @plugin.run
519
489
  end
520
490
 
521
491
  it "finds the default interface by asking which iface has the default route" do
522
- @ohai['network']["default_interface"].should == 'eth0.11'
492
+ @plugin['network']["default_interface"].should == 'eth0.11'
523
493
  end
524
494
 
525
495
  it "finds the default interface by asking which iface has the default route" do
526
- @ohai['network']["default_gateway"].should == '192.168.0.15'
496
+ @plugin['network']["default_gateway"].should == '192.168.0.15'
527
497
  end
528
498
  end
529
499
  end
@@ -531,82 +501,80 @@ ROUTE_N
531
501
 
532
502
  describe "for newer network features using iproute2 only" do
533
503
  before do
534
- File.stub!(:exist?).with("/sbin/ip").and_return(true) # iproute2 only
504
+ File.stub(:exist?).with("/sbin/ip").and_return(true) # iproute2 only
535
505
  do_stubs
536
506
  end
537
507
 
538
508
  it "completes the run" do
539
509
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
540
- @ohai._require_plugin("linux::network")
541
- @ohai['network'].should_not be_nil
510
+ @plugin.run
511
+ @plugin['network'].should_not be_nil
542
512
  end
543
513
 
544
514
  it "finds the default inet6 interface if there's a inet6 default route" do
545
- @ohai._require_plugin("linux::network")
546
- @ohai['network']['default_inet6_interface'].should == 'eth0.11'
515
+ @plugin.run
516
+ @plugin['network']['default_inet6_interface'].should == 'eth0.11'
547
517
  end
548
518
 
549
519
  it "finds the default inet6 gateway if there's a inet6 default route" do
550
- @ohai._require_plugin("linux::network")
551
- @ohai['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::1'
520
+ @plugin.run
521
+ @plugin['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::1'
552
522
  end
553
523
 
554
524
  it "finds inet6 neighbours" do
555
- @ohai._require_plugin("linux::network")
556
- @ohai['network']['interfaces']['eth0.11']['neighbour_inet6']['1111:2222:3333:4444::1'].should == '00:1c:0e:12:34:56'
525
+ @plugin.run
526
+ @plugin['network']['interfaces']['eth0.11']['neighbour_inet6']['1111:2222:3333:4444::1'].should == '00:1c:0e:12:34:56'
557
527
  end
558
528
 
559
529
  it "detects the ipv4 addresses of an ethernet interface with a crazy name" do
560
- @ohai._require_plugin("linux::network")
561
- @ohai['network']['interfaces']['foo:veth0@eth0']['addresses'].keys.should include('192.168.212.2')
562
- @ohai['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['netmask'].should == '255.255.255.0'
563
- @ohai['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['family'].should == 'inet'
530
+ @plugin.run
531
+ @plugin['network']['interfaces']['foo:veth0@eth0']['addresses'].keys.should include('192.168.212.2')
532
+ @plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['netmask'].should == '255.255.255.0'
533
+ @plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['family'].should == 'inet'
564
534
  end
565
535
 
566
536
  it "generates a fake interface for ip aliases for backward compatibility" do
567
- @ohai._require_plugin("linux::network")
568
- @ohai['network']['interfaces']['eth0:5']['addresses'].keys.should include('192.168.5.1')
569
- @ohai['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['netmask'].should == '255.255.255.0'
570
- @ohai['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['family'].should == 'inet'
537
+ @plugin.run
538
+ @plugin['network']['interfaces']['eth0:5']['addresses'].keys.should include('192.168.5.1')
539
+ @plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['netmask'].should == '255.255.255.0'
540
+ @plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['family'].should == 'inet'
571
541
  end
572
542
 
573
543
  it "adds the vlan information of an interface" do
574
- @ohai._require_plugin("linux::network")
575
- @ohai['network']['interfaces']['eth0.11']['vlan']['id'].should == '11'
576
- @ohai['network']['interfaces']['eth0.11']['vlan']['flags'].should == [ 'REORDER_HDR' ]
544
+ @plugin.run
545
+ @plugin['network']['interfaces']['eth0.11']['vlan']['id'].should == '11'
546
+ @plugin['network']['interfaces']['eth0.11']['vlan']['flags'].should == [ 'REORDER_HDR' ]
577
547
  end
578
548
 
579
549
  it "adds the state of an interface" do
580
- @ohai._require_plugin("linux::network")
581
- @ohai['network']['interfaces']['eth0.11']['state'].should == 'up'
550
+ @plugin.run
551
+ @plugin['network']['interfaces']['eth0.11']['state'].should == 'up'
582
552
  end
583
553
 
584
554
  describe "when dealing with routes" do
585
555
  it "adds routes" do
586
- @ohai._require_plugin("linux::network")
587
- @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family =>"inet" )
588
- @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.1")
589
- @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.2")
590
- @ohai['network']['interfaces']['foo:veth0@eth0']['routes'].should include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family =>"inet" )
591
- @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
592
- @ohai['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
593
- @ohai['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
556
+ @plugin.run
557
+ @plugin['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family =>"inet" )
558
+ @plugin['network']['interfaces']['foo:veth0@eth0']['routes'].should include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family =>"inet" )
559
+ @plugin['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
560
+ @plugin['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
561
+ @plugin['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
594
562
  end
595
563
 
596
564
  describe "when there isn't a source field in route entries " do
597
565
  it "doesn't set ipaddress" do
598
- @ohai._require_plugin("linux::network")
599
- @ohai['ipaddress'].should be nil
566
+ @plugin.run
567
+ @plugin['ipaddress'].should be nil
600
568
  end
601
569
 
602
570
  it "doesn't set macaddress" do
603
- @ohai._require_plugin("linux::network")
604
- @ohai['macaddress'].should be nil
571
+ @plugin.run
572
+ @plugin['macaddress'].should be nil
605
573
  end
606
574
 
607
575
  it "doesn't set ip6address" do
608
- @ohai._require_plugin("linux::network")
609
- @ohai['ip6address'].should be nil
576
+ @plugin.run
577
+ @plugin['ip6address'].should be nil
610
578
  end
611
579
  end
612
580
 
@@ -628,24 +596,23 @@ fe80::/64 dev eth0.11 proto kernel metric 256
628
596
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
629
597
  IP_ROUTE_SCOPE
630
598
 
631
- prepare_data
632
599
  do_stubs
633
600
  end
634
601
 
635
602
  it "completes the run" do
636
603
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
637
- @ohai._require_plugin("linux::network")
638
- @ohai['network'].should_not be_nil
604
+ @plugin.run
605
+ @plugin['network'].should_not be_nil
639
606
  end
640
607
 
641
608
  it "sets ipaddress" do
642
- @ohai._require_plugin("linux::network")
643
- @ohai['ipaddress'].should == "10.116.201.76"
609
+ @plugin.run
610
+ @plugin['ipaddress'].should == "10.116.201.76"
644
611
  end
645
612
 
646
613
  it "sets ip6address" do
647
- @ohai._require_plugin("linux::network")
648
- @ohai['ip6address'].should == "1111:2222:3333:4444::3"
614
+ @plugin.run
615
+ @plugin['ip6address'].should == "1111:2222:3333:4444::3"
649
616
  end
650
617
  end
651
618
 
@@ -669,26 +636,25 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
669
636
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023
670
637
  IP_ROUTE_SCOPE
671
638
 
672
- prepare_data
673
639
  do_stubs
674
640
  end
675
641
 
676
642
  it "completes the run" do
677
643
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
678
- @ohai._require_plugin("linux::network")
679
- @ohai['network'].should_not be_nil
644
+ @plugin.run
645
+ @plugin['network'].should_not be_nil
680
646
  end
681
647
 
682
648
  it "sets default ipv4 interface and gateway" do
683
- @ohai._require_plugin("linux::network")
684
- @ohai['network']['default_interface'].should == 'eth0'
685
- @ohai['network']['default_gateway'].should == '10.116.201.254'
649
+ @plugin.run
650
+ @plugin['network']['default_interface'].should == 'eth0'
651
+ @plugin['network']['default_gateway'].should == '10.116.201.254'
686
652
  end
687
653
 
688
654
  it "sets default ipv6 interface and gateway" do
689
- @ohai._require_plugin("linux::network")
690
- @ohai['network']['default_inet6_interface'].should == 'eth0.11'
691
- @ohai['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::ffff'
655
+ @plugin.run
656
+ @plugin['network']['default_inet6_interface'].should == 'eth0.11'
657
+ @plugin['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::ffff'
692
658
  end
693
659
  end
694
660
 
@@ -712,24 +678,23 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
712
678
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:3333:4444::2
713
679
  IP_ROUTE_SCOPE
714
680
 
715
- prepare_data
716
681
  do_stubs
717
682
  end
718
683
 
719
684
  it "completes the run" do
720
685
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
721
- @ohai._require_plugin("linux::network")
722
- @ohai['network'].should_not be_nil
686
+ @plugin.run
687
+ @plugin['network'].should_not be_nil
723
688
  end
724
689
 
725
690
  it "sets ipaddress" do
726
- @ohai._require_plugin("linux::network")
727
- @ohai["ipaddress"].should == "10.116.201.74"
691
+ @plugin.run
692
+ @plugin["ipaddress"].should == "10.116.201.74"
728
693
  end
729
694
 
730
695
  it "sets ip6address" do
731
- @ohai._require_plugin("linux::network")
732
- @ohai["ip6address"].should == "1111:2222:3333:4444::2"
696
+ @plugin.run
697
+ @plugin["ip6address"].should == "1111:2222:3333:4444::2"
733
698
  end
734
699
  end
735
700
 
@@ -751,25 +716,24 @@ fe80::/64 dev eth0.11 proto kernel metric 256
751
716
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
752
717
  IP_ROUTE_SCOPE
753
718
 
754
- prepare_data
755
719
  do_stubs
756
720
  end
757
721
 
758
722
  it "completes the run" do
759
723
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
760
- @ohai._require_plugin("linux::network")
761
- @ohai['network'].should_not be_nil
724
+ @plugin.run
725
+ @plugin['network'].should_not be_nil
762
726
  end
763
727
 
764
728
  it "sets ipaddress" do
765
- @ohai._require_plugin("linux::network")
766
- @ohai['ipaddress'].should == "10.116.201.76"
729
+ @plugin.run
730
+ @plugin['ipaddress'].should == "10.116.201.76"
767
731
  end
768
732
 
769
733
  describe "when about to set macaddress" do
770
734
  it "sets macaddress" do
771
- @ohai._require_plugin("linux::network")
772
- @ohai['macaddress'].should == "12:31:3D:02:BE:A2"
735
+ @plugin.run
736
+ @plugin['macaddress'].should == "12:31:3D:02:BE:A2"
773
737
  end
774
738
 
775
739
  describe "when then interface has the NOARP flag" do
@@ -779,26 +743,25 @@ IP_ROUTE_SCOPE
779
743
  default via 172.16.19.1 dev tun0
780
744
  IP_ROUTE
781
745
 
782
- prepare_data
783
746
  do_stubs
784
747
  end
785
748
 
786
749
  it "completes the run" do
787
750
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
788
- @ohai._require_plugin("linux::network")
789
- @ohai['network'].should_not be_nil
751
+ @plugin.run
752
+ @plugin['network'].should_not be_nil
790
753
  end
791
754
 
792
755
  it "doesn't set macaddress" do
793
- @ohai._require_plugin("linux::network")
794
- @ohai['macaddress'].should be_nil
756
+ @plugin.run
757
+ @plugin['macaddress'].should be_nil
795
758
  end
796
759
  end
797
760
  end
798
761
 
799
762
  it "sets ip6address" do
800
- @ohai._require_plugin("linux::network")
801
- @ohai['ip6address'].should == "1111:2222:3333:4444::3"
763
+ @plugin.run
764
+ @plugin['ip6address'].should == "1111:2222:3333:4444::3"
802
765
  end
803
766
  end
804
767
 
@@ -808,19 +771,18 @@ IP_ROUTE
808
771
  default dev venet0 scope link
809
772
  IP_ROUTE
810
773
 
811
- prepare_data
812
774
  do_stubs
813
775
  end
814
776
 
815
777
  it "completes the run" do
816
778
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
817
- @ohai._require_plugin("linux::network")
818
- @ohai['network'].should_not be_nil
779
+ @plugin.run
780
+ @plugin['network'].should_not be_nil
819
781
  end
820
782
 
821
783
  it "doesn't set ipaddress" do
822
- @ohai._require_plugin("linux::network")
823
- @ohai['ipaddress'].should be_nil
784
+ @plugin.run
785
+ @plugin['ipaddress'].should be_nil
824
786
  end
825
787
  end
826
788
 
@@ -831,19 +793,18 @@ fe80::/64 dev eth0 proto kernel metric 256
831
793
  default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7 metric 1024
832
794
  IP_ROUTE_SCOPE
833
795
 
834
- prepare_data
835
796
  do_stubs
836
797
  end
837
798
 
838
799
  it "completes the run" do
839
800
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
840
- @ohai._require_plugin("linux::network")
841
- @ohai['network'].should_not be_nil
801
+ @plugin.run
802
+ @plugin['network'].should_not be_nil
842
803
  end
843
804
 
844
805
  it "doesn't set ip6address" do
845
- @ohai._require_plugin("linux::network")
846
- @ohai['ip6address'].should be_nil
806
+ @plugin.run
807
+ @plugin['ip6address'].should be_nil
847
808
  end
848
809
 
849
810
  end
@@ -864,24 +825,23 @@ fe80::/64 dev eth0.11 proto kernel metric 256
864
825
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
865
826
  IP_ROUTE
866
827
 
867
- prepare_data
868
828
  do_stubs
869
829
  end
870
830
 
871
831
  it "completes the run" do
872
832
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
873
- @ohai._require_plugin("linux::network")
874
- @ohai['network'].should_not be_nil
833
+ @plugin.run
834
+ @plugin['network'].should_not be_nil
875
835
  end
876
836
 
877
837
  it "doesn't set ipaddress" do
878
- @ohai._require_plugin("linux::network")
879
- @ohai['ipaddress'].should be_nil
838
+ @plugin.run
839
+ @plugin['ipaddress'].should be_nil
880
840
  end
881
841
 
882
842
  it "doesn't set ip6address" do
883
- @ohai._require_plugin("linux::network")
884
- @ohai['ip6address'].should be_nil
843
+ @plugin.run
844
+ @plugin['ip6address'].should be_nil
885
845
  end
886
846
  end
887
847
 
@@ -902,31 +862,30 @@ fe80::/64 dev eth0.11 proto kernel metric 256
902
862
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
903
863
  IP_ROUTE
904
864
 
905
- prepare_data
906
865
  do_stubs
907
866
  end
908
867
 
909
868
  it "completes the run" do
910
869
  Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
911
- @ohai._require_plugin("linux::network")
912
- @ohai['network'].should_not be_nil
870
+ @plugin.run
871
+ @plugin['network'].should_not be_nil
913
872
  end
914
873
 
915
874
  it "doesn't add bogus routes" do
916
- @ohai._require_plugin("linux::network")
917
- @ohai['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.116.201.0/26", :proto => "kernel", :family => "inet", :via => "10.116.201.39" )
918
- @ohai['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.118.19.0/26", :proto => "kernel", :family => "inet", :via => "10.118.19.39" )
919
- @ohai['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "1111:2222:3333:4444::/64", :family => "inet6", :metric => "1024" )
875
+ @plugin.run
876
+ @plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.116.201.0/26", :proto => "kernel", :family => "inet", :via => "10.116.201.39" )
877
+ @plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.118.19.0/26", :proto => "kernel", :family => "inet", :via => "10.118.19.39" )
878
+ @plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "1111:2222:3333:4444::/64", :family => "inet6", :metric => "1024" )
920
879
  end
921
880
 
922
881
  it "doesn't set ipaddress" do
923
- @ohai._require_plugin("linux::network")
924
- @ohai['ipaddress'].should be_nil
882
+ @plugin.run
883
+ @plugin['ipaddress'].should be_nil
925
884
  end
926
885
 
927
886
  it "doesn't set ip6address" do
928
- @ohai._require_plugin("linux::network")
929
- @ohai['ip6address'].should be_nil
887
+ @plugin.run
888
+ @plugin['ip6address'].should be_nil
930
889
  end
931
890
  end
932
891
 
@@ -936,14 +895,13 @@ IP_ROUTE
936
895
  @linux_ip_route = <<-IP_ROUTE
937
896
  192.168.122.0/24 dev virbr0 proto kernel src 192.168.122.1
938
897
  IP_ROUTE
939
- prepare_data
940
898
  do_stubs
941
899
  end
942
900
 
943
901
  it "logs a message and skips previously unseen interfaces in 'ip route show'" do
944
902
  Ohai::Log.should_receive(:debug).with("Skipping previously unseen interface from 'ip route show': virbr0").once
945
- Ohai::Log.should_receive(:debug).any_number_of_times # Catches the 'Loading plugin network' type messages
946
- @ohai._require_plugin("linux::network")
903
+ Ohai::Log.stub(:debug) # Catches the 'Loading plugin network' type messages
904
+ @plugin.run
947
905
  end
948
906
  end
949
907
  end