ohai 8.10.0 → 8.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Rakefile +13 -4
  4. data/bin/ohai +3 -4
  5. data/lib/ohai.rb +4 -4
  6. data/lib/ohai/application.rb +7 -6
  7. data/lib/ohai/common/dmi.rb +56 -56
  8. data/lib/ohai/config.rb +12 -8
  9. data/lib/ohai/dsl.rb +3 -3
  10. data/lib/ohai/dsl/plugin.rb +5 -5
  11. data/lib/ohai/dsl/plugin/versionvi.rb +0 -1
  12. data/lib/ohai/dsl/plugin/versionvii.rb +1 -0
  13. data/lib/ohai/hints.rb +1 -1
  14. data/lib/ohai/loader.rb +7 -7
  15. data/lib/ohai/log.rb +1 -1
  16. data/lib/ohai/mash.rb +3 -2
  17. data/lib/ohai/mixin/command.rb +25 -23
  18. data/lib/ohai/mixin/dmi_decode.rb +10 -10
  19. data/lib/ohai/mixin/ec2_metadata.rb +40 -39
  20. data/lib/ohai/mixin/gce_metadata.rb +9 -9
  21. data/lib/ohai/mixin/network_constants.rb +1 -1
  22. data/lib/ohai/mixin/os.rb +3 -3
  23. data/lib/ohai/mixin/seconds_to_human.rb +0 -2
  24. data/lib/ohai/mixin/softlayer_metadata.rb +10 -10
  25. data/lib/ohai/mixin/string.rb +2 -2
  26. data/lib/ohai/plugin_config.rb +1 -1
  27. data/lib/ohai/plugins/aix/cpu.rb +2 -2
  28. data/lib/ohai/plugins/aix/filesystem.rb +2 -2
  29. data/lib/ohai/plugins/aix/memory.rb +2 -2
  30. data/lib/ohai/plugins/aix/network.rb +9 -10
  31. data/lib/ohai/plugins/aix/os.rb +2 -2
  32. data/lib/ohai/plugins/aix/uptime.rb +3 -3
  33. data/lib/ohai/plugins/aix/virtualization.rb +23 -23
  34. data/lib/ohai/plugins/azure.rb +32 -5
  35. data/lib/ohai/plugins/bsd/virtualization.rb +22 -22
  36. data/lib/ohai/plugins/c.rb +3 -3
  37. data/lib/ohai/plugins/chef.rb +1 -1
  38. data/lib/ohai/plugins/cloud.rb +59 -60
  39. data/lib/ohai/plugins/cloud_v2.rb +37 -39
  40. data/lib/ohai/plugins/darwin/cpu.rb +1 -1
  41. data/lib/ohai/plugins/darwin/filesystem2.rb +5 -5
  42. data/lib/ohai/plugins/darwin/memory.rb +5 -6
  43. data/lib/ohai/plugins/darwin/network.rb +7 -7
  44. data/lib/ohai/plugins/darwin/system_profiler.rb +32 -33
  45. data/lib/ohai/plugins/darwin/virtualization.rb +9 -9
  46. data/lib/ohai/plugins/digital_ocean.rb +16 -16
  47. data/lib/ohai/plugins/dmi.rb +6 -6
  48. data/lib/ohai/plugins/dragonflybsd/cpu.rb +2 -2
  49. data/lib/ohai/plugins/dragonflybsd/memory.rb +0 -1
  50. data/lib/ohai/plugins/dragonflybsd/network.rb +4 -4
  51. data/lib/ohai/plugins/dragonflybsd/os.rb +1 -1
  52. data/lib/ohai/plugins/ec2.rb +39 -15
  53. data/lib/ohai/plugins/elixir.rb +1 -1
  54. data/lib/ohai/plugins/erlang.rb +3 -3
  55. data/lib/ohai/plugins/eucalyptus.rb +16 -12
  56. data/lib/ohai/plugins/freebsd/cpu.rb +2 -2
  57. data/lib/ohai/plugins/freebsd/memory.rb +0 -1
  58. data/lib/ohai/plugins/freebsd/network.rb +4 -4
  59. data/lib/ohai/plugins/freebsd/os.rb +1 -1
  60. data/lib/ohai/plugins/gce.rb +6 -6
  61. data/lib/ohai/plugins/hostname.rb +7 -7
  62. data/lib/ohai/plugins/init_package.rb +1 -1
  63. data/lib/ohai/plugins/ip_scopes.rb +9 -9
  64. data/lib/ohai/plugins/java.rb +1 -1
  65. data/lib/ohai/plugins/joyent.rb +7 -7
  66. data/lib/ohai/plugins/kernel.rb +8 -8
  67. data/lib/ohai/plugins/linode.rb +7 -4
  68. data/lib/ohai/plugins/linux/cpu.rb +5 -5
  69. data/lib/ohai/plugins/linux/filesystem.rb +16 -16
  70. data/lib/ohai/plugins/linux/filesystem2.rb +15 -15
  71. data/lib/ohai/plugins/linux/mdadm.rb +3 -3
  72. data/lib/ohai/plugins/linux/network.rb +85 -51
  73. data/lib/ohai/plugins/linux/platform.rb +24 -24
  74. data/lib/ohai/plugins/linux/virtualization.rb +8 -8
  75. data/lib/ohai/plugins/mono.rb +1 -1
  76. data/lib/ohai/plugins/netbsd/cpu.rb +1 -1
  77. data/lib/ohai/plugins/netbsd/network.rb +2 -2
  78. data/lib/ohai/plugins/network.rb +11 -11
  79. data/lib/ohai/plugins/network_listeners.rb +30 -26
  80. data/lib/ohai/plugins/ohai.rb +3 -3
  81. data/lib/ohai/plugins/openbsd/cpu.rb +4 -4
  82. data/lib/ohai/plugins/openbsd/memory.rb +4 -4
  83. data/lib/ohai/plugins/openbsd/network.rb +3 -3
  84. data/lib/ohai/plugins/openstack.rb +12 -12
  85. data/lib/ohai/plugins/os.rb +2 -2
  86. data/lib/ohai/plugins/packages.rb +22 -22
  87. data/lib/ohai/plugins/passwd.rb +4 -4
  88. data/lib/ohai/plugins/powershell.rb +9 -9
  89. data/lib/ohai/plugins/ps.rb +2 -2
  90. data/lib/ohai/plugins/python.rb +1 -1
  91. data/lib/ohai/plugins/rackspace.rb +13 -13
  92. data/lib/ohai/plugins/root_group.rb +4 -4
  93. data/lib/ohai/plugins/ruby.rb +6 -6
  94. data/lib/ohai/plugins/rust.rb +1 -1
  95. data/lib/ohai/plugins/sigar/cpu.rb +1 -1
  96. data/lib/ohai/plugins/sigar/filesystem.rb +1 -1
  97. data/lib/ohai/plugins/sigar/network.rb +13 -13
  98. data/lib/ohai/plugins/sigar/network_route.rb +34 -29
  99. data/lib/ohai/plugins/softlayer.rb +8 -7
  100. data/lib/ohai/plugins/solaris2/cpu.rb +19 -19
  101. data/lib/ohai/plugins/solaris2/dmi.rb +63 -63
  102. data/lib/ohai/plugins/solaris2/filesystem.rb +13 -13
  103. data/lib/ohai/plugins/solaris2/memory.rb +2 -2
  104. data/lib/ohai/plugins/solaris2/network.rb +5 -5
  105. data/lib/ohai/plugins/solaris2/virtualization.rb +18 -18
  106. data/lib/ohai/plugins/solaris2/zpools.rb +1 -1
  107. data/lib/ohai/plugins/ssh_host_key.rb +2 -2
  108. data/lib/ohai/plugins/uptime.rb +4 -5
  109. data/lib/ohai/plugins/virtualbox.rb +2 -2
  110. data/lib/ohai/plugins/virtualization.rb +17 -17
  111. data/lib/ohai/plugins/vmware.rb +2 -2
  112. data/lib/ohai/plugins/windows/cpu.rb +14 -14
  113. data/lib/ohai/plugins/windows/drivers.rb +8 -8
  114. data/lib/ohai/plugins/windows/filesystem.rb +4 -4
  115. data/lib/ohai/plugins/windows/memory.rb +1 -1
  116. data/lib/ohai/plugins/windows/network.rb +10 -10
  117. data/lib/ohai/plugins/windows/platform.rb +1 -2
  118. data/lib/ohai/plugins/windows/virtualization.rb +17 -17
  119. data/lib/ohai/provides_map.rb +7 -7
  120. data/lib/ohai/runner.rb +3 -3
  121. data/lib/ohai/system.rb +21 -20
  122. data/lib/ohai/util/file_helper.rb +1 -2
  123. data/lib/ohai/util/ip_helper.rb +4 -4
  124. data/lib/ohai/util/win32.rb +5 -5
  125. data/lib/ohai/util/win32/group_helper.rb +4 -5
  126. data/lib/ohai/version.rb +1 -1
  127. data/ohai.gemspec +7 -5
  128. data/spec/functional/application_spec.rb +23 -23
  129. data/spec/functional/loader_spec.rb +1 -1
  130. data/spec/functional/plugins/powershell_spec.rb +13 -13
  131. data/spec/functional/plugins/root_group_spec.rb +5 -5
  132. data/spec/ohai_spec.rb +1 -1
  133. data/spec/spec_helper.rb +9 -9
  134. data/spec/support/integration_helper.rb +7 -7
  135. data/spec/support/platform_helpers.rb +1 -1
  136. data/spec/unit/application_spec.rb +17 -17
  137. data/spec/unit/config_spec.rb +2 -2
  138. data/spec/unit/dsl/plugin_spec.rb +28 -28
  139. data/spec/unit/hints_spec.rb +3 -3
  140. data/spec/unit/loader_spec.rb +9 -9
  141. data/spec/unit/mixin/command_spec.rb +5 -5
  142. data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
  143. data/spec/unit/mixin/softlayer_metadata_spec.rb +19 -23
  144. data/spec/unit/plugin_config_spec.rb +5 -5
  145. data/spec/unit/plugins/abort_spec.rb +3 -3
  146. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  147. data/spec/unit/plugins/aix/filesystem_spec.rb +25 -25
  148. data/spec/unit/plugins/aix/hostname_spec.rb +1 -2
  149. data/spec/unit/plugins/aix/kernel_spec.rb +3 -3
  150. data/spec/unit/plugins/aix/memory_spec.rb +8 -8
  151. data/spec/unit/plugins/aix/network_spec.rb +38 -38
  152. data/spec/unit/plugins/aix/os_spec.rb +1 -2
  153. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  154. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  155. data/spec/unit/plugins/aix/virtualization_spec.rb +11 -11
  156. data/spec/unit/plugins/azure_spec.rb +118 -20
  157. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  158. data/spec/unit/plugins/bsd/virtualization_spec.rb +4 -4
  159. data/spec/unit/plugins/c_spec.rb +12 -12
  160. data/spec/unit/plugins/chef_spec.rb +2 -2
  161. data/spec/unit/plugins/cloud_spec.rb +37 -37
  162. data/spec/unit/plugins/cloud_v2_spec.rb +64 -65
  163. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -2
  164. data/spec/unit/plugins/darwin/filesystem2_spec.rb +7 -7
  165. data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
  166. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -4
  167. data/spec/unit/plugins/darwin/kernel_spec.rb +6 -10
  168. data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
  169. data/spec/unit/plugins/darwin/network_spec.rb +352 -353
  170. data/spec/unit/plugins/darwin/platform_spec.rb +1 -2
  171. data/spec/unit/plugins/darwin/system_profiler_spec.rb +3 -3
  172. data/spec/unit/plugins/darwin/virtualization_spec.rb +6 -6
  173. data/spec/unit/plugins/digital_ocean_spec.rb +38 -37
  174. data/spec/unit/plugins/dmi_spec.rb +3 -3
  175. data/spec/unit/plugins/ec2_spec.rb +97 -88
  176. data/spec/unit/plugins/elixir_spec.rb +1 -2
  177. data/spec/unit/plugins/erlang_spec.rb +2 -2
  178. data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
  179. data/spec/unit/plugins/fail_spec.rb +2 -2
  180. data/spec/unit/plugins/freebsd/cpu_spec.rb +14 -14
  181. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -2
  182. data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -3
  183. data/spec/unit/plugins/freebsd/os_spec.rb +4 -5
  184. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -2
  185. data/spec/unit/plugins/gce_spec.rb +9 -9
  186. data/spec/unit/plugins/go_spec.rb +1 -1
  187. data/spec/unit/plugins/groovy_spec.rb +1 -2
  188. data/spec/unit/plugins/hostname_spec.rb +1 -2
  189. data/spec/unit/plugins/init_package_spec.rb +1 -1
  190. data/spec/unit/plugins/ip_scopes_spec.rb +38 -38
  191. data/spec/unit/plugins/java_spec.rb +52 -1
  192. data/spec/unit/plugins/joyent_spec.rb +9 -11
  193. data/spec/unit/plugins/kernel_spec.rb +11 -12
  194. data/spec/unit/plugins/linode_spec.rb +29 -29
  195. data/spec/unit/plugins/linux/block_device_spec.rb +21 -21
  196. data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
  197. data/spec/unit/plugins/linux/filesystem2_spec.rb +7 -7
  198. data/spec/unit/plugins/linux/filesystem_spec.rb +85 -86
  199. data/spec/unit/plugins/linux/hostname_spec.rb +1 -3
  200. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  201. data/spec/unit/plugins/linux/lsb_spec.rb +1 -2
  202. data/spec/unit/plugins/linux/mdadm_spec.rb +4 -4
  203. data/spec/unit/plugins/linux/memory_spec.rb +29 -33
  204. data/spec/unit/plugins/linux/network_spec.rb +463 -245
  205. data/spec/unit/plugins/linux/platform_spec.rb +64 -65
  206. data/spec/unit/plugins/linux/uptime_spec.rb +1 -2
  207. data/spec/unit/plugins/linux/virtualization_spec.rb +42 -42
  208. data/spec/unit/plugins/lua_spec.rb +1 -2
  209. data/spec/unit/plugins/mono_spec.rb +1 -2
  210. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -2
  211. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -2
  212. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  213. data/spec/unit/plugins/network_spec.rb +118 -118
  214. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  215. data/spec/unit/plugins/ohai_spec.rb +1 -1
  216. data/spec/unit/plugins/ohai_time_spec.rb +1 -2
  217. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -2
  218. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -2
  219. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -2
  220. data/spec/unit/plugins/openstack_spec.rb +35 -37
  221. data/spec/unit/plugins/os_spec.rb +7 -8
  222. data/spec/unit/plugins/packages_spec.rb +118 -118
  223. data/spec/unit/plugins/passwd_spec.rb +18 -18
  224. data/spec/unit/plugins/perl_spec.rb +1 -1
  225. data/spec/unit/plugins/php_spec.rb +4 -4
  226. data/spec/unit/plugins/platform_spec.rb +8 -9
  227. data/spec/unit/plugins/powershell_spec.rb +3 -3
  228. data/spec/unit/plugins/python_spec.rb +1 -1
  229. data/spec/unit/plugins/rackspace_spec.rb +66 -68
  230. data/spec/unit/plugins/root_group_spec.rb +26 -26
  231. data/spec/unit/plugins/ruby_spec.rb +14 -15
  232. data/spec/unit/plugins/rust_spec.rb +2 -2
  233. data/spec/unit/plugins/sigar/network_route_spec.rb +36 -36
  234. data/spec/unit/plugins/softlayer_spec.rb +10 -10
  235. data/spec/unit/plugins/solaris2/cpu_spec.rb +20 -21
  236. data/spec/unit/plugins/solaris2/dmi_spec.rb +5 -6
  237. data/spec/unit/plugins/solaris2/filesystem.rb +5 -5
  238. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  239. data/spec/unit/plugins/solaris2/kernel_spec.rb +3 -3
  240. data/spec/unit/plugins/solaris2/memory_spec.rb +5 -5
  241. data/spec/unit/plugins/solaris2/network_spec.rb +7 -8
  242. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  243. data/spec/unit/plugins/solaris2/virtualization_spec.rb +3 -5
  244. data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
  245. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  246. data/spec/unit/plugins/virtualbox_spec.rb +19 -19
  247. data/spec/unit/plugins/vmware_spec.rb +28 -28
  248. data/spec/unit/plugins/windows/cpu_spec.rb +46 -48
  249. data/spec/unit/plugins/windows/memory_spec.rb +5 -5
  250. data/spec/unit/plugins/windows/virtualization_spec.rb +163 -163
  251. data/spec/unit/provides_map_spec.rb +10 -10
  252. data/spec/unit/runner_spec.rb +10 -10
  253. data/spec/unit/system_spec.rb +19 -19
  254. data/spec/unit/util/file_helper_spec.rb +5 -6
  255. data/spec/unit/util/ip_helper_spec.rb +39 -39
  256. metadata +31 -4
@@ -17,10 +17,10 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
20
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
21
21
 
22
22
  begin
23
- require 'ipaddress'
23
+ require "ipaddress"
24
24
  rescue LoadError => e
25
25
  puts "The linux network plugin spec tests will fail without the 'ipaddress' library/gem.\n\n"
26
26
  raise e
@@ -29,8 +29,8 @@ end
29
29
  describe Ohai::System, "Linux Network Plugin" do
30
30
  let(:plugin) { get_plugin("linux/network") }
31
31
 
32
- let(:linux_ifconfig) {
33
- 'eth0 Link encap:Ethernet HWaddr 12:31:3D:02:BE:A2
32
+ let(:linux_ifconfig) { <<-EOM
33
+ eth0 Link encap:Ethernet HWaddr 12:31:3D:02:BE:A2
34
34
  inet addr:10.116.201.76 Bcast:10.116.201.255 Mask:255.255.255.0
35
35
  inet6 addr: fe80::1031:3dff:fe02:bea2/64 Scope:Link
36
36
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
@@ -138,41 +138,49 @@ xapi1 Link encap:Ethernet HWaddr E8:39:35:C5:C8:50
138
138
  TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
139
139
  collisions:0 txqueuelen:0
140
140
  RX bytes:21515031 (20.5 MiB) TX bytes:2052 (2.0 KiB)
141
- '
141
+
142
+ fwdintf Link encap:Ethernet HWaddr 00:00:00:00:00:0a
143
+ inet6 addr: fe80::200:ff:fe00:a/64 Scope:Link
144
+ UP RUNNING NOARP MULTICAST MTU:1496 Metric:1
145
+ RX packets:0 errors:0 dropped:0 overruns:0 frame:0
146
+ TX packets:2 errors:0 dropped:1 overruns:0 carrier:0
147
+ collisions:0 txqueuelen:1000
148
+ RX bytes:0 (0.0 B) TX bytes:140 (140.0 B)
149
+ EOM
142
150
  # Note that ifconfig shows foo:veth0@eth0 but fails to show any address information.
143
151
  # This was not a mistake collecting the output and Apparently ifconfig is broken in this regard.
144
152
  }
145
153
 
146
- let(:linux_ip_route) {
147
- '10.116.201.0/24 dev eth0 proto kernel
154
+ let(:linux_ip_route) { <<-EOM
155
+ 10.116.201.0/24 dev eth0 proto kernel
148
156
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
149
157
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
150
158
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
151
159
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
152
160
  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
153
161
  default via 10.116.201.1 dev eth0
154
- '
162
+ EOM
155
163
  }
156
164
 
157
- let(:linux_route_n) {
158
- 'Kernel IP routing table
165
+ let(:linux_route_n) { <<-EOM
166
+ Kernel IP routing table
159
167
  Destination Gateway Genmask Flags Metric Ref Use Iface
160
168
  10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
161
169
  169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
162
170
  0.0.0.0 10.116.201.1 0.0.0.0 UG 0 0 0 eth0
163
- '
171
+ EOM
164
172
  }
165
173
 
166
- let(:linux_ip_route_inet6) {
167
- 'fe80::/64 dev eth0 proto kernel metric 256
174
+ let(:linux_ip_route_inet6) { <<-EOM
175
+ fe80::/64 dev eth0 proto kernel metric 256
168
176
  fe80::/64 dev eth0.11 proto kernel metric 256
169
177
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 expires 86023sec
170
178
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
171
- '
179
+ EOM
172
180
  }
173
181
 
174
- let(:linux_ip_addr) {
175
- '1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
182
+ let(:linux_ip_addr) { <<-EOM
183
+ 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
176
184
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
177
185
  inet 127.0.0.1/8 scope host lo
178
186
  inet6 ::1/128 scope host
@@ -225,11 +233,13 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
225
233
  link/ether e8:39:35:c5:c8:50 brd ff:ff:ff:ff:ff:ff
226
234
  inet 192.168.13.34/24 brd 192.168.13.255 scope global xapi1
227
235
  valid_lft forever preferred_lft forever
228
- '
236
+ 13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
237
+ link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff
238
+ EOM
229
239
  }
230
240
 
231
- let(:linux_ip_link_s_d) {
232
- '1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
241
+ let(:linux_ip_link_s_d) { <<-EOM
242
+ 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
233
243
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
234
244
  RX: bytes packets errors dropped overrun mcast
235
245
  35224 524 0 0 0 0
@@ -278,28 +288,34 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
278
288
  21468183 159866 0 0 0 0
279
289
  TX: bytes packets errors dropped carrier collsns
280
290
  2052 6 0 0 0 0
281
- '
291
+ 13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
292
+ link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff promiscuity 0
293
+ RX: bytes packets errors dropped overrun mcast
294
+ 0 0 0 0 0 0
295
+ TX: bytes packets errors dropped carrier collsns
296
+ 140 2 0 1 0 0
297
+ EOM
282
298
  }
283
299
 
284
- let(:linux_arp_an) {
285
- '? (10.116.201.1) at fe:ff:ff:ff:ff:ff [ether] on eth0
286
- '
300
+ let(:linux_arp_an) { <<-EOM
301
+ ? (10.116.201.1) at fe:ff:ff:ff:ff:ff [ether] on eth0
302
+ EOM
287
303
  }
288
304
 
289
- let(:linux_ip_neighbor_show) {
290
- '10.116.201.1 dev eth0 lladdr fe:ff:ff:ff:ff:ff REACHABLE
291
- '
305
+ let(:linux_ip_neighbor_show) { <<-EOM
306
+ 10.116.201.1 dev eth0 lladdr fe:ff:ff:ff:ff:ff REACHABLE
307
+ EOM
292
308
  }
293
309
 
294
- let(:linux_ip_inet6_neighbor_show) {
295
- '1111:2222:3333:4444::1 dev eth0.11 lladdr 00:1c:0e:12:34:56 router REACHABLE
310
+ let(:linux_ip_inet6_neighbor_show) { <<-EOM
311
+ 1111:2222:3333:4444::1 dev eth0.11 lladdr 00:1c:0e:12:34:56 router REACHABLE
296
312
  fe80::21c:eff:fe12:3456 dev eth0.11 lladdr 00:1c:0e:30:28:00 router REACHABLE
297
313
  fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
298
- '
314
+ EOM
299
315
  }
300
316
 
301
- let(:linux_ethtool) {
302
- 'Settings for eth0:
317
+ let(:linux_ethtool) { <<-EOM
318
+ Settings for eth0:
303
319
  Supported ports: [ FIBRE ]
304
320
  Supported link modes: 1000baseT/Full
305
321
  10000baseT/Full
@@ -320,7 +336,7 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
320
336
  Current message level: 0x00000007 (7)
321
337
  drv probe link
322
338
  Link detected: yes
323
- '
339
+ EOM
324
340
  }
325
341
 
326
342
  before(:each) do
@@ -359,121 +375,273 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
359
375
  end
360
376
  end
361
377
 
378
+ describe '#interface_has_no_addresses_in_family?' do
379
+ context "when interface has no addresses" do
380
+ let(:iface) { {} }
381
+
382
+ it "returns true" do
383
+ expect(plugin.interface_has_no_addresses_in_family?(iface, "inet")).to eq(true)
384
+ end
385
+ end
386
+
387
+ context "when an interface has no addresses in family" do
388
+ let(:iface) { { addresses: { "1.2.3.4" => { "family" => "inet6" } } } }
389
+
390
+ it "returns true" do
391
+ expect(plugin.interface_has_no_addresses_in_family?(iface, "inet")).to eq(true)
392
+ end
393
+ end
394
+
395
+ context "when an interface has addresses in family" do
396
+ let(:iface) { { addresses: { "1.2.3.4" => { "family" => "inet" } } } }
397
+
398
+ it "returns false" do
399
+ expect(plugin.interface_has_no_addresses_in_family?(iface, "inet")).to eq(false)
400
+ end
401
+ end
402
+ end
403
+
404
+ describe '#interface_have_address?' do
405
+ context "when interface has no addresses" do
406
+ let(:iface) { {} }
407
+
408
+ it "returns false" do
409
+ expect(plugin.interface_have_address?(iface, "1.2.3.4")).to eq(false)
410
+ end
411
+ end
412
+
413
+ context "when interface has a matching address" do
414
+ let(:iface) { { addresses: { "1.2.3.4" => {} } } }
415
+
416
+ it "returns true" do
417
+ expect(plugin.interface_have_address?(iface, "1.2.3.4")).to eq(true)
418
+ end
419
+ end
420
+
421
+ context "when interface does not have a matching address" do
422
+ let(:iface) { { addresses: { "4.3.2.1" => {} } } }
423
+
424
+ it "returns false" do
425
+ expect(plugin.interface_have_address?(iface, "1.2.3.4")).to eq(false)
426
+ end
427
+ end
428
+ end
429
+
430
+ describe '#interface_address_not_link_level?' do
431
+ context "when the address scope is link" do
432
+ let(:iface) { { addresses: { "1.2.3.4" => { scope: "Link" } } } }
433
+
434
+ it "returns false" do
435
+ expect(plugin.interface_address_not_link_level?(iface, "1.2.3.4")).to eq(false)
436
+ end
437
+ end
438
+
439
+ context "when the address scope is global" do
440
+ let(:iface) { { addresses: { "1.2.3.4" => { scope: "Global" } } } }
441
+
442
+ it "returns true" do
443
+ expect(plugin.interface_address_not_link_level?(iface, "1.2.3.4")).to eq(true)
444
+ end
445
+ end
446
+ end
447
+
448
+ describe '#interface_valid_for_route?' do
449
+ let(:iface) { double("iface") }
450
+ let(:address) { "1.2.3.4" }
451
+ let(:family) { "inet" }
452
+
453
+ context "when interface has no addresses" do
454
+ it "returns true" do
455
+ expect(plugin).to receive(:interface_has_no_addresses_in_family?).with(iface, family).and_return(true)
456
+ expect(plugin.interface_valid_for_route?(iface, address, family)).to eq(true)
457
+ end
458
+ end
459
+
460
+ context "when interface has addresses" do
461
+ before do
462
+ expect(plugin).to receive(:interface_has_no_addresses_in_family?).with(iface, family).and_return(false)
463
+ end
464
+
465
+ context "when interface contains the address" do
466
+ before do
467
+ expect(plugin).to receive(:interface_have_address?).with(iface, address).and_return(true)
468
+ end
469
+
470
+ context "when interface address is not a link-level address" do
471
+ it "returns true" do
472
+ expect(plugin).to receive(:interface_address_not_link_level?).with(iface, address).and_return(true)
473
+ expect(plugin.interface_valid_for_route?(iface, address, family)).to eq(true)
474
+ end
475
+ end
476
+
477
+ context "when the interface address is a link-level address" do
478
+ it "returns false" do
479
+ expect(plugin).to receive(:interface_address_not_link_level?).with(iface, address).and_return(false)
480
+ expect(plugin.interface_valid_for_route?(iface, address, family)).to eq(false)
481
+ end
482
+ end
483
+ end
484
+
485
+ context "when interface does not contain the address" do
486
+ it "returns false" do
487
+ expect(plugin).to receive(:interface_have_address?).with(iface, address).and_return(false)
488
+ expect(plugin.interface_valid_for_route?(iface, address, family)).to eq(false)
489
+ end
490
+ end
491
+ end
492
+ end
493
+
494
+ describe '#route_is_valid_default_route?' do
495
+ context "when the route destination is default" do
496
+ let(:route) { { destination: "default" } }
497
+ let(:default_route) { double("default_route") }
498
+
499
+ it "returns true" do
500
+ expect(plugin.route_is_valid_default_route?(route, default_route)).to eq(true)
501
+ end
502
+ end
503
+
504
+ context "when the route destination is not default" do
505
+ let(:route) { { destination: "10.0.0.0/24" } }
506
+
507
+ context "when the default route does not have a gateway" do
508
+ let(:default_route) { {} }
509
+
510
+ it "returns false" do
511
+ expect(plugin.route_is_valid_default_route?(route, default_route)).to eq(false)
512
+ end
513
+ end
514
+
515
+ context "when the gateway is within the destination" do
516
+ let(:default_route) { { via: "10.0.0.1" } }
362
517
 
363
- ["ifconfig","iproute2"].each do |network_method|
518
+ it "returns true" do
519
+ expect(plugin.route_is_valid_default_route?(route, default_route)).to eq(true)
520
+ end
521
+ end
522
+
523
+ context "when the gateway is not within the destination" do
524
+ let(:default_route) { { via: "20.0.0.1" } }
525
+
526
+ it "returns false" do
527
+ expect(plugin.route_is_valid_default_route?(route, default_route)).to eq(false)
528
+ end
529
+ end
530
+ end
531
+ end
364
532
 
533
+ %w{ifconfig iproute2}.each do |network_method|
365
534
  describe "gathering IP layer address info via #{network_method}" do
366
535
  before(:each) do
367
536
  allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" )
368
- allow(plugin).to receive(:find_ethtool_binary).and_return( '/sbin/ethtool' )
537
+ allow(plugin).to receive(:find_ethtool_binary).and_return( "/sbin/ethtool" )
369
538
  plugin.run
370
539
  end
371
540
 
372
541
  it "completes the run" do
373
542
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
374
- expect(plugin['network']).not_to be_nil
543
+ expect(plugin["network"]).not_to be_nil
375
544
  end
376
545
 
377
546
  it "detects the interfaces" do
378
- expect(plugin['network']['interfaces'].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
547
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
379
548
  end
380
549
 
381
550
  it "detects the layer one details of an ethernet interface" do
382
- expect(plugin['network']['interfaces']['eth0']['link_speed']).to eq(10000)
383
- expect(plugin['network']['interfaces']['eth0']['duplex']).to eq('Full')
384
- expect(plugin['network']['interfaces']['eth0']['port']).to eq('FIBRE')
385
- expect(plugin['network']['interfaces']['eth0']['transceiver']).to eq('external')
386
- expect(plugin['network']['interfaces']['eth0']['auto_negotiation']).to eq('on')
387
- expect(plugin['network']['interfaces']['eth0']['mdi_x']).to be_nil
551
+ expect(plugin["network"]["interfaces"]["eth0"]["link_speed"]).to eq(10000)
552
+ expect(plugin["network"]["interfaces"]["eth0"]["duplex"]).to eq("Full")
553
+ expect(plugin["network"]["interfaces"]["eth0"]["port"]).to eq("FIBRE")
554
+ expect(plugin["network"]["interfaces"]["eth0"]["transceiver"]).to eq("external")
555
+ expect(plugin["network"]["interfaces"]["eth0"]["auto_negotiation"]).to eq("on")
556
+ expect(plugin["network"]["interfaces"]["eth0"]["mdi_x"]).to be_nil
388
557
  end
389
558
 
390
559
  it "detects the ipv4 addresses of the ethernet interface" do
391
- expect(plugin['network']['interfaces']['eth0']['addresses'].keys).to include('10.116.201.76')
392
- expect(plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['netmask']).to eq('255.255.255.0')
393
- expect(plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['broadcast']).to eq('10.116.201.255')
394
- expect(plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['family']).to eq('inet')
560
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"].keys).to include("10.116.201.76")
561
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["10.116.201.76"]["netmask"]).to eq("255.255.255.0")
562
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["10.116.201.76"]["broadcast"]).to eq("10.116.201.255")
563
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["10.116.201.76"]["family"]).to eq("inet")
395
564
  end
396
565
 
397
566
  it "detects the ipv4 addresses of an ethernet subinterface" do
398
- expect(plugin['network']['interfaces']['eth0.11']['addresses'].keys).to include('192.168.0.16')
399
- expect(plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['netmask']).to eq('255.255.255.0')
400
- expect(plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['broadcast']).to eq('192.168.0.255')
401
- expect(plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['family']).to eq('inet')
567
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"].keys).to include("192.168.0.16")
568
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"]["192.168.0.16"]["netmask"]).to eq("255.255.255.0")
569
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"]["192.168.0.16"]["broadcast"]).to eq("192.168.0.255")
570
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"]["192.168.0.16"]["family"]).to eq("inet")
402
571
  end
403
572
 
404
573
  it "detects the ipv6 addresses of the ethernet interface" do
405
- expect(plugin['network']['interfaces']['eth0']['addresses'].keys).to include('fe80::1031:3dff:fe02:bea2')
406
- expect(plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['scope']).to eq('Link')
407
- expect(plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['prefixlen']).to eq('64')
408
- expect(plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['family']).to eq('inet6')
574
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"].keys).to include("fe80::1031:3dff:fe02:bea2")
575
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["fe80::1031:3dff:fe02:bea2"]["scope"]).to eq("Link")
576
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["fe80::1031:3dff:fe02:bea2"]["prefixlen"]).to eq("64")
577
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["fe80::1031:3dff:fe02:bea2"]["family"]).to eq("inet6")
409
578
  end
410
579
 
411
580
  it "detects the ipv6 addresses of an ethernet subinterface" do
412
- %w[ 1111:2222:3333:4444::2 1111:2222:3333:4444::3 ].each do |addr|
413
- expect(plugin['network']['interfaces']['eth0.11']['addresses'].keys).to include(addr)
414
- expect(plugin['network']['interfaces']['eth0.11']['addresses'][addr]['scope']).to eq('Global')
415
- expect(plugin['network']['interfaces']['eth0.11']['addresses'][addr]['prefixlen']).to eq('64')
416
- expect(plugin['network']['interfaces']['eth0.11']['addresses'][addr]['family']).to eq('inet6')
581
+ %w{ 1111:2222:3333:4444::2 1111:2222:3333:4444::3 }.each do |addr|
582
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"].keys).to include(addr)
583
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"][addr]["scope"]).to eq("Global")
584
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"][addr]["prefixlen"]).to eq("64")
585
+ expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"][addr]["family"]).to eq("inet6")
417
586
  end
418
587
  end
419
588
 
420
589
  it "detects the mac addresses of the ethernet interface" do
421
- expect(plugin['network']['interfaces']['eth0']['addresses'].keys).to include('12:31:3D:02:BE:A2')
422
- expect(plugin['network']['interfaces']['eth0']['addresses']['12:31:3D:02:BE:A2']['family']).to eq('lladdr')
590
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"].keys).to include("12:31:3D:02:BE:A2")
591
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["12:31:3D:02:BE:A2"]["family"]).to eq("lladdr")
423
592
  end
424
593
 
425
594
  it "detects the encapsulation type of the ethernet interface" do
426
- expect(plugin['network']['interfaces']['eth0']['encapsulation']).to eq('Ethernet')
595
+ expect(plugin["network"]["interfaces"]["eth0"]["encapsulation"]).to eq("Ethernet")
427
596
  end
428
597
 
429
598
  it "detects the flags of the ethernet interface" do
430
599
  if network_method == "ifconfig"
431
- expect(plugin['network']['interfaces']['eth0']['flags'].sort).to eq(['BROADCAST','MULTICAST','RUNNING','UP'])
600
+ expect(plugin["network"]["interfaces"]["eth0"]["flags"].sort).to eq(%w{BROADCAST MULTICAST RUNNING UP})
432
601
  else
433
- expect(plugin['network']['interfaces']['eth0']['flags'].sort).to eq(['BROADCAST','LOWER_UP','MULTICAST','UP'])
602
+ expect(plugin["network"]["interfaces"]["eth0"]["flags"].sort).to eq(%w{BROADCAST LOWER_UP MULTICAST UP})
434
603
  end
435
604
  end
436
605
 
437
606
  it "detects the number of the ethernet interface" do
438
- expect(plugin['network']['interfaces']['eth0']['number']).to eq("0")
607
+ expect(plugin["network"]["interfaces"]["eth0"]["number"]).to eq("0")
439
608
  end
440
609
 
441
610
  it "detects the mtu of the ethernet interface" do
442
- expect(plugin['network']['interfaces']['eth0']['mtu']).to eq("1500")
611
+ expect(plugin["network"]["interfaces"]["eth0"]["mtu"]).to eq("1500")
443
612
  end
444
613
 
445
614
  it "detects the ipv4 addresses of the loopback interface" do
446
- expect(plugin['network']['interfaces']['lo']['addresses'].keys).to include('127.0.0.1')
447
- expect(plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['netmask']).to eq('255.0.0.0')
448
- expect(plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['family']).to eq('inet')
615
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"].keys).to include("127.0.0.1")
616
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"]["127.0.0.1"]["netmask"]).to eq("255.0.0.0")
617
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"]["127.0.0.1"]["family"]).to eq("inet")
449
618
  end
450
619
 
451
620
  it "detects the ipv6 addresses of the loopback interface" do
452
- expect(plugin['network']['interfaces']['lo']['addresses'].keys).to include('::1')
453
- expect(plugin['network']['interfaces']['lo']['addresses']['::1']['scope']).to eq('Node')
454
- expect(plugin['network']['interfaces']['lo']['addresses']['::1']['prefixlen']).to eq('128')
455
- expect(plugin['network']['interfaces']['lo']['addresses']['::1']['family']).to eq('inet6')
621
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"].keys).to include("::1")
622
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"]["::1"]["scope"]).to eq("Node")
623
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"]["::1"]["prefixlen"]).to eq("128")
624
+ expect(plugin["network"]["interfaces"]["lo"]["addresses"]["::1"]["family"]).to eq("inet6")
456
625
  end
457
626
 
458
627
  it "detects the encapsulation type of the loopback interface" do
459
- expect(plugin['network']['interfaces']['lo']['encapsulation']).to eq('Loopback')
628
+ expect(plugin["network"]["interfaces"]["lo"]["encapsulation"]).to eq("Loopback")
460
629
  end
461
630
 
462
631
  it "detects the flags of the ethernet interface" do
463
632
  if network_method == "ifconfig"
464
- expect(plugin['network']['interfaces']['lo']['flags'].sort).to eq(['LOOPBACK','RUNNING','UP'])
633
+ expect(plugin["network"]["interfaces"]["lo"]["flags"].sort).to eq(%w{LOOPBACK RUNNING UP})
465
634
  else
466
- expect(plugin['network']['interfaces']['lo']['flags'].sort).to eq(['LOOPBACK','LOWER_UP','UP'])
635
+ expect(plugin["network"]["interfaces"]["lo"]["flags"].sort).to eq(%w{LOOPBACK LOWER_UP UP})
467
636
  end
468
637
  end
469
638
 
470
-
471
639
  it "detects the mtu of the loopback interface" do
472
- expect(plugin['network']['interfaces']['lo']['mtu']).to eq("16436")
640
+ expect(plugin["network"]["interfaces"]["lo"]["mtu"]).to eq("16436")
473
641
  end
474
642
 
475
643
  it "detects the arp entries" do
476
- expect(plugin['network']['interfaces']['eth0']['arp']['10.116.201.1']).to eq('fe:ff:ff:ff:ff:ff')
644
+ expect(plugin["network"]["interfaces"]["eth0"]["arp"]["10.116.201.1"]).to eq("fe:ff:ff:ff:ff:ff")
477
645
  end
478
646
 
479
647
  end
@@ -485,34 +653,34 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
485
653
  end
486
654
 
487
655
  it "detects the ethernet counters" do
488
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['bytes']).to eq("691785313")
489
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['packets']).to eq("1919690")
490
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['collisions']).to eq("0")
491
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['queuelen']).to eq("1000")
492
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['errors']).to eq("0")
493
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['carrier']).to eq("0")
494
- expect(plugin['counters']['network']['interfaces']['eth0']['tx']['drop']).to eq("0")
495
-
496
- expect(plugin['counters']['network']['interfaces']['eth0']['rx']['bytes']).to eq("1392844460")
497
- expect(plugin['counters']['network']['interfaces']['eth0']['rx']['packets']).to eq("2659966")
498
- expect(plugin['counters']['network']['interfaces']['eth0']['rx']['errors']).to eq("0")
499
- expect(plugin['counters']['network']['interfaces']['eth0']['rx']['overrun']).to eq("0")
500
- expect(plugin['counters']['network']['interfaces']['eth0']['rx']['drop']).to eq("0")
656
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["bytes"]).to eq("691785313")
657
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["packets"]).to eq("1919690")
658
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["collisions"]).to eq("0")
659
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["queuelen"]).to eq("1000")
660
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["errors"]).to eq("0")
661
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["carrier"]).to eq("0")
662
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["tx"]["drop"]).to eq("0")
663
+
664
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["rx"]["bytes"]).to eq("1392844460")
665
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["rx"]["packets"]).to eq("2659966")
666
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["rx"]["errors"]).to eq("0")
667
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["rx"]["overrun"]).to eq("0")
668
+ expect(plugin["counters"]["network"]["interfaces"]["eth0"]["rx"]["drop"]).to eq("0")
501
669
  end
502
670
 
503
671
  it "detects the loopback counters" do
504
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['bytes']).to eq("35224")
505
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['packets']).to eq("524")
506
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['collisions']).to eq("0")
507
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['errors']).to eq("0")
508
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['carrier']).to eq("0")
509
- expect(plugin['counters']['network']['interfaces']['lo']['tx']['drop']).to eq("0")
510
-
511
- expect(plugin['counters']['network']['interfaces']['lo']['rx']['bytes']).to eq("35224")
512
- expect(plugin['counters']['network']['interfaces']['lo']['rx']['packets']).to eq("524")
513
- expect(plugin['counters']['network']['interfaces']['lo']['rx']['errors']).to eq("0")
514
- expect(plugin['counters']['network']['interfaces']['lo']['rx']['overrun']).to eq("0")
515
- expect(plugin['counters']['network']['interfaces']['lo']['rx']['drop']).to eq("0")
672
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["bytes"]).to eq("35224")
673
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["packets"]).to eq("524")
674
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["collisions"]).to eq("0")
675
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["errors"]).to eq("0")
676
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["carrier"]).to eq("0")
677
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["tx"]["drop"]).to eq("0")
678
+
679
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["rx"]["bytes"]).to eq("35224")
680
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["rx"]["packets"]).to eq("524")
681
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["rx"]["errors"]).to eq("0")
682
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["rx"]["overrun"]).to eq("0")
683
+ expect(plugin["counters"]["network"]["interfaces"]["lo"]["rx"]["drop"]).to eq("0")
516
684
  end
517
685
  end
518
686
 
@@ -524,27 +692,27 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
524
692
 
525
693
  describe "without a subinterface" do
526
694
  it "finds the default interface by asking which iface has the default route" do
527
- expect(plugin['network']['default_interface']).to eq('eth0')
695
+ expect(plugin["network"]["default_interface"]).to eq("eth0")
528
696
  end
529
697
 
530
698
  it "finds the default gateway by asking which iface has the default route" do
531
- expect(plugin['network']['default_gateway']).to eq('10.116.201.1')
699
+ expect(plugin["network"]["default_gateway"]).to eq("10.116.201.1")
532
700
  end
533
701
  end
534
702
 
535
703
  describe "with a link level default route" do
536
- let(:linux_ip_route) {
537
- '10.116.201.0/24 dev eth0 proto kernel
704
+ let(:linux_ip_route) { <<-EOM
705
+ 10.116.201.0/24 dev eth0 proto kernel
538
706
  default dev eth0 scope link
539
- '
707
+ EOM
540
708
  }
541
709
 
542
- let(:linux_route_n) {
543
- 'Kernel IP routing table
710
+ let(:linux_route_n) { <<-EOM
711
+ Kernel IP routing table
544
712
  Destination Gateway Genmask Flags Metric Ref Use Iface
545
713
  10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
546
714
  0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
547
- '
715
+ EOM
548
716
  }
549
717
 
550
718
  before(:each) do
@@ -552,27 +720,27 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
552
720
  end
553
721
 
554
722
  it "finds the default interface by asking which iface has the default route" do
555
- expect(plugin['network']['default_interface']).to eq('eth0')
723
+ expect(plugin["network"]["default_interface"]).to eq("eth0")
556
724
  end
557
725
 
558
726
  it "finds the default interface by asking which iface has the default route" do
559
- expect(plugin['network']['default_gateway']).to eq('0.0.0.0')
727
+ expect(plugin["network"]["default_gateway"]).to eq("0.0.0.0")
560
728
  end
561
729
  end
562
730
 
563
731
  describe "with a subinterface" do
564
- let(:linux_ip_route) {
565
- '192.168.0.0/24 dev eth0.11 proto kernel src 192.168.0.2
732
+ let(:linux_ip_route) { <<-EOM
733
+ 192.168.0.0/24 dev eth0.11 proto kernel src 192.168.0.2
566
734
  default via 192.168.0.15 dev eth0.11
567
- '
735
+ EOM
568
736
  }
569
737
 
570
- let(:linux_route_n) {
571
- 'Kernel IP routing table
738
+ let(:linux_route_n) { <<-EOM
739
+ Kernel IP routing table
572
740
  Destination Gateway Genmask Flags Metric Ref Use Iface
573
741
  192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0.11
574
742
  0.0.0.0 192.168.0.15 0.0.0.0 UG 0 0 0 eth0.11
575
- '
743
+ EOM
576
744
  }
577
745
 
578
746
  before(:each) do
@@ -580,11 +748,11 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
580
748
  end
581
749
 
582
750
  it "finds the default interface by asking which iface has the default route" do
583
- expect(plugin['network']["default_interface"]).to eq('eth0.11')
751
+ expect(plugin["network"]["default_interface"]).to eq("eth0.11")
584
752
  end
585
753
 
586
754
  it "finds the default interface by asking which iface has the default route" do
587
- expect(plugin['network']["default_gateway"]).to eq('192.168.0.15')
755
+ expect(plugin["network"]["default_gateway"]).to eq("192.168.0.15")
588
756
  end
589
757
  end
590
758
  end
@@ -600,44 +768,44 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
600
768
 
601
769
  it "completes the run" do
602
770
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
603
- expect(plugin['network']).not_to be_nil
771
+ expect(plugin["network"]).not_to be_nil
604
772
  end
605
773
 
606
774
  it "finds the default inet6 interface if there's a inet6 default route" do
607
- expect(plugin['network']['default_inet6_interface']).to eq('eth0.11')
775
+ expect(plugin["network"]["default_inet6_interface"]).to eq("eth0.11")
608
776
  end
609
777
 
610
778
  it "finds the default inet6 gateway if there's a inet6 default route" do
611
- expect(plugin['network']['default_inet6_gateway']).to eq('1111:2222:3333:4444::1')
779
+ expect(plugin["network"]["default_inet6_gateway"]).to eq("1111:2222:3333:4444::1")
612
780
  end
613
781
 
614
782
  it "finds inet6 neighbours" do
615
- expect(plugin['network']['interfaces']['eth0.11']['neighbour_inet6']['1111:2222:3333:4444::1']).to eq('00:1c:0e:12:34:56')
783
+ expect(plugin["network"]["interfaces"]["eth0.11"]["neighbour_inet6"]["1111:2222:3333:4444::1"]).to eq("00:1c:0e:12:34:56")
616
784
  end
617
785
 
618
786
  it "detects the ipv4 addresses of an ethernet interface with a crazy name" do
619
- expect(plugin['network']['interfaces']['foo:veth0@eth0']['addresses'].keys).to include('192.168.212.2')
620
- expect(plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['netmask']).to eq('255.255.255.0')
621
- expect(plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['family']).to eq('inet')
787
+ expect(plugin["network"]["interfaces"]["foo:veth0@eth0"]["addresses"].keys).to include("192.168.212.2")
788
+ expect(plugin["network"]["interfaces"]["foo:veth0@eth0"]["addresses"]["192.168.212.2"]["netmask"]).to eq("255.255.255.0")
789
+ expect(plugin["network"]["interfaces"]["foo:veth0@eth0"]["addresses"]["192.168.212.2"]["family"]).to eq("inet")
622
790
  end
623
791
 
624
792
  it "generates a fake interface for ip aliases for backward compatibility" do
625
- expect(plugin['network']['interfaces']['eth0:5']['addresses'].keys).to include('192.168.5.1')
626
- expect(plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['netmask']).to eq('255.255.255.0')
627
- expect(plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['family']).to eq('inet')
793
+ expect(plugin["network"]["interfaces"]["eth0:5"]["addresses"].keys).to include("192.168.5.1")
794
+ expect(plugin["network"]["interfaces"]["eth0:5"]["addresses"]["192.168.5.1"]["netmask"]).to eq("255.255.255.0")
795
+ expect(plugin["network"]["interfaces"]["eth0:5"]["addresses"]["192.168.5.1"]["family"]).to eq("inet")
628
796
  end
629
797
 
630
798
  it "adds the vlan information of an interface" do
631
- expect(plugin['network']['interfaces']['eth0.11']['vlan']['id']).to eq('11')
632
- expect(plugin['network']['interfaces']['eth0.11']['vlan']['flags']).to eq([ 'REORDER_HDR' ])
799
+ expect(plugin["network"]["interfaces"]["eth0.11"]["vlan"]["id"]).to eq("11")
800
+ expect(plugin["network"]["interfaces"]["eth0.11"]["vlan"]["flags"]).to eq([ "REORDER_HDR" ])
633
801
  end
634
802
 
635
803
  it "adds the state of an interface" do
636
- expect(plugin['network']['interfaces']['eth0.11']['state']).to eq('up')
804
+ expect(plugin["network"]["interfaces"]["eth0.11"]["state"]).to eq("up")
637
805
  end
638
806
 
639
807
  it "detects interfaces only visible via ip link" do
640
- expect(plugin['network']['interfaces']['eth3']['state']).to eq('up')
808
+ expect(plugin["network"]["interfaces"]["eth3"]["state"]).to eq("up")
641
809
  end
642
810
 
643
811
  describe "when IPv6 is disabled" do
@@ -647,28 +815,28 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
647
815
  end
648
816
 
649
817
  it "doesn't set ip6address" do
650
- expect(plugin['ip6address']).to be_nil
818
+ expect(plugin["ip6address"]).to be_nil
651
819
  end
652
820
  end
653
821
 
654
822
  describe "when dealing with routes" do
655
823
  it "adds routes" do
656
824
  plugin.run
657
- expect(plugin['network']['interfaces']['eth0']['routes']).to include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family =>"inet" )
658
- expect(plugin['network']['interfaces']['eth0']['routes']).to include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.1")
659
- expect(plugin['network']['interfaces']['eth0']['routes']).to include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.2")
660
- expect(plugin['network']['interfaces']['foo:veth0@eth0']['routes']).to include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family =>"inet" )
661
- expect(plugin['network']['interfaces']['eth0']['routes']).to include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
662
- expect(plugin['network']['interfaces']['eth0.11']['routes']).to include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
663
- expect(plugin['network']['interfaces']['eth0.11']['routes']).to include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
825
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).to include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family => "inet" )
826
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).to include Mash.new( :destination => "10.5.4.0/24", :family => "inet", :via => "10.5.4.1")
827
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).to include Mash.new( :destination => "10.5.4.0/24", :family => "inet", :via => "10.5.4.2")
828
+ expect(plugin["network"]["interfaces"]["foo:veth0@eth0"]["routes"]).to include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family => "inet" )
829
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).to include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
830
+ expect(plugin["network"]["interfaces"]["eth0.11"]["routes"]).to include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
831
+ expect(plugin["network"]["interfaces"]["eth0.11"]["routes"]).to include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
664
832
  end
665
833
 
666
834
  describe "when there isn't a source field in route entries and no ipv6 default routes" do
667
- let(:linux_ip_route_inet6) {
668
- 'fe80::/64 dev eth0 proto kernel metric 256
835
+ let(:linux_ip_route_inet6) { <<-EOM
836
+ fe80::/64 dev eth0 proto kernel metric 256
669
837
  fe80::/64 dev eth0.11 proto kernel metric 256
670
838
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 expires 86023sec
671
- '
839
+ EOM
672
840
  }
673
841
 
674
842
  before(:each) do
@@ -676,35 +844,35 @@ fe80::/64 dev eth0.11 proto kernel metric 256
676
844
  end
677
845
 
678
846
  it "doesn't set ipaddress" do
679
- expect(plugin['ipaddress']).to be nil
847
+ expect(plugin["ipaddress"]).to be nil
680
848
  end
681
849
 
682
850
  it "doesn't set macaddress" do
683
- expect(plugin['macaddress']).to be nil
851
+ expect(plugin["macaddress"]).to be nil
684
852
  end
685
853
 
686
854
  it "doesn't set ip6address" do
687
- expect(plugin['ip6address']).to be nil
855
+ expect(plugin["ip6address"]).to be nil
688
856
  end
689
857
  end
690
858
 
691
859
  describe "when there's a source field in the default route entry" do
692
- let(:linux_ip_route) {
693
- '10.116.201.0/24 dev eth0 proto kernel
860
+ let(:linux_ip_route) { <<-EOM
861
+ 10.116.201.0/24 dev eth0 proto kernel
694
862
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
695
863
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
696
864
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
697
865
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
698
866
  default via 10.116.201.1 dev eth0 src 10.116.201.76
699
- '
867
+ EOM
700
868
  }
701
869
 
702
- let(:linux_ip_route_inet6) {
703
- 'fe80::/64 dev eth0 proto kernel metric 256
870
+ let(:linux_ip_route_inet6) { <<-EOM
871
+ fe80::/64 dev eth0 proto kernel metric 256
704
872
  fe80::/64 dev eth0.11 proto kernel metric 256
705
873
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024
706
874
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
707
- '
875
+ EOM
708
876
  }
709
877
 
710
878
  before(:each) do
@@ -713,37 +881,37 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333:
713
881
 
714
882
  it "completes the run" do
715
883
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
716
- expect(plugin['network']).not_to be_nil
884
+ expect(plugin["network"]).not_to be_nil
717
885
  end
718
886
 
719
887
  it "sets ipaddress" do
720
- expect(plugin['ipaddress']).to eq("10.116.201.76")
888
+ expect(plugin["ipaddress"]).to eq("10.116.201.76")
721
889
  end
722
890
 
723
891
  it "sets ip6address" do
724
- expect(plugin['ip6address']).to eq("1111:2222:3333:4444::3")
892
+ expect(plugin["ip6address"]).to eq("1111:2222:3333:4444::3")
725
893
  end
726
894
  end
727
895
 
728
896
  describe "when there're several default routes" do
729
- let(:linux_ip_route) {
730
- '10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
897
+ let(:linux_ip_route) { <<-EOM
898
+ 10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
731
899
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
732
900
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
733
901
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
734
902
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
735
903
  default via 10.116.201.1 dev eth0 metric 10
736
904
  default via 10.116.201.254 dev eth0 metric 9
737
- '
905
+ EOM
738
906
  }
739
907
 
740
- let(:linux_ip_route_inet6) {
741
- 'fe80::/64 dev eth0 proto kernel metric 256
908
+ let(:linux_ip_route_inet6) { <<-EOM
909
+ fe80::/64 dev eth0 proto kernel metric 256
742
910
  fe80::/64 dev eth0.11 proto kernel metric 256
743
911
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
744
912
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
745
913
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023
746
- '
914
+ EOM
747
915
  }
748
916
 
749
917
  before(:each) do
@@ -752,39 +920,39 @@ default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023
752
920
 
753
921
  it "completes the run" do
754
922
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
755
- expect(plugin['network']).not_to be_nil
923
+ expect(plugin["network"]).not_to be_nil
756
924
  end
757
925
 
758
926
  it "sets default ipv4 interface and gateway" do
759
- expect(plugin['network']['default_interface']).to eq('eth0')
760
- expect(plugin['network']['default_gateway']).to eq('10.116.201.254')
927
+ expect(plugin["network"]["default_interface"]).to eq("eth0")
928
+ expect(plugin["network"]["default_gateway"]).to eq("10.116.201.254")
761
929
  end
762
930
 
763
931
  it "sets default ipv6 interface and gateway" do
764
- expect(plugin['network']['default_inet6_interface']).to eq('eth0.11')
765
- expect(plugin['network']['default_inet6_gateway']).to eq('1111:2222:3333:4444::ffff')
932
+ expect(plugin["network"]["default_inet6_interface"]).to eq("eth0.11")
933
+ expect(plugin["network"]["default_inet6_gateway"]).to eq("1111:2222:3333:4444::ffff")
766
934
  end
767
935
  end
768
936
 
769
937
  describe "when there're a mixed setup of routes that could be used to set ipaddress" do
770
- let(:linux_ip_route) {
771
- '10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
938
+ let(:linux_ip_route) { <<-EOM
939
+ 10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
772
940
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
773
941
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
774
942
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
775
943
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
776
944
  default via 10.116.201.1 dev eth0 metric 10
777
945
  default via 10.116.201.254 dev eth0 metric 9 src 10.116.201.74
778
- '
946
+ EOM
779
947
  }
780
948
 
781
- let(:linux_ip_route_inet6) {
782
- 'fe80::/64 dev eth0 proto kernel metric 256
949
+ let(:linux_ip_route_inet6) { <<-EOM
950
+ fe80::/64 dev eth0 proto kernel metric 256
783
951
  fe80::/64 dev eth0.11 proto kernel metric 256
784
952
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
785
953
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
786
954
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:3333:4444::2
787
- '
955
+ EOM
788
956
  }
789
957
 
790
958
  before(:each) do
@@ -793,7 +961,7 @@ default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:333
793
961
 
794
962
  it "completes the run" do
795
963
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
796
- expect(plugin['network']).not_to be_nil
964
+ expect(plugin["network"]).not_to be_nil
797
965
  end
798
966
 
799
967
  it "sets ipaddress" do
@@ -806,82 +974,102 @@ default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:333
806
974
  end
807
975
 
808
976
  describe "when there's a source field in a local route entry but it isnt in the default route" do
809
- let(:linux_ip_route) {
810
- '10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
977
+ let(:linux_ip_route) { <<-EOM
978
+ 10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
811
979
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
812
980
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
813
981
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
814
982
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
815
983
  default via 10.116.201.1 dev eth0
816
- '
984
+ EOM
817
985
  }
818
986
 
819
- let(:linux_ip_route_inet6) {
820
- 'fe80::/64 dev eth0 proto kernel metric 256
987
+ let(:linux_ip_route_inet6) { <<-EOM
988
+ fe80::/64 dev eth0 proto kernel metric 256
821
989
  fe80::/64 dev eth0.11 proto kernel metric 256
822
990
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
823
991
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
824
- '
992
+ EOM
825
993
  }
826
994
 
827
995
  it "completes the run" do
828
996
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
829
997
  plugin.run
830
- expect(plugin['network']).not_to be_nil
998
+ expect(plugin["network"]).not_to be_nil
831
999
  end
832
1000
 
833
1001
  it "sets ipaddress" do
834
1002
  plugin.run
835
- expect(plugin['ipaddress']).to eq("10.116.201.76")
1003
+ expect(plugin["ipaddress"]).to eq("10.116.201.76")
836
1004
  end
837
1005
 
838
1006
  # without a source address on the default route we cannot pick the an ipv6 address from the interface
839
1007
  # In the future an RFC6724 compliant process should choose ip6address in the network plugin
840
1008
  it "does not set ip6address" do
841
1009
  plugin.run
842
- expect(plugin['ip6address']).to eq(nil)
1010
+ expect(plugin["ip6address"]).to eq(nil)
843
1011
  end
844
1012
 
845
1013
  context "with only ipv6 routes" do
846
- let(:linux_ip_route) { '' }
1014
+ let(:linux_ip_route) { "" }
847
1015
 
848
1016
  it "sets macaddress to the mac address of the ip6 default interface" do
849
- expect(plugin['macaddress']).to eq("00:AA:BB:CC:DD:EE")
1017
+ expect(plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
850
1018
  end
851
1019
  end
852
1020
 
853
1021
  describe "when about to set macaddress" do
854
1022
  it "sets macaddress" do
855
1023
  plugin.run
856
- expect(plugin['macaddress']).to eq("12:31:3D:02:BE:A2")
1024
+ expect(plugin["macaddress"]).to eq("12:31:3D:02:BE:A2")
857
1025
  end
858
1026
 
859
1027
  context "when then ipv4 interface has the NOARP flag and no ipv6 routes exist" do
860
- let(:linux_ip_route) {
861
- '10.118.19.1 dev tun0 proto kernel src 10.118.19.39
1028
+ let(:linux_ip_route) { <<-EOM
1029
+ 10.118.19.1 dev tun0 proto kernel src 10.118.19.39
862
1030
  default via 172.16.19.1 dev tun0
863
- '
1031
+ EOM
864
1032
  }
865
- let(:linux_ip_route_inet6) { '' }
1033
+ let(:linux_ip_route_inet6) { "" }
866
1034
 
867
1035
  it "completes the run" do
868
1036
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
869
1037
  plugin.run
870
- expect(plugin['network']).not_to be_nil
1038
+ expect(plugin["network"]).not_to be_nil
871
1039
  end
872
1040
 
873
1041
  it "doesn't set macaddress" do
874
1042
  plugin.run
875
- expect(plugin['macaddress']).to be_nil
1043
+ expect(plugin["macaddress"]).to be_nil
876
1044
  end
877
1045
  end
878
1046
  end
879
1047
  end
880
1048
 
881
1049
  describe "with a link level default route" do
882
- let(:linux_ip_route) {
883
- 'default dev venet0 scope link
884
- '
1050
+ let(:linux_ip_route) { <<-EOM
1051
+ default dev venet0 scope link
1052
+ EOM
1053
+ }
1054
+
1055
+ before(:each) do
1056
+ plugin.run
1057
+ end
1058
+
1059
+ it "completes the run" do
1060
+ expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
1061
+ expect(plugin["network"]).not_to be_nil
1062
+ end
1063
+
1064
+ it "doesn't set ipaddress" do
1065
+ expect(plugin["ipaddress"]).to be_nil
1066
+ end
1067
+ end
1068
+
1069
+ describe "with a link level default route to an unaddressed int" do
1070
+ let(:linux_ip_route) { <<-EOM
1071
+ default dev eth3 scope link
1072
+ EOM
885
1073
  }
886
1074
 
887
1075
  before(:each) do
@@ -890,19 +1078,47 @@ default via 172.16.19.1 dev tun0
890
1078
 
891
1079
  it "completes the run" do
892
1080
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
893
- expect(plugin['network']).not_to be_nil
1081
+ expect(plugin["network"]).not_to be_nil
1082
+ end
1083
+
1084
+ it "sets default_interface" do
1085
+ expect(plugin["network"]["default_interface"]).to eq("eth3")
894
1086
  end
895
1087
 
896
1088
  it "doesn't set ipaddress" do
897
- expect(plugin['ipaddress']).to be_nil
1089
+ expect(plugin["ipaddress"]).to be_nil
1090
+ end
1091
+ end
1092
+
1093
+ describe "with a link level default route with a source" do
1094
+ let(:linux_ip_route) { <<-EOM
1095
+ default dev fwdintf scope link src 2.2.2.2
1096
+ EOM
1097
+ }
1098
+
1099
+ before(:each) do
1100
+ plugin.run
1101
+ end
1102
+
1103
+ it "completes the run" do
1104
+ expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
1105
+ expect(plugin["network"]).not_to be_nil
1106
+ end
1107
+
1108
+ it "sets default_interface" do
1109
+ expect(plugin["network"]["default_interface"]).to eq("fwdintf")
1110
+ end
1111
+
1112
+ it "sets ipaddress" do
1113
+ expect(plugin["ipaddress"]).to eq("2.2.2.2")
898
1114
  end
899
1115
  end
900
1116
 
901
1117
  describe "when not having a global scope ipv6 address" do
902
- let(:linux_ip_route_inet6) {
903
- 'fe80::/64 dev eth0 proto kernel metric 256
1118
+ let(:linux_ip_route_inet6) { <<-EOM
1119
+ fe80::/64 dev eth0 proto kernel metric 256
904
1120
  default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7 metric 1024
905
- '
1121
+ EOM
906
1122
  }
907
1123
  before(:each) do
908
1124
  plugin.run
@@ -910,30 +1126,30 @@ default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7
910
1126
 
911
1127
  it "completes the run" do
912
1128
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
913
- expect(plugin['network']).not_to be_nil
1129
+ expect(plugin["network"]).not_to be_nil
914
1130
  end
915
1131
 
916
1132
  it "doesn't set ip6address" do
917
- expect(plugin['ip6address']).to be_nil
1133
+ expect(plugin["ip6address"]).to be_nil
918
1134
  end
919
1135
 
920
1136
  end
921
1137
 
922
1138
  describe "with no default route" do
923
- let(:linux_ip_route) {
924
- '10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
1139
+ let(:linux_ip_route) { <<-EOM
1140
+ 10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
925
1141
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
926
1142
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
927
1143
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
928
1144
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
929
- '
1145
+ EOM
930
1146
  }
931
1147
 
932
- let(:linux_ip_route_inet6) {
933
- 'fe80::/64 dev eth0 proto kernel metric 256
1148
+ let(:linux_ip_route_inet6) { <<-EOM
1149
+ fe80::/64 dev eth0 proto kernel metric 256
934
1150
  fe80::/64 dev eth0.11 proto kernel metric 256
935
1151
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
936
- '
1152
+ EOM
937
1153
  }
938
1154
 
939
1155
  before(:each) do
@@ -942,21 +1158,22 @@ fe80::/64 dev eth0.11 proto kernel metric 256
942
1158
 
943
1159
  it "completes the run" do
944
1160
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
945
- expect(plugin['network']).not_to be_nil
1161
+ expect(plugin["network"]).not_to be_nil
946
1162
  end
947
1163
 
948
1164
  it "doesn't set ipaddress" do
949
- expect(plugin['ipaddress']).to be_nil
1165
+ expect(plugin["ipaddress"]).to be_nil
950
1166
  end
951
1167
 
952
1168
  it "doesn't set ip6address" do
953
- expect(plugin['ip6address']).to be_nil
1169
+ expect(plugin["ip6address"]).to be_nil
954
1170
  end
955
1171
  end
956
1172
 
957
1173
  describe "with openvz setup" do
958
- let(:linux_ip_route) {'default dev venet0 scope link' }
959
- let(:linux_ip_addr) {'1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
1174
+ let(:linux_ip_route) { "default dev venet0 scope link" }
1175
+ let(:linux_ip_addr) { <<-EOM
1176
+ 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
960
1177
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
961
1178
  inet 127.0.0.1/8 scope host lo
962
1179
  inet6 ::1/128 scope host
@@ -967,10 +1184,11 @@ fe80::/64 dev eth0.11 proto kernel metric 256
967
1184
  inet 10.116.201.76/24 brd 10.116.201.255 scope global venet0:0
968
1185
  inet6 2001:44b8:4160:8f00:a00:27ff:fe13:eacd/64 scope global dynamic
969
1186
  valid_lft 6128sec preferred_lft 2526sec
970
- '}
1187
+ EOM
1188
+ }
971
1189
  # We don't have the corresponding ipv6 data for these tests
972
- let(:linux_ip_route_inet6) { '' }
973
- let(:linux_ip_inet6_neighbor_show) { '' }
1190
+ let(:linux_ip_route_inet6) { "" }
1191
+ let(:linux_ip_inet6_neighbor_show) { "" }
974
1192
 
975
1193
  before(:each) do
976
1194
  allow(plugin).to receive(:is_openvz?).and_return true
@@ -980,39 +1198,39 @@ fe80::/64 dev eth0.11 proto kernel metric 256
980
1198
 
981
1199
  it "completes the run" do
982
1200
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
983
- expect(plugin['network']).not_to be_nil
1201
+ expect(plugin["network"]).not_to be_nil
984
1202
  end
985
1203
 
986
1204
  it "sets default ipv4 interface and gateway" do
987
- expect(plugin['network']['default_interface']).to eq('venet0:0')
988
- expect(plugin['network']['default_gateway']).to eq('0.0.0.0')
1205
+ expect(plugin["network"]["default_interface"]).to eq("venet0:0")
1206
+ expect(plugin["network"]["default_gateway"]).to eq("0.0.0.0")
989
1207
  end
990
1208
 
991
1209
  it "sets correct routing information" do
992
- expect(plugin['network']['interfaces']['venet0:0']['routes']).to eq([Mash.new( :destination => "default", :family => "inet", :scope => "link" )])
1210
+ expect(plugin["network"]["interfaces"]["venet0:0"]["routes"]).to eq([Mash.new( :destination => "default", :family => "inet", :scope => "link" )])
993
1211
  end
994
1212
 
995
1213
  it "sets correct address information" do
996
- expect(plugin['network']['interfaces']['venet0:0']['addresses']).to eq("10.116.201.76" => Mash.new(:family => 'inet', :prefixlen => '24', :netmask =>'255.255.255.0', :broadcast => '10.116.201.255', :scope => "Global"))
1214
+ expect(plugin["network"]["interfaces"]["venet0:0"]["addresses"]).to eq("10.116.201.76" => Mash.new(:family => "inet", :prefixlen => "24", :netmask => "255.255.255.0", :broadcast => "10.116.201.255", :scope => "Global"))
997
1215
  end
998
1216
  end
999
1217
 
1000
1218
  describe "with irrelevant routes (container setups)" do
1001
- let(:linux_ip_route) {
1002
- '10.116.201.0/26 dev eth0 proto kernel src 10.116.201.39
1219
+ let(:linux_ip_route) { <<-EOM
1220
+ 10.116.201.0/26 dev eth0 proto kernel src 10.116.201.39
1003
1221
  10.116.201.0/26 dev if4 proto kernel src 10.116.201.45
1004
1222
  10.118.19.0/26 dev eth0 proto kernel src 10.118.19.39
1005
1223
  10.118.19.0/26 dev if5 proto kernel src 10.118.19.45
1006
1224
  default via 10.116.201.1 dev eth0 src 10.116.201.99
1007
- '
1225
+ EOM
1008
1226
  }
1009
1227
 
1010
- let(:linux_ip_route_inet6) {
1011
- 'fe80::/64 dev eth0 proto kernel metric 256
1228
+ let(:linux_ip_route_inet6) { <<-EOM
1229
+ fe80::/64 dev eth0 proto kernel metric 256
1012
1230
  fe80::/64 dev eth0.11 proto kernel metric 256
1013
1231
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::FFFF:2
1014
1232
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1015
- '
1233
+ EOM
1016
1234
  }
1017
1235
 
1018
1236
  before(:each) do
@@ -1021,29 +1239,29 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1021
1239
 
1022
1240
  it "completes the run" do
1023
1241
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
1024
- expect(plugin['network']).not_to be_nil
1242
+ expect(plugin["network"]).not_to be_nil
1025
1243
  end
1026
1244
 
1027
1245
  it "doesn't add bogus routes" do
1028
- expect(plugin['network']['interfaces']['eth0']['routes']).not_to include Mash.new( :destination => "10.116.201.0/26", :proto => "kernel", :family => "inet", :via => "10.116.201.39" )
1029
- expect(plugin['network']['interfaces']['eth0']['routes']).not_to include Mash.new( :destination => "10.118.19.0/26", :proto => "kernel", :family => "inet", :via => "10.118.19.39" )
1030
- expect(plugin['network']['interfaces']['eth0']['routes']).not_to include Mash.new( :destination => "1111:2222:3333:4444::/64", :family => "inet6", :metric => "1024" )
1246
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).not_to include Mash.new( :destination => "10.116.201.0/26", :proto => "kernel", :family => "inet", :via => "10.116.201.39" )
1247
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).not_to include Mash.new( :destination => "10.118.19.0/26", :proto => "kernel", :family => "inet", :via => "10.118.19.39" )
1248
+ expect(plugin["network"]["interfaces"]["eth0"]["routes"]).not_to include Mash.new( :destination => "1111:2222:3333:4444::/64", :family => "inet6", :metric => "1024" )
1031
1249
  end
1032
1250
 
1033
1251
  it "doesn't set ipaddress" do
1034
- expect(plugin['ipaddress']).to be_nil
1252
+ expect(plugin["ipaddress"]).to be_nil
1035
1253
  end
1036
1254
 
1037
1255
  it "doesn't set ip6address" do
1038
- expect(plugin['ip6address']).to be_nil
1256
+ expect(plugin["ip6address"]).to be_nil
1039
1257
  end
1040
1258
  end
1041
1259
 
1042
1260
  # This should never happen in the real world.
1043
1261
  describe "when encountering a surprise interface" do
1044
- let(:linux_ip_route) {
1045
- '192.168.122.0/24 dev virbr0 proto kernel src 192.168.122.1
1046
- '
1262
+ let(:linux_ip_route) { <<-EOM
1263
+ 192.168.122.0/24 dev virbr0 proto kernel src 192.168.122.1
1264
+ EOM
1047
1265
  }
1048
1266
 
1049
1267
  it "logs a message and skips previously unseen interfaces in 'ip route show'" do
@@ -1054,8 +1272,8 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1054
1272
  end
1055
1273
 
1056
1274
  describe "when running with ip version ss131122" do
1057
- let(:linux_ip_link_s_d) {
1058
- '1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT group default
1275
+ let(:linux_ip_link_s_d) { <<-EOM
1276
+ 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT group default
1059
1277
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0
1060
1278
  RX: bytes packets errors dropped overrun mcast
1061
1279
  35224 524 0 0 0 0
@@ -1086,14 +1304,14 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1086
1304
  1392844460 2659966 0 0 0 0
1087
1305
  TX: bytes packets errors dropped carrier collsns
1088
1306
  691785313 1919690 0 0 0 0
1089
- '
1307
+ EOM
1090
1308
  }
1091
1309
 
1092
1310
  it "adds the vlan information of an interface" do
1093
1311
  plugin.run
1094
- expect(plugin['network']['interfaces']['eth0.11']['vlan']['id']).to eq('11')
1095
- expect(plugin['network']['interfaces']['eth0.11']['vlan']['protocol']).to eq('802.1Q')
1096
- expect(plugin['network']['interfaces']['eth0.11']['vlan']['flags']).to eq([ 'REORDER_HDR' ])
1312
+ expect(plugin["network"]["interfaces"]["eth0.11"]["vlan"]["id"]).to eq("11")
1313
+ expect(plugin["network"]["interfaces"]["eth0.11"]["vlan"]["protocol"]).to eq("802.1Q")
1314
+ expect(plugin["network"]["interfaces"]["eth0.11"]["vlan"]["flags"]).to eq([ "REORDER_HDR" ])
1097
1315
  end
1098
1316
  end
1099
1317
  end