ohai 8.19.2 → 8.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/common/dmi.rb +12 -12
  4. data/lib/ohai/config.rb +30 -28
  5. data/lib/ohai/loader.rb +1 -1
  6. data/lib/ohai/mixin/command.rb +2 -2
  7. data/lib/ohai/plugins/dmi.rb +1 -1
  8. data/lib/ohai/plugins/ip_scopes.rb +3 -3
  9. data/lib/ohai/plugins/kernel.rb +4 -0
  10. data/lib/ohai/plugins/linux/hostnamectl.rb +34 -0
  11. data/lib/ohai/plugins/linux/machineid.rb +35 -0
  12. data/lib/ohai/plugins/linux/network.rb +1 -1
  13. data/lib/ohai/plugins/linux/virtualization.rb +10 -0
  14. data/lib/ohai/plugins/rackspace.rb +4 -4
  15. data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
  16. data/lib/ohai/plugins/solaris2/filesystem.rb +6 -6
  17. data/lib/ohai/plugins/solaris2/network.rb +8 -8
  18. data/lib/ohai/plugins/windows/cpu.rb +5 -3
  19. data/lib/ohai/plugins/windows/network.rb +59 -37
  20. data/lib/ohai/runner.rb +2 -2
  21. data/lib/ohai/system.rb +2 -2
  22. data/lib/ohai/version.rb +1 -1
  23. data/spec/functional/application_spec.rb +1 -1
  24. data/spec/support/integration_helper.rb +3 -3
  25. data/spec/unit/application_spec.rb +1 -1
  26. data/spec/unit/dsl/plugin_spec.rb +22 -22
  27. data/spec/unit/mixin/ec2_metadata_spec.rb +2 -2
  28. data/spec/unit/mixin/softlayer_metadata_spec.rb +2 -2
  29. data/spec/unit/plugin_config_spec.rb +6 -6
  30. data/spec/unit/plugins/aix/cpu_spec.rb +6 -6
  31. data/spec/unit/plugins/aix/filesystem_spec.rb +8 -8
  32. data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
  33. data/spec/unit/plugins/azure_spec.rb +2 -2
  34. data/spec/unit/plugins/darwin/hardware_spec.rb +3 -3
  35. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
  36. data/spec/unit/plugins/digital_ocean_spec.rb +2 -2
  37. data/spec/unit/plugins/init_package_spec.rb +2 -2
  38. data/spec/unit/plugins/ip_scopes_spec.rb +3 -2
  39. data/spec/unit/plugins/linux/hostnamectl_spec.rb +59 -0
  40. data/spec/unit/plugins/linux/machineid_spec.rb +46 -0
  41. data/spec/unit/plugins/linux/network_spec.rb +113 -77
  42. data/spec/unit/plugins/linux/platform_spec.rb +2 -2
  43. data/spec/unit/plugins/linux/virtualization_spec.rb +20 -0
  44. data/spec/unit/plugins/ruby_spec.rb +3 -2
  45. data/spec/unit/plugins/solaris2/kernel_spec.rb +23 -0
  46. data/spec/unit/runner_spec.rb +74 -74
  47. data/spec/unit/util/ip_helper_spec.rb +2 -2
  48. metadata +7 -3
@@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
19
 
20
20
  describe Ohai::System, "AIX filesystem plugin" do
21
21
  before(:each) do
22
- @df_Pk_LPAR = <<-DF_PK
22
+ @df_pk_lpar = <<-DF_PK
23
23
  Filesystem 1024-blocks Used Available Capacity Mounted on
24
24
  /dev/hd4 2097152 219796 1877356 11% /
25
25
  /dev/hd2 5242880 2416828 2826052 47% /usr
@@ -46,7 +46,7 @@ Filesystem 1024-blocks Used Available Capacity Mounted on
46
46
  /dev/fslv12 10485760 272376 10213384 3% /wpars/toolchain-tester-5c969f/var
47
47
  DF_PK
48
48
 
49
- @df_Pk_WPAR = <<-DF_PK
49
+ @df_pk_wpar = <<-DF_PK
50
50
  Filesystem 1024-blocks Used Available Capacity Mounted on
51
51
  Global 10485760 130872 10354888 2% /
52
52
  Global 5242880 39572 5203308 1% /home
@@ -57,7 +57,7 @@ Global 5242880 2725048 2517832 52% /usr
57
57
  Global 10485760 272376 10213384 3% /var
58
58
  DF_PK
59
59
 
60
- @mount_LPAR = <<-MOUNT
60
+ @mount_lpar = <<-MOUNT
61
61
  node mounted mounted over vfs date options
62
62
  -------- --------------- --------------- ------ ------------ ---------------
63
63
  /dev/hd4 / jfs2 Jul 17 13:22 rw,log=/dev/hd8
@@ -71,7 +71,7 @@ DF_PK
71
71
  192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
72
72
  MOUNT
73
73
 
74
- @mount_WPAR = <<-MOUNT
74
+ @mount_wpar = <<-MOUNT
75
75
  node mounted mounted over vfs date options
76
76
  -------- --------------- --------------- ------ ------------ ---------------
77
77
  Global / jfs2 Nov 23 21:03 rw,log=NULL
@@ -91,8 +91,8 @@ MOUNT
91
91
 
92
92
  context "when run within an LPAR" do
93
93
  before do
94
- allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_LPAR, nil))
95
- allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_LPAR, nil))
94
+ allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_lpar, nil))
95
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_lpar, nil))
96
96
  @plugin.run
97
97
  end
98
98
 
@@ -153,8 +153,8 @@ MOUNT
153
153
 
154
154
  context "when run within a WPAR" do
155
155
  before do
156
- allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_WPAR, nil))
157
- allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_WPAR, nil))
156
+ allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_wpar, nil))
157
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_wpar, nil))
158
158
  @plugin.run
159
159
  end
160
160
 
@@ -27,12 +27,12 @@ describe Ohai::System, "AIX virtualization plugin" do
27
27
  allow(p).to receive(:collect_os).and_return(:aix)
28
28
  allow(p).to receive(:shell_out).with("uname -L").and_return(mock_shell_out(0, "29 l273pp027", nil))
29
29
  allow(p).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
30
- allow(p).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, @lswpar_L, nil))
30
+ allow(p).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, @lswpar_l, nil))
31
31
  p
32
32
  end
33
33
 
34
34
  before(:each) do
35
- @lswpar_L = <<-LSWPAR_L
35
+ @lswpar_l = <<-LSWPAR_L
36
36
  =================================================================
37
37
  applejack-541ba3 - Active
38
38
  =================================================================
@@ -21,7 +21,7 @@ require "open-uri"
21
21
 
22
22
  describe Ohai::System, "plugin azure" do
23
23
  let(:plugin) { get_plugin("azure") }
24
- let(:hint) {
24
+ let(:hint) do
25
25
  {
26
26
  "public_ip" => "137.135.46.202",
27
27
  "vm_name" => "test-vm",
@@ -29,7 +29,7 @@ describe Ohai::System, "plugin azure" do
29
29
  "public_ssh_port" => "22",
30
30
  "public_winrm_port" => "5985",
31
31
  }
32
- }
32
+ end
33
33
 
34
34
  shared_examples_for "!azure" do
35
35
  it "does not set the azure attribute" do
@@ -27,7 +27,7 @@ describe Ohai::System, "Darwin hardware plugin", :unix_only do
27
27
  allow(plugin).to receive(:shell_out).with(
28
28
  "system_profiler SPHardwareDataType -xml"
29
29
  ).and_return(
30
- mock_shell_out(0, HardwareSystemProfilerOutput::Hardware, "")
30
+ mock_shell_out(0, HardwareSystemProfilerOutput::HARDWARE, "")
31
31
  )
32
32
 
33
33
  allow(plugin).to receive(:shell_out).with(
@@ -57,13 +57,13 @@ describe Ohai::System, "Darwin hardware plugin", :unix_only do
57
57
  allow(plugin).to receive(:shell_out).with(
58
58
  "system_profiler SPStorageDataType -xml"
59
59
  ).and_return(
60
- mock_shell_out(0, HardwareSystemProfilerOutput::Storage, "")
60
+ mock_shell_out(0, HardwareSystemProfilerOutput::STORAGE, "")
61
61
  )
62
62
 
63
63
  allow(plugin).to receive(:shell_out).with(
64
64
  "system_profiler SPPowerDataType -xml"
65
65
  ).and_return(
66
- mock_shell_out(0, HardwareSystemProfilerOutput::Power, "")
66
+ mock_shell_out(0, HardwareSystemProfilerOutput::POWER, "")
67
67
  )
68
68
  end
69
69
 
@@ -1,5 +1,5 @@
1
1
  module HardwareSystemProfilerOutput
2
- Hardware = <<hardware_output
2
+ HARDWARE = <<hardware_output
3
3
  <?xml version="1.0" encoding="UTF-8"?>
4
4
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5
5
  <plist version="1.0">
@@ -289,7 +289,7 @@ module HardwareSystemProfilerOutput
289
289
  </plist>
290
290
  hardware_output
291
291
 
292
- Storage = <<storage_output
292
+ STORAGE = <<storage_output
293
293
  <?xml version="1.0" encoding="UTF-8"?>
294
294
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
295
295
  <plist version="1.0">
@@ -600,7 +600,7 @@ hardware_output
600
600
  </plist>
601
601
  storage_output
602
602
 
603
- Power = <<power_output
603
+ POWER = <<power_output
604
604
  <?xml version="1.0" encoding="UTF-8"?>
605
605
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
606
606
  <plist version="1.0">
@@ -21,7 +21,7 @@ require "spec_helper"
21
21
  describe Ohai::System, "plugin digital_ocean" do
22
22
  let(:plugin) { get_plugin("digital_ocean") }
23
23
  let(:digitalocean_path) { "/etc/digitalocean" }
24
- let(:hint) {
24
+ let(:hint) do
25
25
  {
26
26
  "droplet_id" => 12345678,
27
27
  "name" => "example.com",
@@ -33,7 +33,7 @@ describe Ohai::System, "plugin digital_ocean" do
33
33
  "private" => "5.6.7.8",
34
34
  },
35
35
  }
36
- }
36
+ end
37
37
 
38
38
  before do
39
39
  plugin[:network] = {
@@ -19,11 +19,11 @@
19
19
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
20
20
 
21
21
  describe Ohai::System, "Init package" do
22
- let(:plugin) {
22
+ let(:plugin) do
23
23
  p = get_plugin("init_package")
24
24
  allow(p).to receive(:collect_os).and_return("linux")
25
25
  p
26
- }
26
+ end
27
27
 
28
28
  let(:proc1_content) { "init\n" }
29
29
  let(:proc1_exists) { true }
@@ -8,9 +8,10 @@ end
8
8
  describe Ohai::System, "plugin ip_scopes" do
9
9
  let(:plugin) { get_plugin("ip_scopes") }
10
10
  let(:network) { Mash.new(:interfaces => interfaces) }
11
- let(:interfaces) { Hash[
11
+ let(:interfaces) do
12
+ Hash[
12
13
  interface1, { :addresses => addresses1, :type => interface1_type },
13
- interface2, { :addresses => addresses2, :type => interface2_type }] }
14
+ interface2, { :addresses => addresses2, :type => interface2_type }] end
14
15
  let(:interface1) { :eth0 }
15
16
  let(:interface2) { :eth1 }
16
17
  let(:addresses1) { {} }
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Davide Cavalca <dcavalca@fb.com>
3
+ # Copyright:: Copyright (c) 2016 Facebook
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
+
21
+ describe Ohai::System, "Linux hostnamectl plugin" do
22
+ let(:plugin) { get_plugin("linux/hostnamectl") }
23
+
24
+ before(:each) do
25
+ allow(plugin).to receive(:collect_os).and_return(:linux)
26
+ end
27
+
28
+ it "should populate hostnamectl if hostnamectl is available" do
29
+ hostnamectl_out = <<-HOSTNAMECTL_OUT
30
+ Static hostname: foo
31
+ Icon name: computer-laptop
32
+ Chassis: laptop
33
+ Machine ID: 6f702523e2fc7499eb1dc68e5314dacf
34
+ Boot ID: e085ae9e65e245a8a7b62912adeebe97
35
+ Operating System: Debian GNU/Linux 8 (jessie)
36
+ Kernel: Linux 4.3.0-0.bpo.1-amd64
37
+ Architecture: x86-64
38
+ HOSTNAMECTL_OUT
39
+
40
+ allow(plugin).to receive(:which).with("hostnamectl").and_return("/bin/hostnamectl")
41
+ allow(plugin).to receive(:shell_out).with("/bin/hostnamectl").and_return(mock_shell_out(0, hostnamectl_out, ""))
42
+ plugin.run
43
+ expect(plugin[:hostnamectl].to_hash).to eq({
44
+ "static_hostname" => "foo",
45
+ "icon_name" => "computer-laptop",
46
+ "chassis" => "laptop",
47
+ "machine_id" => "6f702523e2fc7499eb1dc68e5314dacf",
48
+ "boot_id" => "e085ae9e65e245a8a7b62912adeebe97",
49
+ "operating_system" => "Debian GNU/Linux 8 (jessie)",
50
+ "kernel" => "Linux 4.3.0-0.bpo.1-amd64",
51
+ "architecture" => "x86-64",
52
+ })
53
+ end
54
+
55
+ it "should not populate hostnamectl if hostnamectl is not available" do
56
+ allow(plugin).to receive(:which).with("hostnamectl").and_return(false)
57
+ expect(plugin[:hostnamectl]).to eq(nil)
58
+ end
59
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Davide Cavalca <dcavalca@fb.com>
3
+ # Copyright:: Copyright (c) 2016 Facebook
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
+
21
+ describe Ohai::System, "Machine id plugin" do
22
+ let(:plugin) { get_plugin("linux/machineid") }
23
+
24
+ before(:each) do
25
+ allow(plugin).to receive(:collect_os).and_return(:linux)
26
+ end
27
+
28
+ it "should read /etc/machine-id if available" do
29
+ machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
30
+
31
+ allow(File).to receive(:exists?).with("/etc/machine-id").and_return(true)
32
+ allow(File).to receive(:read).with("/etc/machine-id").and_return(machine_id)
33
+ plugin.run
34
+ expect(plugin[:machine_id]).to eq(machine_id)
35
+ end
36
+
37
+ it "should read /var/lib/dbus/machine-id if available" do
38
+ machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
39
+
40
+ allow(File).to receive(:exists?).with("/etc/machine-id").and_return(false)
41
+ allow(File).to receive(:exists?).with("/var/lib/dbus/machine-id").and_return(true)
42
+ allow(File).to receive(:read).with("/var/lib/dbus/machine-id").and_return(machine_id)
43
+ plugin.run
44
+ expect(plugin[:machine_id]).to eq(machine_id)
45
+ end
46
+ end
@@ -29,7 +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) { <<-EOM
32
+ let(:linux_ifconfig) do
33
+ <<-EOM
33
34
  eth0 Link encap:Ethernet HWaddr 12:31:3D:02:BE:A2
34
35
  inet addr:10.116.201.76 Bcast:10.116.201.255 Mask:255.255.255.0
35
36
  inet6 addr: fe80::1031:3dff:fe02:bea2/64 Scope:Link
@@ -149,9 +150,10 @@ fwdintf Link encap:Ethernet HWaddr 00:00:00:00:00:0a
149
150
  EOM
150
151
  # Note that ifconfig shows foo:veth0@eth0 but fails to show any address information.
151
152
  # This was not a mistake collecting the output and Apparently ifconfig is broken in this regard.
152
- }
153
+ end
153
154
 
154
- let(:linux_ip_route) { <<-EOM
155
+ let(:linux_ip_route) do
156
+ <<-EOM
155
157
  10.116.201.0/24 dev eth0 proto kernel
156
158
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
157
159
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
@@ -160,26 +162,29 @@ EOM
160
162
  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
161
163
  default via 10.116.201.1 dev eth0
162
164
  EOM
163
- }
165
+ end
164
166
 
165
- let(:linux_route_n) { <<-EOM
167
+ let(:linux_route_n) do
168
+ <<-EOM
166
169
  Kernel IP routing table
167
170
  Destination Gateway Genmask Flags Metric Ref Use Iface
168
171
  10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169
172
  169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
170
173
  0.0.0.0 10.116.201.1 0.0.0.0 UG 0 0 0 eth0
171
174
  EOM
172
- }
175
+ end
173
176
 
174
- let(:linux_ip_route_inet6) { <<-EOM
177
+ let(:linux_ip_route_inet6) do
178
+ <<-EOM
175
179
  fe80::/64 dev eth0 proto kernel metric 256
176
180
  fe80::/64 dev eth0.11 proto kernel metric 256
177
181
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 expires 86023sec
178
182
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
179
183
  EOM
180
- }
184
+ end
181
185
 
182
- let(:linux_ip_addr) { <<-EOM
186
+ let(:linux_ip_addr) do
187
+ <<-EOM
183
188
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
184
189
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
185
190
  inet 127.0.0.1/8 scope host lo
@@ -236,9 +241,10 @@ EOM
236
241
  13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
237
242
  link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff
238
243
  EOM
239
- }
244
+ end
240
245
 
241
- let(:linux_ip_link_s_d) { <<-EOM
246
+ let(:linux_ip_link_s_d) do
247
+ <<-EOM
242
248
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
243
249
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
244
250
  RX: bytes packets errors dropped overrun mcast
@@ -295,26 +301,30 @@ EOM
295
301
  TX: bytes packets errors dropped carrier collsns
296
302
  140 2 0 1 0 0
297
303
  EOM
298
- }
304
+ end
299
305
 
300
- let(:linux_arp_an) { <<-EOM
306
+ let(:linux_arp_an) do
307
+ <<-EOM
301
308
  ? (10.116.201.1) at fe:ff:ff:ff:ff:ff [ether] on eth0
302
309
  EOM
303
- }
310
+ end
304
311
 
305
- let(:linux_ip_neighbor_show) { <<-EOM
312
+ let(:linux_ip_neighbor_show) do
313
+ <<-EOM
306
314
  10.116.201.1 dev eth0 lladdr fe:ff:ff:ff:ff:ff REACHABLE
307
315
  EOM
308
- }
316
+ end
309
317
 
310
- let(:linux_ip_inet6_neighbor_show) { <<-EOM
318
+ let(:linux_ip_inet6_neighbor_show) do
319
+ <<-EOM
311
320
  1111:2222:3333:4444::1 dev eth0.11 lladdr 00:1c:0e:12:34:56 router REACHABLE
312
321
  fe80::21c:eff:fe12:3456 dev eth0.11 lladdr 00:1c:0e:30:28:00 router REACHABLE
313
322
  fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
314
323
  EOM
315
- }
324
+ end
316
325
 
317
- let(:linux_ethtool) { <<-EOM
326
+ let(:linux_ethtool) do
327
+ <<-EOM
318
328
  Settings for eth0:
319
329
  Supported ports: [ FIBRE ]
320
330
  Supported link modes: 1000baseT/Full
@@ -337,9 +347,10 @@ Settings for eth0:
337
347
  drv probe link
338
348
  Link detected: yes
339
349
  EOM
340
- }
350
+ end
341
351
 
342
- let(:linux_ethtool_g) { <<-EOM
352
+ let(:linux_ethtool_g) do
353
+ <<-EOM
343
354
  Ring parameters for eth0:
344
355
  Pre-set maximums:
345
356
  RX: 8192
@@ -353,7 +364,7 @@ RX Jumbo: 0
353
364
  TX: 8192
354
365
 
355
366
  EOM
356
- }
367
+ end
357
368
 
358
369
  before(:each) do
359
370
  allow(plugin).to receive(:collect_os).and_return(:linux)
@@ -392,7 +403,7 @@ EOM
392
403
  end
393
404
  end
394
405
 
395
- describe '#interface_has_no_addresses_in_family?' do
406
+ describe "#interface_has_no_addresses_in_family?" do
396
407
  context "when interface has no addresses" do
397
408
  let(:iface) { {} }
398
409
 
@@ -418,7 +429,7 @@ EOM
418
429
  end
419
430
  end
420
431
 
421
- describe '#interface_have_address?' do
432
+ describe "#interface_have_address?" do
422
433
  context "when interface has no addresses" do
423
434
  let(:iface) { {} }
424
435
 
@@ -444,7 +455,7 @@ EOM
444
455
  end
445
456
  end
446
457
 
447
- describe '#interface_address_not_link_level?' do
458
+ describe "#interface_address_not_link_level?" do
448
459
  context "when the address scope is link" do
449
460
  let(:iface) { { addresses: { "1.2.3.4" => { scope: "Link" } } } }
450
461
 
@@ -462,7 +473,7 @@ EOM
462
473
  end
463
474
  end
464
475
 
465
- describe '#interface_valid_for_route?' do
476
+ describe "#interface_valid_for_route?" do
466
477
  let(:iface) { double("iface") }
467
478
  let(:address) { "1.2.3.4" }
468
479
  let(:family) { "inet" }
@@ -508,7 +519,7 @@ EOM
508
519
  end
509
520
  end
510
521
 
511
- describe '#route_is_valid_default_route?' do
522
+ describe "#route_is_valid_default_route?" do
512
523
  context "when the route destination is default" do
513
524
  let(:route) { { destination: "default" } }
514
525
  let(:default_route) { double("default_route") }
@@ -722,19 +733,21 @@ EOM
722
733
  end
723
734
 
724
735
  describe "with a link level default route" do
725
- let(:linux_ip_route) { <<-EOM
736
+ let(:linux_ip_route) do
737
+ <<-EOM
726
738
  10.116.201.0/24 dev eth0 proto kernel
727
739
  default dev eth0 scope link
728
740
  EOM
729
- }
741
+ end
730
742
 
731
- let(:linux_route_n) { <<-EOM
743
+ let(:linux_route_n) do
744
+ <<-EOM
732
745
  Kernel IP routing table
733
746
  Destination Gateway Genmask Flags Metric Ref Use Iface
734
747
  10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
735
748
  0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
736
749
  EOM
737
- }
750
+ end
738
751
 
739
752
  before(:each) do
740
753
  plugin.run
@@ -750,19 +763,21 @@ EOM
750
763
  end
751
764
 
752
765
  describe "with a subinterface" do
753
- let(:linux_ip_route) { <<-EOM
766
+ let(:linux_ip_route) do
767
+ <<-EOM
754
768
  192.168.0.0/24 dev eth0.11 proto kernel src 192.168.0.2
755
769
  default via 192.168.0.15 dev eth0.11
756
770
  EOM
757
- }
771
+ end
758
772
 
759
- let(:linux_route_n) { <<-EOM
773
+ let(:linux_route_n) do
774
+ <<-EOM
760
775
  Kernel IP routing table
761
776
  Destination Gateway Genmask Flags Metric Ref Use Iface
762
777
  192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0.11
763
778
  0.0.0.0 192.168.0.15 0.0.0.0 UG 0 0 0 eth0.11
764
779
  EOM
765
- }
780
+ end
766
781
 
767
782
  before(:each) do
768
783
  plugin.run
@@ -857,12 +872,13 @@ EOM
857
872
  end
858
873
 
859
874
  describe "when there isn't a source field in route entries and no ipv6 default routes" do
860
- let(:linux_ip_route_inet6) { <<-EOM
875
+ let(:linux_ip_route_inet6) do
876
+ <<-EOM
861
877
  fe80::/64 dev eth0 proto kernel metric 256
862
878
  fe80::/64 dev eth0.11 proto kernel metric 256
863
879
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 expires 86023sec
864
880
  EOM
865
- }
881
+ end
866
882
 
867
883
  before(:each) do
868
884
  plugin.run
@@ -882,7 +898,8 @@ EOM
882
898
  end
883
899
 
884
900
  describe "when there's a source field in the default route entry" do
885
- let(:linux_ip_route) { <<-EOM
901
+ let(:linux_ip_route) do
902
+ <<-EOM
886
903
  10.116.201.0/24 dev eth0 proto kernel
887
904
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
888
905
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
@@ -890,15 +907,16 @@ EOM
890
907
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
891
908
  default via 10.116.201.1 dev eth0 src 10.116.201.76
892
909
  EOM
893
- }
910
+ end
894
911
 
895
- let(:linux_ip_route_inet6) { <<-EOM
912
+ let(:linux_ip_route_inet6) do
913
+ <<-EOM
896
914
  fe80::/64 dev eth0 proto kernel metric 256
897
915
  fe80::/64 dev eth0.11 proto kernel metric 256
898
916
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024
899
917
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
900
918
  EOM
901
- }
919
+ end
902
920
 
903
921
  before(:each) do
904
922
  plugin.run
@@ -919,7 +937,8 @@ EOM
919
937
  end
920
938
 
921
939
  describe "when there're several default routes" do
922
- let(:linux_ip_route) { <<-EOM
940
+ let(:linux_ip_route) do
941
+ <<-EOM
923
942
  10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
924
943
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
925
944
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
@@ -928,16 +947,17 @@ EOM
928
947
  default via 10.116.201.1 dev eth0 metric 10
929
948
  default via 10.116.201.254 dev eth0 metric 9
930
949
  EOM
931
- }
950
+ end
932
951
 
933
- let(:linux_ip_route_inet6) { <<-EOM
952
+ let(:linux_ip_route_inet6) do
953
+ <<-EOM
934
954
  fe80::/64 dev eth0 proto kernel metric 256
935
955
  fe80::/64 dev eth0.11 proto kernel metric 256
936
956
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
937
957
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
938
958
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023
939
959
  EOM
940
- }
960
+ end
941
961
 
942
962
  before(:each) do
943
963
  plugin.run
@@ -960,7 +980,8 @@ EOM
960
980
  end
961
981
 
962
982
  describe "when there're a mixed setup of routes that could be used to set ipaddress" do
963
- let(:linux_ip_route) { <<-EOM
983
+ let(:linux_ip_route) do
984
+ <<-EOM
964
985
  10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
965
986
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
966
987
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
@@ -969,16 +990,17 @@ EOM
969
990
  default via 10.116.201.1 dev eth0 metric 10
970
991
  default via 10.116.201.254 dev eth0 metric 9 src 10.116.201.74
971
992
  EOM
972
- }
993
+ end
973
994
 
974
- let(:linux_ip_route_inet6) { <<-EOM
995
+ let(:linux_ip_route_inet6) do
996
+ <<-EOM
975
997
  fe80::/64 dev eth0 proto kernel metric 256
976
998
  fe80::/64 dev eth0.11 proto kernel metric 256
977
999
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
978
1000
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
979
1001
  default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:3333:4444::2
980
1002
  EOM
981
- }
1003
+ end
982
1004
 
983
1005
  before(:each) do
984
1006
  plugin.run
@@ -999,7 +1021,8 @@ EOM
999
1021
  end
1000
1022
 
1001
1023
  describe "when there's a source field in a local route entry but it isnt in the default route" do
1002
- let(:linux_ip_route) { <<-EOM
1024
+ let(:linux_ip_route) do
1025
+ <<-EOM
1003
1026
  10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
1004
1027
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
1005
1028
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
@@ -1007,15 +1030,16 @@ EOM
1007
1030
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
1008
1031
  default via 10.116.201.1 dev eth0
1009
1032
  EOM
1010
- }
1033
+ end
1011
1034
 
1012
- let(:linux_ip_route_inet6) { <<-EOM
1035
+ let(:linux_ip_route_inet6) do
1036
+ <<-EOM
1013
1037
  fe80::/64 dev eth0 proto kernel metric 256
1014
1038
  fe80::/64 dev eth0.11 proto kernel metric 256
1015
1039
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
1016
1040
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1017
1041
  EOM
1018
- }
1042
+ end
1019
1043
 
1020
1044
  it "completes the run" do
1021
1045
  expect(Ohai::Log).not_to receive(:debug).with(/Plugin linux::network threw exception/)
@@ -1050,11 +1074,12 @@ EOM
1050
1074
  end
1051
1075
 
1052
1076
  context "when then ipv4 interface has the NOARP flag and no ipv6 routes exist" do
1053
- let(:linux_ip_route) { <<-EOM
1077
+ let(:linux_ip_route) do
1078
+ <<-EOM
1054
1079
  10.118.19.1 dev tun0 proto kernel src 10.118.19.39
1055
1080
  default via 172.16.19.1 dev tun0
1056
1081
  EOM
1057
- }
1082
+ end
1058
1083
  let(:linux_ip_route_inet6) { "" }
1059
1084
 
1060
1085
  it "completes the run" do
@@ -1072,10 +1097,11 @@ EOM
1072
1097
  end
1073
1098
 
1074
1099
  describe "with a link level default route" do
1075
- let(:linux_ip_route) { <<-EOM
1100
+ let(:linux_ip_route) do
1101
+ <<-EOM
1076
1102
  default dev venet0 scope link
1077
1103
  EOM
1078
- }
1104
+ end
1079
1105
 
1080
1106
  before(:each) do
1081
1107
  plugin.run
@@ -1092,10 +1118,11 @@ EOM
1092
1118
  end
1093
1119
 
1094
1120
  describe "with a link level default route to an unaddressed int" do
1095
- let(:linux_ip_route) { <<-EOM
1121
+ let(:linux_ip_route) do
1122
+ <<-EOM
1096
1123
  default dev eth3 scope link
1097
1124
  EOM
1098
- }
1125
+ end
1099
1126
 
1100
1127
  before(:each) do
1101
1128
  plugin.run
@@ -1116,10 +1143,11 @@ EOM
1116
1143
  end
1117
1144
 
1118
1145
  describe "with a link level default route with a source" do
1119
- let(:linux_ip_route) { <<-EOM
1146
+ let(:linux_ip_route) do
1147
+ <<-EOM
1120
1148
  default dev fwdintf scope link src 2.2.2.2
1121
1149
  EOM
1122
- }
1150
+ end
1123
1151
 
1124
1152
  before(:each) do
1125
1153
  plugin.run
@@ -1140,11 +1168,12 @@ EOM
1140
1168
  end
1141
1169
 
1142
1170
  describe "when not having a global scope ipv6 address" do
1143
- let(:linux_ip_route_inet6) { <<-EOM
1171
+ let(:linux_ip_route_inet6) do
1172
+ <<-EOM
1144
1173
  fe80::/64 dev eth0 proto kernel metric 256
1145
1174
  default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7 metric 1024
1146
1175
  EOM
1147
- }
1176
+ end
1148
1177
  before(:each) do
1149
1178
  plugin.run
1150
1179
  end
@@ -1161,21 +1190,23 @@ EOM
1161
1190
  end
1162
1191
 
1163
1192
  describe "with no default route" do
1164
- let(:linux_ip_route) { <<-EOM
1193
+ let(:linux_ip_route) do
1194
+ <<-EOM
1165
1195
  10.116.201.0/24 dev eth0 proto kernel src 10.116.201.76
1166
1196
  192.168.5.0/24 dev eth0 proto kernel src 192.168.5.1
1167
1197
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
1168
1198
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
1169
1199
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
1170
1200
  EOM
1171
- }
1201
+ end
1172
1202
 
1173
- let(:linux_ip_route_inet6) { <<-EOM
1203
+ let(:linux_ip_route_inet6) do
1204
+ <<-EOM
1174
1205
  fe80::/64 dev eth0 proto kernel metric 256
1175
1206
  fe80::/64 dev eth0.11 proto kernel metric 256
1176
1207
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
1177
1208
  EOM
1178
- }
1209
+ end
1179
1210
 
1180
1211
  before(:each) do
1181
1212
  plugin.run
@@ -1197,7 +1228,8 @@ EOM
1197
1228
 
1198
1229
  describe "with openvz setup" do
1199
1230
  let(:linux_ip_route) { "default dev venet0 scope link" }
1200
- let(:linux_ip_addr) { <<-EOM
1231
+ let(:linux_ip_addr) do
1232
+ <<-EOM
1201
1233
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
1202
1234
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
1203
1235
  inet 127.0.0.1/8 scope host lo
@@ -1210,7 +1242,7 @@ EOM
1210
1242
  inet6 2001:44b8:4160:8f00:a00:27ff:fe13:eacd/64 scope global dynamic
1211
1243
  valid_lft 6128sec preferred_lft 2526sec
1212
1244
  EOM
1213
- }
1245
+ end
1214
1246
  # We don't have the corresponding ipv6 data for these tests
1215
1247
  let(:linux_ip_route_inet6) { "" }
1216
1248
  let(:linux_ip_inet6_neighbor_show) { "" }
@@ -1241,22 +1273,24 @@ EOM
1241
1273
  end
1242
1274
 
1243
1275
  describe "with irrelevant routes (container setups)" do
1244
- let(:linux_ip_route) { <<-EOM
1276
+ let(:linux_ip_route) do
1277
+ <<-EOM
1245
1278
  10.116.201.0/26 dev eth0 proto kernel src 10.116.201.39
1246
1279
  10.116.201.0/26 dev if4 proto kernel src 10.116.201.45
1247
1280
  10.118.19.0/26 dev eth0 proto kernel src 10.118.19.39
1248
1281
  10.118.19.0/26 dev if5 proto kernel src 10.118.19.45
1249
1282
  default via 10.116.201.1 dev eth0 src 10.116.201.99
1250
1283
  EOM
1251
- }
1284
+ end
1252
1285
 
1253
- let(:linux_ip_route_inet6) { <<-EOM
1286
+ let(:linux_ip_route_inet6) do
1287
+ <<-EOM
1254
1288
  fe80::/64 dev eth0 proto kernel metric 256
1255
1289
  fe80::/64 dev eth0.11 proto kernel metric 256
1256
1290
  1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::FFFF:2
1257
1291
  default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
1258
1292
  EOM
1259
- }
1293
+ end
1260
1294
 
1261
1295
  before(:each) do
1262
1296
  plugin.run
@@ -1284,10 +1318,11 @@ EOM
1284
1318
 
1285
1319
  # This should never happen in the real world.
1286
1320
  describe "when encountering a surprise interface" do
1287
- let(:linux_ip_route) { <<-EOM
1321
+ let(:linux_ip_route) do
1322
+ <<-EOM
1288
1323
  192.168.122.0/24 dev virbr0 proto kernel src 192.168.122.1
1289
1324
  EOM
1290
- }
1325
+ end
1291
1326
 
1292
1327
  it "logs a message and skips previously unseen interfaces in 'ip route show'" do
1293
1328
  expect(Ohai::Log).to receive(:debug).with("Skipping previously unseen interface from 'ip route show': virbr0").once
@@ -1297,7 +1332,8 @@ EOM
1297
1332
  end
1298
1333
 
1299
1334
  describe "when running with ip version ss131122" do
1300
- let(:linux_ip_link_s_d) { <<-EOM
1335
+ let(:linux_ip_link_s_d) do
1336
+ <<-EOM
1301
1337
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT group default
1302
1338
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0
1303
1339
  RX: bytes packets errors dropped overrun mcast
@@ -1330,7 +1366,7 @@ EOM
1330
1366
  TX: bytes packets errors dropped carrier collsns
1331
1367
  691785313 1919690 0 0 0 0
1332
1368
  EOM
1333
- }
1369
+ end
1334
1370
 
1335
1371
  it "adds the vlan information of an interface" do
1336
1372
  plugin.run