ohai 8.10.0 → 8.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Rakefile +13 -4
- data/bin/ohai +3 -4
- data/lib/ohai.rb +4 -4
- data/lib/ohai/application.rb +7 -6
- data/lib/ohai/common/dmi.rb +56 -56
- data/lib/ohai/config.rb +12 -8
- data/lib/ohai/dsl.rb +3 -3
- data/lib/ohai/dsl/plugin.rb +5 -5
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +1 -0
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +7 -7
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mash.rb +3 -2
- data/lib/ohai/mixin/command.rb +25 -23
- data/lib/ohai/mixin/dmi_decode.rb +10 -10
- data/lib/ohai/mixin/ec2_metadata.rb +40 -39
- data/lib/ohai/mixin/gce_metadata.rb +9 -9
- data/lib/ohai/mixin/network_constants.rb +1 -1
- data/lib/ohai/mixin/os.rb +3 -3
- data/lib/ohai/mixin/seconds_to_human.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +10 -10
- data/lib/ohai/mixin/string.rb +2 -2
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/cpu.rb +2 -2
- data/lib/ohai/plugins/aix/filesystem.rb +2 -2
- data/lib/ohai/plugins/aix/memory.rb +2 -2
- data/lib/ohai/plugins/aix/network.rb +9 -10
- data/lib/ohai/plugins/aix/os.rb +2 -2
- data/lib/ohai/plugins/aix/uptime.rb +3 -3
- data/lib/ohai/plugins/aix/virtualization.rb +23 -23
- data/lib/ohai/plugins/azure.rb +32 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +22 -22
- data/lib/ohai/plugins/c.rb +3 -3
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +59 -60
- data/lib/ohai/plugins/cloud_v2.rb +37 -39
- data/lib/ohai/plugins/darwin/cpu.rb +1 -1
- data/lib/ohai/plugins/darwin/filesystem2.rb +5 -5
- data/lib/ohai/plugins/darwin/memory.rb +5 -6
- data/lib/ohai/plugins/darwin/network.rb +7 -7
- data/lib/ohai/plugins/darwin/system_profiler.rb +32 -33
- data/lib/ohai/plugins/darwin/virtualization.rb +9 -9
- data/lib/ohai/plugins/digital_ocean.rb +16 -16
- data/lib/ohai/plugins/dmi.rb +6 -6
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +2 -2
- data/lib/ohai/plugins/dragonflybsd/memory.rb +0 -1
- data/lib/ohai/plugins/dragonflybsd/network.rb +4 -4
- data/lib/ohai/plugins/dragonflybsd/os.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +39 -15
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +3 -3
- data/lib/ohai/plugins/eucalyptus.rb +16 -12
- data/lib/ohai/plugins/freebsd/cpu.rb +2 -2
- data/lib/ohai/plugins/freebsd/memory.rb +0 -1
- data/lib/ohai/plugins/freebsd/network.rb +4 -4
- data/lib/ohai/plugins/freebsd/os.rb +1 -1
- data/lib/ohai/plugins/gce.rb +6 -6
- data/lib/ohai/plugins/hostname.rb +7 -7
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/ip_scopes.rb +9 -9
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/joyent.rb +7 -7
- data/lib/ohai/plugins/kernel.rb +8 -8
- data/lib/ohai/plugins/linode.rb +7 -4
- data/lib/ohai/plugins/linux/cpu.rb +5 -5
- data/lib/ohai/plugins/linux/filesystem.rb +16 -16
- data/lib/ohai/plugins/linux/filesystem2.rb +15 -15
- data/lib/ohai/plugins/linux/mdadm.rb +3 -3
- data/lib/ohai/plugins/linux/network.rb +85 -51
- data/lib/ohai/plugins/linux/platform.rb +24 -24
- data/lib/ohai/plugins/linux/virtualization.rb +8 -8
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/cpu.rb +1 -1
- data/lib/ohai/plugins/netbsd/network.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/network_listeners.rb +30 -26
- data/lib/ohai/plugins/ohai.rb +3 -3
- data/lib/ohai/plugins/openbsd/cpu.rb +4 -4
- data/lib/ohai/plugins/openbsd/memory.rb +4 -4
- data/lib/ohai/plugins/openbsd/network.rb +3 -3
- data/lib/ohai/plugins/openstack.rb +12 -12
- data/lib/ohai/plugins/os.rb +2 -2
- data/lib/ohai/plugins/packages.rb +22 -22
- data/lib/ohai/plugins/passwd.rb +4 -4
- data/lib/ohai/plugins/powershell.rb +9 -9
- data/lib/ohai/plugins/ps.rb +2 -2
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +13 -13
- data/lib/ohai/plugins/root_group.rb +4 -4
- data/lib/ohai/plugins/ruby.rb +6 -6
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/sigar/cpu.rb +1 -1
- data/lib/ohai/plugins/sigar/filesystem.rb +1 -1
- data/lib/ohai/plugins/sigar/network.rb +13 -13
- data/lib/ohai/plugins/sigar/network_route.rb +34 -29
- data/lib/ohai/plugins/softlayer.rb +8 -7
- data/lib/ohai/plugins/solaris2/cpu.rb +19 -19
- data/lib/ohai/plugins/solaris2/dmi.rb +63 -63
- data/lib/ohai/plugins/solaris2/filesystem.rb +13 -13
- data/lib/ohai/plugins/solaris2/memory.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +5 -5
- data/lib/ohai/plugins/solaris2/virtualization.rb +18 -18
- data/lib/ohai/plugins/solaris2/zpools.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +2 -2
- data/lib/ohai/plugins/uptime.rb +4 -5
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/virtualization.rb +17 -17
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +14 -14
- data/lib/ohai/plugins/windows/drivers.rb +8 -8
- data/lib/ohai/plugins/windows/filesystem.rb +4 -4
- data/lib/ohai/plugins/windows/memory.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +10 -10
- data/lib/ohai/plugins/windows/platform.rb +1 -2
- data/lib/ohai/plugins/windows/virtualization.rb +17 -17
- data/lib/ohai/provides_map.rb +7 -7
- data/lib/ohai/runner.rb +3 -3
- data/lib/ohai/system.rb +21 -20
- data/lib/ohai/util/file_helper.rb +1 -2
- data/lib/ohai/util/ip_helper.rb +4 -4
- data/lib/ohai/util/win32.rb +5 -5
- data/lib/ohai/util/win32/group_helper.rb +4 -5
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +7 -5
- data/spec/functional/application_spec.rb +23 -23
- data/spec/functional/loader_spec.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +13 -13
- data/spec/functional/plugins/root_group_spec.rb +5 -5
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -9
- data/spec/support/integration_helper.rb +7 -7
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/unit/application_spec.rb +17 -17
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/dsl/plugin_spec.rb +28 -28
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +9 -9
- data/spec/unit/mixin/command_spec.rb +5 -5
- data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
- data/spec/unit/mixin/softlayer_metadata_spec.rb +19 -23
- data/spec/unit/plugin_config_spec.rb +5 -5
- data/spec/unit/plugins/abort_spec.rb +3 -3
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +25 -25
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -2
- data/spec/unit/plugins/aix/kernel_spec.rb +3 -3
- data/spec/unit/plugins/aix/memory_spec.rb +8 -8
- data/spec/unit/plugins/aix/network_spec.rb +38 -38
- data/spec/unit/plugins/aix/os_spec.rb +1 -2
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +11 -11
- data/spec/unit/plugins/azure_spec.rb +118 -20
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +4 -4
- data/spec/unit/plugins/c_spec.rb +12 -12
- data/spec/unit/plugins/chef_spec.rb +2 -2
- data/spec/unit/plugins/cloud_spec.rb +37 -37
- data/spec/unit/plugins/cloud_v2_spec.rb +64 -65
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -2
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -4
- data/spec/unit/plugins/darwin/kernel_spec.rb +6 -10
- data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
- data/spec/unit/plugins/darwin/network_spec.rb +352 -353
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -2
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +3 -3
- data/spec/unit/plugins/darwin/virtualization_spec.rb +6 -6
- data/spec/unit/plugins/digital_ocean_spec.rb +38 -37
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +97 -88
- data/spec/unit/plugins/elixir_spec.rb +1 -2
- data/spec/unit/plugins/erlang_spec.rb +2 -2
- data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
- data/spec/unit/plugins/fail_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/cpu_spec.rb +14 -14
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -3
- data/spec/unit/plugins/freebsd/os_spec.rb +4 -5
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/gce_spec.rb +9 -9
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -2
- data/spec/unit/plugins/hostname_spec.rb +1 -2
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +38 -38
- data/spec/unit/plugins/java_spec.rb +52 -1
- data/spec/unit/plugins/joyent_spec.rb +9 -11
- data/spec/unit/plugins/kernel_spec.rb +11 -12
- data/spec/unit/plugins/linode_spec.rb +29 -29
- data/spec/unit/plugins/linux/block_device_spec.rb +21 -21
- data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
- data/spec/unit/plugins/linux/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/linux/filesystem_spec.rb +85 -86
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -3
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -2
- data/spec/unit/plugins/linux/mdadm_spec.rb +4 -4
- data/spec/unit/plugins/linux/memory_spec.rb +29 -33
- data/spec/unit/plugins/linux/network_spec.rb +463 -245
- data/spec/unit/plugins/linux/platform_spec.rb +64 -65
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -2
- data/spec/unit/plugins/linux/virtualization_spec.rb +42 -42
- data/spec/unit/plugins/lua_spec.rb +1 -2
- data/spec/unit/plugins/mono_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +118 -118
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/openstack_spec.rb +35 -37
- data/spec/unit/plugins/os_spec.rb +7 -8
- data/spec/unit/plugins/packages_spec.rb +118 -118
- data/spec/unit/plugins/passwd_spec.rb +18 -18
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +4 -4
- data/spec/unit/plugins/platform_spec.rb +8 -9
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +66 -68
- data/spec/unit/plugins/root_group_spec.rb +26 -26
- data/spec/unit/plugins/ruby_spec.rb +14 -15
- data/spec/unit/plugins/rust_spec.rb +2 -2
- data/spec/unit/plugins/sigar/network_route_spec.rb +36 -36
- data/spec/unit/plugins/softlayer_spec.rb +10 -10
- data/spec/unit/plugins/solaris2/cpu_spec.rb +20 -21
- data/spec/unit/plugins/solaris2/dmi_spec.rb +5 -6
- data/spec/unit/plugins/solaris2/filesystem.rb +5 -5
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/memory_spec.rb +5 -5
- data/spec/unit/plugins/solaris2/network_spec.rb +7 -8
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +3 -5
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +19 -19
- data/spec/unit/plugins/vmware_spec.rb +28 -28
- data/spec/unit/plugins/windows/cpu_spec.rb +46 -48
- data/spec/unit/plugins/windows/memory_spec.rb +5 -5
- data/spec/unit/plugins/windows/virtualization_spec.rb +163 -163
- data/spec/unit/provides_map_spec.rb +10 -10
- data/spec/unit/runner_spec.rb +10 -10
- data/spec/unit/system_spec.rb +19 -19
- data/spec/unit/util/file_helper_spec.rb +5 -6
- data/spec/unit/util/ip_helper_spec.rb +39 -39
- 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__) +
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
|
21
21
|
|
22
22
|
begin
|
23
|
-
require
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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(
|
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[
|
543
|
+
expect(plugin["network"]).not_to be_nil
|
375
544
|
end
|
376
545
|
|
377
546
|
it "detects the interfaces" do
|
378
|
-
expect(plugin[
|
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[
|
383
|
-
expect(plugin[
|
384
|
-
expect(plugin[
|
385
|
-
expect(plugin[
|
386
|
-
expect(plugin[
|
387
|
-
expect(plugin[
|
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[
|
392
|
-
expect(plugin[
|
393
|
-
expect(plugin[
|
394
|
-
expect(plugin[
|
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[
|
399
|
-
expect(plugin[
|
400
|
-
expect(plugin[
|
401
|
-
expect(plugin[
|
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[
|
406
|
-
expect(plugin[
|
407
|
-
expect(plugin[
|
408
|
-
expect(plugin[
|
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
|
413
|
-
expect(plugin[
|
414
|
-
expect(plugin[
|
415
|
-
expect(plugin[
|
416
|
-
expect(plugin[
|
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[
|
422
|
-
expect(plugin[
|
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[
|
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[
|
600
|
+
expect(plugin["network"]["interfaces"]["eth0"]["flags"].sort).to eq(%w{BROADCAST MULTICAST RUNNING UP})
|
432
601
|
else
|
433
|
-
expect(plugin[
|
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[
|
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[
|
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[
|
447
|
-
expect(plugin[
|
448
|
-
expect(plugin[
|
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[
|
453
|
-
expect(plugin[
|
454
|
-
expect(plugin[
|
455
|
-
expect(plugin[
|
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[
|
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[
|
633
|
+
expect(plugin["network"]["interfaces"]["lo"]["flags"].sort).to eq(%w{LOOPBACK RUNNING UP})
|
465
634
|
else
|
466
|
-
expect(plugin[
|
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[
|
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[
|
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[
|
489
|
-
expect(plugin[
|
490
|
-
expect(plugin[
|
491
|
-
expect(plugin[
|
492
|
-
expect(plugin[
|
493
|
-
expect(plugin[
|
494
|
-
expect(plugin[
|
495
|
-
|
496
|
-
expect(plugin[
|
497
|
-
expect(plugin[
|
498
|
-
expect(plugin[
|
499
|
-
expect(plugin[
|
500
|
-
expect(plugin[
|
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[
|
505
|
-
expect(plugin[
|
506
|
-
expect(plugin[
|
507
|
-
expect(plugin[
|
508
|
-
expect(plugin[
|
509
|
-
expect(plugin[
|
510
|
-
|
511
|
-
expect(plugin[
|
512
|
-
expect(plugin[
|
513
|
-
expect(plugin[
|
514
|
-
expect(plugin[
|
515
|
-
expect(plugin[
|
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[
|
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[
|
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
|
-
|
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
|
-
|
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[
|
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[
|
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
|
-
|
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
|
-
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
620
|
-
expect(plugin[
|
621
|
-
expect(plugin[
|
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[
|
626
|
-
expect(plugin[
|
627
|
-
expect(plugin[
|
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[
|
632
|
-
expect(plugin[
|
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[
|
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[
|
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[
|
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[
|
658
|
-
expect(plugin[
|
659
|
-
expect(plugin[
|
660
|
-
expect(plugin[
|
661
|
-
expect(plugin[
|
662
|
-
expect(plugin[
|
663
|
-
expect(plugin[
|
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
|
-
|
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[
|
847
|
+
expect(plugin["ipaddress"]).to be nil
|
680
848
|
end
|
681
849
|
|
682
850
|
it "doesn't set macaddress" do
|
683
|
-
expect(plugin[
|
851
|
+
expect(plugin["macaddress"]).to be nil
|
684
852
|
end
|
685
853
|
|
686
854
|
it "doesn't set ip6address" do
|
687
|
-
expect(plugin[
|
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
|
-
|
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
|
-
|
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[
|
884
|
+
expect(plugin["network"]).not_to be_nil
|
717
885
|
end
|
718
886
|
|
719
887
|
it "sets ipaddress" do
|
720
|
-
expect(plugin[
|
888
|
+
expect(plugin["ipaddress"]).to eq("10.116.201.76")
|
721
889
|
end
|
722
890
|
|
723
891
|
it "sets ip6address" do
|
724
|
-
expect(plugin[
|
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
|
-
|
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
|
-
|
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[
|
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[
|
760
|
-
expect(plugin[
|
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[
|
765
|
-
expect(plugin[
|
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
|
-
|
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
|
-
|
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[
|
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
|
-
|
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
|
-
|
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[
|
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[
|
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[
|
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[
|
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[
|
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
|
-
|
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[
|
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[
|
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
|
-
|
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[
|
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[
|
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
|
-
|
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[
|
1129
|
+
expect(plugin["network"]).not_to be_nil
|
914
1130
|
end
|
915
1131
|
|
916
1132
|
it "doesn't set ip6address" do
|
917
|
-
expect(plugin[
|
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
|
-
|
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
|
-
|
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[
|
1161
|
+
expect(plugin["network"]).not_to be_nil
|
946
1162
|
end
|
947
1163
|
|
948
1164
|
it "doesn't set ipaddress" do
|
949
|
-
expect(plugin[
|
1165
|
+
expect(plugin["ipaddress"]).to be_nil
|
950
1166
|
end
|
951
1167
|
|
952
1168
|
it "doesn't set ip6address" do
|
953
|
-
expect(plugin[
|
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) {
|
959
|
-
let(:linux_ip_addr) {
|
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[
|
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[
|
988
|
-
expect(plugin[
|
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[
|
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[
|
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
|
-
|
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
|
-
|
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[
|
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[
|
1029
|
-
expect(plugin[
|
1030
|
-
expect(plugin[
|
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[
|
1252
|
+
expect(plugin["ipaddress"]).to be_nil
|
1035
1253
|
end
|
1036
1254
|
|
1037
1255
|
it "doesn't set ip6address" do
|
1038
|
-
expect(plugin[
|
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
|
-
|
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
|
-
|
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[
|
1095
|
-
expect(plugin[
|
1096
|
-
expect(plugin[
|
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
|