ohai 15.3.1 → 15.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
- data/lib/ohai/plugins/aix/network.rb +3 -8
- data/lib/ohai/plugins/darwin/network.rb +6 -4
- data/lib/ohai/plugins/filesystem.rb +166 -0
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +3 -162
- data/Rakefile +0 -42
- data/lib/ohai/plugins/windows/filesystem.rb +0 -147
- data/spec/data/plugins/dpkg-query.output +0 -4
- data/spec/data/plugins/lslpp.output +0 -50
- data/spec/data/plugins/pacman.output +0 -51
- data/spec/data/plugins/pkg-query.output +0 -58
- data/spec/data/plugins/pkginfo.output +0 -50
- data/spec/data/plugins/pkglist.output +0 -24
- data/spec/data/plugins/rpmquery.output +0 -7
- data/spec/functional/application_spec.rb +0 -107
- data/spec/functional/loader_spec.rb +0 -53
- data/spec/functional/plugins/powershell_spec.rb +0 -88
- data/spec/functional/plugins/root_group_spec.rb +0 -41
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
- data/spec/ohai_spec.rb +0 -27
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -124
- data/spec/support/integration_helper.rb +0 -61
- data/spec/support/platform_helpers.rb +0 -38
- data/spec/unit/application_spec.rb +0 -96
- data/spec/unit/config_spec.rb +0 -57
- data/spec/unit/dsl/plugin_spec.rb +0 -634
- data/spec/unit/hints_spec.rb +0 -65
- data/spec/unit/loader_spec.rb +0 -195
- data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
- data/spec/unit/mixin/command_spec.rb +0 -151
- data/spec/unit/mixin/dmi_decode.rb +0 -75
- data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
- data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
- data/spec/unit/plugin_config_spec.rb +0 -117
- data/spec/unit/plugins/abort_spec.rb +0 -69
- data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
- data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
- data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
- data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
- data/spec/unit/plugins/aix/memory_spec.rb +0 -49
- data/spec/unit/plugins/aix/network_spec.rb +0 -313
- data/spec/unit/plugins/aix/platform_spec.rb +0 -44
- data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
- data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
- data/spec/unit/plugins/azure_spec.rb +0 -243
- data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
- data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
- data/spec/unit/plugins/c_spec.rb +0 -341
- data/spec/unit/plugins/chef_spec.rb +0 -44
- data/spec/unit/plugins/cloud_spec.rb +0 -484
- data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
- data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
- data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
- data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
- data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
- data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
- data/spec/unit/plugins/darwin/network_spec.rb +0 -849
- data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
- data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
- data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
- data/spec/unit/plugins/dmi_spec.rb +0 -156
- data/spec/unit/plugins/docker_spec.rb +0 -100
- data/spec/unit/plugins/ec2_spec.rb +0 -452
- data/spec/unit/plugins/elixir_spec.rb +0 -55
- data/spec/unit/plugins/erlang_spec.rb +0 -71
- data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
- data/spec/unit/plugins/fail_spec.rb +0 -260
- data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
- data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/gce_spec.rb +0 -81
- data/spec/unit/plugins/go_spec.rb +0 -48
- data/spec/unit/plugins/groovy_spec.rb +0 -66
- data/spec/unit/plugins/haskell_spec.rb +0 -231
- data/spec/unit/plugins/hostname_spec.rb +0 -162
- data/spec/unit/plugins/init_package_spec.rb +0 -60
- data/spec/unit/plugins/java_spec.rb +0 -230
- data/spec/unit/plugins/joyent_spec.rb +0 -100
- data/spec/unit/plugins/kernel_spec.rb +0 -38
- data/spec/unit/plugins/linode_spec.rb +0 -135
- data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
- data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
- data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
- data/spec/unit/plugins/linux/fips_spec.rb +0 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
- data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
- data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
- data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
- data/spec/unit/plugins/linux/memory_spec.rb +0 -256
- data/spec/unit/plugins/linux/network_spec.rb +0 -1392
- data/spec/unit/plugins/linux/platform_spec.rb +0 -812
- data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
- data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
- data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
- data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
- data/spec/unit/plugins/lua_spec.rb +0 -60
- data/spec/unit/plugins/mono_spec.rb +0 -67
- data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
- data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/network_spec.rb +0 -1078
- data/spec/unit/plugins/nodejs_spec.rb +0 -55
- data/spec/unit/plugins/ohai_spec.rb +0 -32
- data/spec/unit/plugins/ohai_time_spec.rb +0 -44
- data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
- data/spec/unit/plugins/openstack_spec.rb +0 -311
- data/spec/unit/plugins/os_spec.rb +0 -115
- data/spec/unit/plugins/packages_spec.rb +0 -353
- data/spec/unit/plugins/passwd_spec.rb +0 -65
- data/spec/unit/plugins/perl_spec.rb +0 -62
- data/spec/unit/plugins/php_spec.rb +0 -97
- data/spec/unit/plugins/platform_spec.rb +0 -65
- data/spec/unit/plugins/powershell_spec.rb +0 -71
- data/spec/unit/plugins/python_spec.rb +0 -51
- data/spec/unit/plugins/rackspace_spec.rb +0 -350
- data/spec/unit/plugins/root_group_spec.rb +0 -90
- data/spec/unit/plugins/ruby_spec.rb +0 -60
- data/spec/unit/plugins/rust_spec.rb +0 -43
- data/spec/unit/plugins/scala_spec.rb +0 -58
- data/spec/unit/plugins/scaleway_spec.rb +0 -93
- data/spec/unit/plugins/scsi_spec.rb +0 -69
- data/spec/unit/plugins/shard_spec.rb +0 -121
- data/spec/unit/plugins/shells_spec.rb +0 -56
- data/spec/unit/plugins/softlayer_spec.rb +0 -60
- data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
- data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
- data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
- data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
- data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
- data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
- data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
- data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
- data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
- data/spec/unit/plugins/sysconf_spec.rb +0 -680
- data/spec/unit/plugins/timezone_spec.rb +0 -30
- data/spec/unit/plugins/vbox_host_spec.rb +0 -14
- data/spec/unit/plugins/virtualbox_spec.rb +0 -375
- data/spec/unit/plugins/vmware_spec.rb +0 -81
- data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
- data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
- data/spec/unit/plugins/windows/fips_spec.rb +0 -60
- data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
- data/spec/unit/plugins/windows/memory_spec.rb +0 -52
- data/spec/unit/plugins/windows/network_spec.rb +0 -137
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
- data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
- data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
- data/spec/unit/plugins/zpools_spec.rb +0 -244
- data/spec/unit/provides_map_spec.rb +0 -208
- data/spec/unit/runner_spec.rb +0 -422
- data/spec/unit/system_spec.rb +0 -416
- data/spec/unit/util/file_helper_spec.rb +0 -47
- data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2009 VMware, Inc.
|
5
|
-
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
6
|
-
# License:: Apache License, Version 2.0
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
#
|
20
|
-
|
21
|
-
require "spec_helper"
|
22
|
-
|
23
|
-
describe Ohai::System, "plugin lua" do
|
24
|
-
|
25
|
-
let(:plugin) { get_plugin("lua") }
|
26
|
-
|
27
|
-
before do
|
28
|
-
plugin[:languages] = Mash.new
|
29
|
-
@message = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
|
30
|
-
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @message))
|
31
|
-
end
|
32
|
-
|
33
|
-
it "gets the lua version from running lua -v" do
|
34
|
-
expect(plugin).to receive(:shell_out).with("lua -v")
|
35
|
-
plugin.run
|
36
|
-
end
|
37
|
-
|
38
|
-
it "sets languages[:lua][:version]" do
|
39
|
-
plugin.run
|
40
|
-
expect(plugin.languages[:lua][:version]).to eql("5.1.2")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "does not set languages[:lua] if lua command fails" do
|
44
|
-
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(1, "", ""))
|
45
|
-
plugin.run
|
46
|
-
expect(plugin.languages).not_to have_key(:lua)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "does not set languages[:lua] if lua command doesn't exist" do
|
50
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
51
|
-
plugin.run
|
52
|
-
expect(plugin.languages).not_to have_key(:lua)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "sets languages[:lua][:version] when 'lua -v' returns output on stdout not stderr" do
|
56
|
-
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, @message, ""))
|
57
|
-
plugin.run
|
58
|
-
expect(plugin.languages[:lua][:version]).to eql("5.1.2")
|
59
|
-
end
|
60
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
|
-
# Copyright:: Copyright (c) 2009 VMware, Inc.
|
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 "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "plugin mono" do
|
22
|
-
let(:plugin) { get_plugin("mono") }
|
23
|
-
|
24
|
-
before do
|
25
|
-
plugin[:languages] = Mash.new
|
26
|
-
@stdout = <<~OUT
|
27
|
-
Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
|
28
|
-
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
|
29
|
-
TLS: normal
|
30
|
-
SIGSEGV: altstack
|
31
|
-
Notification: kqueue
|
32
|
-
Architecture: amd64
|
33
|
-
Disabled: none
|
34
|
-
Misc: softdebug
|
35
|
-
LLVM: supported, not enabled.
|
36
|
-
GC: sgen
|
37
|
-
OUT
|
38
|
-
allow(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "gets the mono version from running mono -V" do
|
42
|
-
expect(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
|
43
|
-
plugin.run
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets languages[:mono][:version]" do
|
47
|
-
plugin.run
|
48
|
-
expect(plugin.languages[:mono][:version]).to eql("4.2.3")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "sets languages[:mono][:builddate]" do
|
52
|
-
plugin.run
|
53
|
-
expect(plugin.languages[:mono][:builddate]).to eql("Wed Mar 30 13:57:48 PDT 2016")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "does not set the languages[:mono] if mono command fails" do
|
57
|
-
allow(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
|
58
|
-
plugin.run
|
59
|
-
expect(plugin.languages).not_to have_key(:mono)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "does not set languages[:mono] if mono command doesn't exist" do
|
63
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
64
|
-
plugin.run
|
65
|
-
expect(plugin.languages).not_to have_key(:mono)
|
66
|
-
end
|
67
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
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 "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "NetBSD hostname plugin" do
|
22
|
-
before do
|
23
|
-
@plugin = get_plugin("hostname")
|
24
|
-
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
25
|
-
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
|
26
|
-
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
27
|
-
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
|
28
|
-
end
|
29
|
-
|
30
|
-
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
31
|
-
|
32
|
-
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
33
|
-
|
34
|
-
it "uses #resolve_fqdn to find the fqdn" do
|
35
|
-
@plugin.run
|
36
|
-
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the domain to everything after the first dot of the fqdn" do
|
40
|
-
@plugin.run
|
41
|
-
expect(@plugin[:domain]).to eq("bethell")
|
42
|
-
end
|
43
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
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 "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "NetBSD kernel plugin" do
|
22
|
-
before do
|
23
|
-
@plugin = get_plugin("kernel")
|
24
|
-
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
25
|
-
allow(@plugin).to receive(:init_kernel).and_return({})
|
26
|
-
allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
|
27
|
-
allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
|
28
|
-
allow(@plugin).to receive(:shell_out).with((Ohai.abs_path( "/usr/bin/modstat" )).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets the kernel_os to the kernel_name value" do
|
32
|
-
@plugin.run
|
33
|
-
expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
|
34
|
-
end
|
35
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
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 "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "NetBSD plugin platform" do
|
22
|
-
before do
|
23
|
-
@plugin = get_plugin("netbsd/platform")
|
24
|
-
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
|
25
|
-
allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
26
|
-
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "sets platform to lowercased lsb[:id]" do
|
30
|
-
@plugin.run
|
31
|
-
expect(@plugin[:platform]).to eq("netbsd")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "sets platform_version to lsb[:release]" do
|
35
|
-
@plugin.run
|
36
|
-
expect(@plugin[:platform_version]).to eq("4.5")
|
37
|
-
end
|
38
|
-
end
|
@@ -1,1078 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Laurent Desarmes <laurent.desarmes@u-picardie.fr>
|
3
|
-
# Copyright:: Copyright (c) 2012 Laurent Desarmes
|
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 "spec_helper"
|
20
|
-
|
21
|
-
def it_doesnt_fail
|
22
|
-
it "doesnt fail" do
|
23
|
-
allow(@plugin.logger).to receive(:warn)
|
24
|
-
expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
|
25
|
-
@plugin.run
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# basic sanity check that is called in all describes below
|
30
|
-
def it_populates_ipaddress_attributes
|
31
|
-
source = caller[0]
|
32
|
-
|
33
|
-
it "populates ipaddress, macaddress and ip6address" do
|
34
|
-
|
35
|
-
allow(@plugin.logger).to receive(:warn)
|
36
|
-
expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
|
37
|
-
@plugin.run
|
38
|
-
%w{ ipaddress macaddress ip6address }.each do |attribute|
|
39
|
-
expect(@plugin).to have_key(attribute)
|
40
|
-
end
|
41
|
-
rescue Exception
|
42
|
-
puts "RSpec context: #{source}"
|
43
|
-
raise
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe Ohai::System, "Network Plugin" do
|
49
|
-
|
50
|
-
# output of network plugins on particular platforms to mock plugin runs
|
51
|
-
basic_data = {
|
52
|
-
"freebsd" => {
|
53
|
-
"network" => {
|
54
|
-
"interfaces" => {
|
55
|
-
"vr0" => {
|
56
|
-
"type" => "vr",
|
57
|
-
"number" => "0",
|
58
|
-
"flags" => %w{UP BROADCAST RUNNING SIMPLEX MULTICAST},
|
59
|
-
"addresses" => {
|
60
|
-
"00:00:24:c9:5e:b8" => {
|
61
|
-
"family" => "lladdr",
|
62
|
-
},
|
63
|
-
"fe80::200:24ff:fec9:5eb8" => {
|
64
|
-
"family" => "inet6",
|
65
|
-
"zoneid" => "vr0",
|
66
|
-
"prefixlen" => "64",
|
67
|
-
"scopeid" => "0x1",
|
68
|
-
},
|
69
|
-
"76.91.1.255" => {
|
70
|
-
"family" => "inet",
|
71
|
-
"netmask" => "255.255.252.0",
|
72
|
-
"broadcast" => "255.255.255.255",
|
73
|
-
},
|
74
|
-
},
|
75
|
-
"arp" => {
|
76
|
-
"76.91.1.255" => "00:00:24:c9:5e:b8",
|
77
|
-
"76.91.0.1" => "00:01:5c:24:8c:01",
|
78
|
-
},
|
79
|
-
},
|
80
|
-
"vr1" => {
|
81
|
-
"type" => "vr",
|
82
|
-
"number" => "1",
|
83
|
-
"flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST},
|
84
|
-
"addresses" => {
|
85
|
-
"00:00:24:c9:5e:b9" => {
|
86
|
-
"family" => "lladdr",
|
87
|
-
},
|
88
|
-
"fe80::200:24ff:fec9:5eb9" => {
|
89
|
-
"family" => "inet6",
|
90
|
-
"zoneid" => "vr1",
|
91
|
-
"prefixlen" => "64",
|
92
|
-
"scopeid" => "0x2",
|
93
|
-
},
|
94
|
-
},
|
95
|
-
},
|
96
|
-
"vr2" => {
|
97
|
-
"type" => "vr",
|
98
|
-
"number" => "2",
|
99
|
-
"flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST},
|
100
|
-
"addresses" => {
|
101
|
-
"00:00:24:c9:5e:ba" => {
|
102
|
-
"family" => "lladdr",
|
103
|
-
},
|
104
|
-
"fe80::200:24ff:fec9:5eba" => {
|
105
|
-
"family" => "inet6",
|
106
|
-
"zoneid" => "vr2",
|
107
|
-
"prefixlen" => "64",
|
108
|
-
"scopeid" => "0x3",
|
109
|
-
},
|
110
|
-
},
|
111
|
-
},
|
112
|
-
"vr3" => {
|
113
|
-
"type" => "vr",
|
114
|
-
"number" => "3",
|
115
|
-
"flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST},
|
116
|
-
"addresses" => {
|
117
|
-
"00:00:24:c9:5e:bb" => {
|
118
|
-
"family" => "lladdr",
|
119
|
-
},
|
120
|
-
"fe80::200:24ff:fec9:5ebb" => {
|
121
|
-
"family" => "inet6",
|
122
|
-
"zoneid" => "vr3",
|
123
|
-
"prefixlen" => "64",
|
124
|
-
"scopeid" => "0x4",
|
125
|
-
},
|
126
|
-
},
|
127
|
-
},
|
128
|
-
"ipfw0" => {
|
129
|
-
# OHAI-492: Ensure network plugin works with interfaces without addresses.
|
130
|
-
"type" => "ipfw",
|
131
|
-
"number" => "0",
|
132
|
-
"flags" => %w{UP SIMPLEX MULTICAST},
|
133
|
-
},
|
134
|
-
"lo0" => {
|
135
|
-
"type" => "lo",
|
136
|
-
"number" => "0",
|
137
|
-
"flags" => %w{UP LOOPBACK RUNNING MULTICAST},
|
138
|
-
"addresses" => {
|
139
|
-
"127.0.0.1" => {
|
140
|
-
"family" => "inet",
|
141
|
-
"netmask" => "255.0.0.0",
|
142
|
-
},
|
143
|
-
"::1" => {
|
144
|
-
"family" => "inet6",
|
145
|
-
"prefixlen" => "128",
|
146
|
-
},
|
147
|
-
"fe80::1" => {
|
148
|
-
"family" => "inet6",
|
149
|
-
"zoneid" => "lo0",
|
150
|
-
"prefixlen" => "64",
|
151
|
-
"scopeid" => "0x8",
|
152
|
-
},
|
153
|
-
},
|
154
|
-
},
|
155
|
-
"bridge0" => {
|
156
|
-
"type" => "bridge",
|
157
|
-
"number" => "0",
|
158
|
-
"flags" => %w{LEARNING DISCOVER AUTOEDGE AUTOPTP},
|
159
|
-
"addresses" => {
|
160
|
-
"02:20:6f:d2:c4:00" => {
|
161
|
-
"family" => "lladdr",
|
162
|
-
},
|
163
|
-
"192.168.2.1" => {
|
164
|
-
"family" => "inet",
|
165
|
-
"netmask" => "255.255.255.0",
|
166
|
-
"broadcast" => "192.168.2.255",
|
167
|
-
},
|
168
|
-
"2001:470:d:cb4::1" => {
|
169
|
-
"family" => "inet6",
|
170
|
-
"prefixlen" => "64",
|
171
|
-
},
|
172
|
-
"fe80::cafe:babe:dead:beef" => {
|
173
|
-
"family" => "inet6",
|
174
|
-
"zoneid" => "bridge0",
|
175
|
-
"prefixlen" => "64",
|
176
|
-
"scopeid" => "0x9",
|
177
|
-
},
|
178
|
-
},
|
179
|
-
"arp" => {
|
180
|
-
"192.168.2.142" => "60:67:20:75:a2:0c",
|
181
|
-
"192.168.2.205" => "c0:c1:c0:f9:40:ed",
|
182
|
-
"192.168.2.160" => "cc:3a:61:cf:67:13",
|
183
|
-
"192.168.2.1" => "02:20:6f:d2:c4:00",
|
184
|
-
"192.168.2.135" => "f8:0c:f3:d7:c6:b6",
|
185
|
-
"192.168.2.165" => "f8:8f:ca:24:49:ad",
|
186
|
-
"192.168.2.158" => "48:5d:60:1f:ea:d1",
|
187
|
-
"192.168.2.150" => "60:a4:4c:60:b3:d9",
|
188
|
-
},
|
189
|
-
},
|
190
|
-
"gif0" => {
|
191
|
-
"type" => "gif",
|
192
|
-
"number" => "0",
|
193
|
-
"flags" => %w{UP POINTOPOINT RUNNING MULTICAST},
|
194
|
-
"addresses" => {
|
195
|
-
"fe80::200:24ff:fec9:5eb8" => {
|
196
|
-
"family" => "inet6",
|
197
|
-
"zoneid" => "gif0",
|
198
|
-
"prefixlen" => "64",
|
199
|
-
"scopeid" => "0xa",
|
200
|
-
},
|
201
|
-
},
|
202
|
-
},
|
203
|
-
},
|
204
|
-
"default_gateway" => "76.91.0.1",
|
205
|
-
"default_interface" => "vr0",
|
206
|
-
"default_inet6_gateway" => "2001:470:d:cb4::2",
|
207
|
-
"default_inet6_interface" => "bridge0",
|
208
|
-
},
|
209
|
-
},
|
210
|
-
"linux" => {
|
211
|
-
"network" => {
|
212
|
-
# pp Hash[node['network']] from chef-shell to get the network data
|
213
|
-
# have just removed the neighbour and route entries by hand
|
214
|
-
"interfaces" => {
|
215
|
-
"lo" => {
|
216
|
-
"flags" => %w{LOOPBACK UP},
|
217
|
-
"addresses" => {
|
218
|
-
"::1" => {
|
219
|
-
"scope" => "Node",
|
220
|
-
"prefixlen" => "128",
|
221
|
-
"family" => "inet6",
|
222
|
-
},
|
223
|
-
"127.0.0.1" => {
|
224
|
-
"scope" => "Node",
|
225
|
-
"netmask" => "255.0.0.0",
|
226
|
-
"prefixlen" => "8",
|
227
|
-
"family" => "inet",
|
228
|
-
},
|
229
|
-
},
|
230
|
-
"mtu" => "16436",
|
231
|
-
"encapsulation" => "Loopback",
|
232
|
-
"state" => "unknown",
|
233
|
-
},
|
234
|
-
"eth0" => {
|
235
|
-
"flags" => %w{BROADCAST MULTICAST UP},
|
236
|
-
"number" => "0",
|
237
|
-
"addresses" => {
|
238
|
-
"fe80::216:3eff:fe2f:3679" => {
|
239
|
-
"scope" => "Link",
|
240
|
-
"prefixlen" => "64",
|
241
|
-
"family" => "inet6",
|
242
|
-
},
|
243
|
-
"00:16:3E:2F:36:79" => {
|
244
|
-
"family" => "lladdr",
|
245
|
-
},
|
246
|
-
"192.168.66.33" => {
|
247
|
-
"scope" => "Global",
|
248
|
-
"netmask" => "255.255.255.0",
|
249
|
-
"broadcast" => "192.168.66.255",
|
250
|
-
"prefixlen" => "24",
|
251
|
-
"family" => "inet",
|
252
|
-
},
|
253
|
-
"3ffe:1111:2222::33" => {
|
254
|
-
"prefixlen" => "48",
|
255
|
-
"family" => "inet6",
|
256
|
-
"scope" => "Global",
|
257
|
-
"state" => "up",
|
258
|
-
},
|
259
|
-
},
|
260
|
-
"mtu" => "1500",
|
261
|
-
"type" => "eth",
|
262
|
-
"encapsulation" => "Ethernet",
|
263
|
-
},
|
264
|
-
"eth1" => {
|
265
|
-
"flags" => %w{BROADCAST MULTICAST UP},
|
266
|
-
"number" => "1",
|
267
|
-
"addresses" => {
|
268
|
-
"fe80::216:3eff:fe2f:3680" => {
|
269
|
-
"scope" => "Link",
|
270
|
-
"prefixlen" => "64",
|
271
|
-
"family" => "inet6",
|
272
|
-
},
|
273
|
-
"00:16:3E:2F:36:80" => {
|
274
|
-
"family" => "lladdr",
|
275
|
-
},
|
276
|
-
"192.168.99.11" => {
|
277
|
-
"scope" => "Global",
|
278
|
-
"netmask" => "255.255.255.0",
|
279
|
-
"broadcast" => "192.168.99.255",
|
280
|
-
"prefixlen" => "24",
|
281
|
-
"family" => "inet",
|
282
|
-
},
|
283
|
-
"3ffe:1111:3333::1" => {
|
284
|
-
"prefixlen" => "48",
|
285
|
-
"family" => "inet6",
|
286
|
-
"scope" => "Global",
|
287
|
-
},
|
288
|
-
},
|
289
|
-
"mtu" => "1500",
|
290
|
-
"type" => "eth",
|
291
|
-
"encapsulation" => "Ethernet",
|
292
|
-
},
|
293
|
-
},
|
294
|
-
"default_gateway" => "192.168.66.15",
|
295
|
-
"default_interface" => "eth0",
|
296
|
-
"default_inet6_gateway" => "3ffe:1111:2222::",
|
297
|
-
"default_inet6_interface" => "eth0",
|
298
|
-
},
|
299
|
-
},
|
300
|
-
"windows" => {
|
301
|
-
"network" => {
|
302
|
-
"interfaces" => {
|
303
|
-
"0xb" => {
|
304
|
-
"addresses" => {
|
305
|
-
"172.19.0.130" => {
|
306
|
-
"prefixlen" => "24",
|
307
|
-
"netmask" => "255.255.255.0",
|
308
|
-
"broadcast" => "172.19.0.255",
|
309
|
-
"family" => "inet",
|
310
|
-
},
|
311
|
-
"fe80::698d:3e37:7950:b28c" => {
|
312
|
-
"prefixlen" => "64",
|
313
|
-
"family" => "inet6",
|
314
|
-
"scope" => "Link",
|
315
|
-
},
|
316
|
-
"52:54:44:66:66:02" => {
|
317
|
-
"family" => "lladdr",
|
318
|
-
},
|
319
|
-
},
|
320
|
-
"mtu" => nil,
|
321
|
-
"type" => "Ethernet 802.3",
|
322
|
-
"encapsulation" => "Ethernet",
|
323
|
-
},
|
324
|
-
},
|
325
|
-
"default_gateway" => "172.19.0.1",
|
326
|
-
"default_interface" => "0xb",
|
327
|
-
},
|
328
|
-
},
|
329
|
-
}
|
330
|
-
|
331
|
-
describe "on linux" do
|
332
|
-
before do
|
333
|
-
@plugin = get_plugin("network")
|
334
|
-
@plugin["network"] = basic_data["linux"]["network"]
|
335
|
-
end
|
336
|
-
|
337
|
-
describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
|
338
|
-
describe "simple network setup" do
|
339
|
-
it_populates_ipaddress_attributes
|
340
|
-
|
341
|
-
it "detects {ip,ip6,mac}address" do
|
342
|
-
@plugin.run
|
343
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
344
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
345
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "default ipv4 and ipv6 gateway on different interfaces" do
|
350
|
-
describe "both interfaces have an ARP" do
|
351
|
-
before do
|
352
|
-
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
|
353
|
-
@plugin["network"]["default_inet6_interface"] = "eth1"
|
354
|
-
end
|
355
|
-
|
356
|
-
it_populates_ipaddress_attributes
|
357
|
-
|
358
|
-
it "detects {ip,ip6}address" do
|
359
|
-
@plugin.run
|
360
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
361
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
362
|
-
end
|
363
|
-
|
364
|
-
it "set macaddress from the ipv4 setup" do
|
365
|
-
@plugin.run
|
366
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
367
|
-
end
|
368
|
-
|
369
|
-
it "informs about this setup" do
|
370
|
-
expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
|
371
|
-
allow(@plugin.logger).to receive(:trace)
|
372
|
-
@plugin.run
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
describe "ipv4 interface has no ARP" do
|
377
|
-
before do
|
378
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, kv| kv["family"] == "lladdr" }
|
379
|
-
# not really checked by this pluging
|
380
|
-
@plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
|
381
|
-
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
|
382
|
-
@plugin["network"]["default_inet6_interface"] = "eth1"
|
383
|
-
end
|
384
|
-
|
385
|
-
it_populates_ipaddress_attributes
|
386
|
-
|
387
|
-
it "detects {ip,ip6}address" do
|
388
|
-
@plugin.run
|
389
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
390
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
391
|
-
end
|
392
|
-
|
393
|
-
it "sets macaddress to the ipv6 interface because it hadn't set one for ipv4 first" do
|
394
|
-
@plugin.run
|
395
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
396
|
-
end
|
397
|
-
|
398
|
-
it "informs about this setup" do
|
399
|
-
expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
|
400
|
-
allow(@plugin.logger).to receive(:trace)
|
401
|
-
@plugin.run
|
402
|
-
end
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
describe "conflicting results from the linux::network plugin" do
|
407
|
-
describe "default interface doesn't match the default_gateway" do
|
408
|
-
before do
|
409
|
-
@plugin["network"]["default_interface"] = "eth1"
|
410
|
-
@plugin["network"]["default_inet6_interface"] = "eth1"
|
411
|
-
end
|
412
|
-
|
413
|
-
it_populates_ipaddress_attributes
|
414
|
-
|
415
|
-
it "picks {ip,ip6,mac}address" do
|
416
|
-
allow(@plugin.logger).to receive(:warn)
|
417
|
-
@plugin.run
|
418
|
-
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
419
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
420
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
421
|
-
end
|
422
|
-
|
423
|
-
it "warns about this conflict" do
|
424
|
-
expect(@plugin.logger).to receive(:trace).with(%r{\[inet\] no ipaddress/mask on eth1}).once
|
425
|
-
expect(@plugin.logger).to receive(:trace).with(%r{\[inet6\] no ipaddress/mask on eth1}).once
|
426
|
-
allow(@plugin.logger).to receive(:trace)
|
427
|
-
@plugin.run
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
describe "there's a default gateway, none of the configured ip/mask theorically allows to reach it" do
|
432
|
-
before do
|
433
|
-
@plugin["network"]["default_gateway"] = "172.16.12.42"
|
434
|
-
@plugin["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
|
435
|
-
end
|
436
|
-
|
437
|
-
it "picks {ip,ip6,mac}address" do
|
438
|
-
allow(@plugin.logger).to receive(:warn)
|
439
|
-
@plugin.run
|
440
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
441
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
442
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
443
|
-
end
|
444
|
-
|
445
|
-
end
|
446
|
-
|
447
|
-
describe "no ip address for the given default interface/gateway" do
|
448
|
-
before do
|
449
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
|
450
|
-
end
|
451
|
-
|
452
|
-
it_doesnt_fail
|
453
|
-
|
454
|
-
it "doesn't detect {ip,ip6,mac}address" do
|
455
|
-
allow(@plugin.logger).to receive(:warn)
|
456
|
-
@plugin.run
|
457
|
-
expect(@plugin["ipaddress"]).to be_nil
|
458
|
-
expect(@plugin["macaddress"]).to be_nil
|
459
|
-
expect(@plugin["ip6address"]).to be_nil
|
460
|
-
end
|
461
|
-
|
462
|
-
it "warns about this conflict" do
|
463
|
-
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
464
|
-
expect(@plugin.logger).to receive(:warn).with(/\[inet\] no ip address on eth0/).once
|
465
|
-
expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
|
466
|
-
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
|
467
|
-
expect(@plugin.logger).to receive(:warn).with(/\[inet6\] no ip address on eth0/).once
|
468
|
-
@plugin.run
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
describe "no ip at all" do
|
473
|
-
before do
|
474
|
-
@plugin["network"]["default_gateway"] = nil
|
475
|
-
@plugin["network"]["default_interface"] = nil
|
476
|
-
@plugin["network"]["default_inet6_gateway"] = nil
|
477
|
-
@plugin["network"]["default_inet6_interface"] = nil
|
478
|
-
@plugin["network"]["interfaces"].each_value do |val|
|
479
|
-
val["addresses"].delete_if { |k, kv| %w{inet inet6}.include? kv["family"] }
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
|
-
it_doesnt_fail
|
484
|
-
|
485
|
-
it "doesn't detect {ip,ip6,mac}address" do
|
486
|
-
allow(@plugin.logger).to receive(:warn)
|
487
|
-
@plugin.run
|
488
|
-
expect(@plugin["ipaddress"]).to be_nil
|
489
|
-
expect(@plugin["macaddress"]).to be_nil
|
490
|
-
expect(@plugin["ip6address"]).to be_nil
|
491
|
-
end
|
492
|
-
|
493
|
-
it "warns about it" do
|
494
|
-
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
495
|
-
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
|
496
|
-
expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
|
497
|
-
@plugin.run
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
describe "several ipaddresses matching the default route" do
|
503
|
-
describe "bigger prefix not set on the default interface" do
|
504
|
-
before do
|
505
|
-
@plugin["network"]["interfaces"]["eth2"] = {
|
506
|
-
"flags" => %w{BROADCAST MULTICAST UP},
|
507
|
-
"number" => "2",
|
508
|
-
"addresses" => {
|
509
|
-
"fe80::216:3eff:fe2f:3681" => {
|
510
|
-
"scope" => "Link",
|
511
|
-
"prefixlen" => "64",
|
512
|
-
"family" => "inet6",
|
513
|
-
},
|
514
|
-
"00:16:3E:2F:36:81" => { "family" => "lladdr" },
|
515
|
-
"192.168.66.99" => {
|
516
|
-
"scope" => "Global",
|
517
|
-
"netmask" => "255.255.255.128",
|
518
|
-
"broadcast" => "192.168.99.127",
|
519
|
-
"prefixlen" => "25",
|
520
|
-
"family" => "inet",
|
521
|
-
},
|
522
|
-
"3ffe:1111:2222:0:4444::1" => {
|
523
|
-
"prefixlen" => "64",
|
524
|
-
"family" => "inet6",
|
525
|
-
"scope" => "Global",
|
526
|
-
},
|
527
|
-
},
|
528
|
-
}
|
529
|
-
end
|
530
|
-
|
531
|
-
it_populates_ipaddress_attributes
|
532
|
-
|
533
|
-
it "sets {ip,ip6,mac}address correctly" do
|
534
|
-
@plugin.run
|
535
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
536
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
537
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
describe "bigger prefix set on the default interface" do
|
542
|
-
before do
|
543
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
|
544
|
-
"scope" => "Global",
|
545
|
-
"netmask" => "255.255.255.128",
|
546
|
-
"broadcast" => "192.168.66.127",
|
547
|
-
"prefixlen" => "25",
|
548
|
-
"family" => "inet",
|
549
|
-
}
|
550
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
|
551
|
-
"prefixlen" => "64",
|
552
|
-
"family" => "inet6",
|
553
|
-
"scope" => "Global",
|
554
|
-
}
|
555
|
-
end
|
556
|
-
|
557
|
-
it_populates_ipaddress_attributes
|
558
|
-
|
559
|
-
it "sets {ip,ip6,mac}address correctly" do
|
560
|
-
@plugin.run
|
561
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.99")
|
562
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
563
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
describe "smallest ip not set on the default_interface" do
|
568
|
-
before do
|
569
|
-
@plugin["network"]["interfaces"]["eth2"] = {
|
570
|
-
"flags" => %w{BROADCAST MULTICAST UP},
|
571
|
-
"number" => "2",
|
572
|
-
"addresses" => {
|
573
|
-
"fe80::216:3eff:fe2f:3681" => {
|
574
|
-
"scope" => "Link",
|
575
|
-
"prefixlen" => "64",
|
576
|
-
"family" => "inet6",
|
577
|
-
},
|
578
|
-
"00:16:3E:2F:36:81" => { "family" => "lladdr" },
|
579
|
-
"192.168.66.32" => {
|
580
|
-
"scope" => "Global",
|
581
|
-
"netmask" => "255.255.255.0",
|
582
|
-
"broadcast" => "192.168.66.255",
|
583
|
-
"prefixlen" => "24",
|
584
|
-
"family" => "inet",
|
585
|
-
},
|
586
|
-
"3ffe:1111:2222::32" => {
|
587
|
-
"prefixlen" => "48",
|
588
|
-
"family" => "inet6",
|
589
|
-
"scope" => "Global",
|
590
|
-
},
|
591
|
-
},
|
592
|
-
}
|
593
|
-
end
|
594
|
-
|
595
|
-
it_populates_ipaddress_attributes
|
596
|
-
|
597
|
-
it "sets {ip,ip6,mac}address correctly" do
|
598
|
-
@plugin.run
|
599
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
600
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
601
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
602
|
-
end
|
603
|
-
end
|
604
|
-
|
605
|
-
describe "smallest ip set on the default_interface" do
|
606
|
-
before do
|
607
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
|
608
|
-
"scope" => "Global",
|
609
|
-
"netmask" => "255.255.255.0",
|
610
|
-
"broadcast" => "192.168.66.255",
|
611
|
-
"prefixlen" => "24",
|
612
|
-
"family" => "inet",
|
613
|
-
}
|
614
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
|
615
|
-
"prefixlen" => "48",
|
616
|
-
"family" => "inet6",
|
617
|
-
"scope" => "Global",
|
618
|
-
}
|
619
|
-
end
|
620
|
-
|
621
|
-
it_populates_ipaddress_attributes
|
622
|
-
|
623
|
-
it "sets {ip,ip6,mac}address correctly" do
|
624
|
-
@plugin.run
|
625
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.32")
|
626
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
627
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::32")
|
628
|
-
end
|
629
|
-
end
|
630
|
-
end
|
631
|
-
|
632
|
-
describe "no default route" do
|
633
|
-
describe "first interface is not the best choice" do
|
634
|
-
before do
|
635
|
-
@plugin["network"]["default_gateway"] = nil
|
636
|
-
@plugin["network"]["default_interface"] = nil
|
637
|
-
@plugin["network"]["default_inet6_gateway"] = nil
|
638
|
-
@plugin["network"]["default_inet6_interface"] = nil
|
639
|
-
# removing inet* addresses from eth0, to complicate things a bit
|
640
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
|
641
|
-
end
|
642
|
-
|
643
|
-
it_populates_ipaddress_attributes
|
644
|
-
|
645
|
-
it "picks {ip,mac,ip6}address from the first interface" do
|
646
|
-
expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
|
647
|
-
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
|
648
|
-
allow(@plugin.logger).to receive(:trace)
|
649
|
-
@plugin.run
|
650
|
-
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
651
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
652
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
describe "can choose from addresses with different scopes" do
|
657
|
-
before do
|
658
|
-
@plugin["network"]["default_gateway"] = nil
|
659
|
-
@plugin["network"]["default_interface"] = nil
|
660
|
-
@plugin["network"]["default_inet6_gateway"] = nil
|
661
|
-
@plugin["network"]["default_inet6_interface"] = nil
|
662
|
-
# just changing scopes to lInK for eth0 addresses
|
663
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"].each_value { |v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] }
|
664
|
-
end
|
665
|
-
|
666
|
-
it_populates_ipaddress_attributes
|
667
|
-
|
668
|
-
it "prefers global scope addressses to set {ip,mac,ip6}address" do
|
669
|
-
expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
|
670
|
-
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
|
671
|
-
allow(@plugin.logger).to receive(:trace)
|
672
|
-
@plugin.run
|
673
|
-
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
674
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
675
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
676
|
-
end
|
677
|
-
end
|
678
|
-
end
|
679
|
-
|
680
|
-
describe "link level default route" do
|
681
|
-
describe "simple setup" do
|
682
|
-
before do
|
683
|
-
@plugin["network"]["default_gateway"] = "0.0.0.0"
|
684
|
-
@plugin["network"]["default_interface"] = "eth1"
|
685
|
-
@plugin["network"]["default_inet6_gateway"] = "::"
|
686
|
-
@plugin["network"]["default_inet6_interface"] = "eth1"
|
687
|
-
end
|
688
|
-
|
689
|
-
it_populates_ipaddress_attributes
|
690
|
-
|
691
|
-
it "picks {ip,mac,ip6}address from the default interface" do
|
692
|
-
@plugin.run
|
693
|
-
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
694
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
695
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
696
|
-
end
|
697
|
-
end
|
698
|
-
|
699
|
-
describe "fe80::1 as a default gateway" do
|
700
|
-
before do
|
701
|
-
@plugin["network"]["default_inet6_gateway"] = "fe80::1"
|
702
|
-
end
|
703
|
-
|
704
|
-
it_populates_ipaddress_attributes
|
705
|
-
|
706
|
-
it "picks {ip,mac,ip6}address from the default interface" do
|
707
|
-
@plugin.run
|
708
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
709
|
-
end
|
710
|
-
end
|
711
|
-
|
712
|
-
describe "can choose from addresses with different scopes" do
|
713
|
-
before do
|
714
|
-
@plugin["network"]["default_gateway"] = "0.0.0.0"
|
715
|
-
@plugin["network"]["default_interface"] = "eth1"
|
716
|
-
@plugin["network"]["default_inet6_gateway"] = "::"
|
717
|
-
@plugin["network"]["default_inet6_interface"] = "eth1"
|
718
|
-
@plugin["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
|
719
|
-
"scope" => "host",
|
720
|
-
"netmask" => "255.255.255.255",
|
721
|
-
"prefixlen" => "32",
|
722
|
-
"family" => "inet",
|
723
|
-
}
|
724
|
-
end
|
725
|
-
|
726
|
-
it_populates_ipaddress_attributes
|
727
|
-
|
728
|
-
it "picks {ip,mac,ip6}address from the default interface" do
|
729
|
-
@plugin.run
|
730
|
-
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
731
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
732
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
|
733
|
-
end
|
734
|
-
end
|
735
|
-
end
|
736
|
-
|
737
|
-
describe "point to point address" do
|
738
|
-
before do
|
739
|
-
@plugin["network"]["interfaces"]["eth2"] = {
|
740
|
-
"flags" => %w{POINTOPOINT BROADCAST MULTICAST UP},
|
741
|
-
"number" => "2",
|
742
|
-
"addresses" => {
|
743
|
-
"fe80::216:3eff:fe2f:3681" => {
|
744
|
-
"scope" => "Link",
|
745
|
-
"prefixlen" => "64",
|
746
|
-
"family" => "inet6",
|
747
|
-
},
|
748
|
-
"00:16:3E:2F:36:81" => { "family" => "lladdr" },
|
749
|
-
"192.168.66.99" => {
|
750
|
-
"scope" => "Global",
|
751
|
-
"netmask" => "255.255.255.255",
|
752
|
-
"peer" => "192.168.99.126",
|
753
|
-
"prefixlen" => "32",
|
754
|
-
"family" => "inet",
|
755
|
-
},
|
756
|
-
"3ffe:1111:2222:0:4444::1" => {
|
757
|
-
"prefixlen" => "128",
|
758
|
-
"peer" => "3ffe:1111:2222:0:4444::2",
|
759
|
-
"family" => "inet6",
|
760
|
-
"scope" => "Global",
|
761
|
-
},
|
762
|
-
},
|
763
|
-
}
|
764
|
-
@plugin["network"]["default_gateway"] = "192.168.99.126"
|
765
|
-
@plugin["network"]["default_interface"] = "eth2"
|
766
|
-
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
|
767
|
-
@plugin["network"]["default_inet6_interface"] = "eth2"
|
768
|
-
end
|
769
|
-
|
770
|
-
it_populates_ipaddress_attributes
|
771
|
-
|
772
|
-
it "picks {ip,mac,ip6}address from the default interface" do
|
773
|
-
@plugin.run
|
774
|
-
expect(@plugin["ipaddress"]).to eq("192.168.66.99")
|
775
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:81")
|
776
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
describe "ipv6 only node" do
|
781
|
-
before do
|
782
|
-
@plugin["network"]["default_gateway"] = nil
|
783
|
-
@plugin["network"]["default_interface"] = nil
|
784
|
-
@plugin["network"]["interfaces"].each_value do |val|
|
785
|
-
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
786
|
-
end
|
787
|
-
end
|
788
|
-
|
789
|
-
it_doesnt_fail
|
790
|
-
|
791
|
-
it "can't detect ipaddress" do
|
792
|
-
allow(@plugin.logger).to receive(:warn)
|
793
|
-
@plugin.run
|
794
|
-
expect(@plugin["ipaddress"]).to be_nil
|
795
|
-
end
|
796
|
-
|
797
|
-
it "warns about not being able to set {ip,mac}address (ipv4)" do
|
798
|
-
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
799
|
-
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/) # for ipv4
|
800
|
-
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to/) # for ipv6
|
801
|
-
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] Using default interface eth0 and default gateway/) # for ipv6
|
802
|
-
@plugin.run
|
803
|
-
end
|
804
|
-
|
805
|
-
it "sets {ip6,mac}address" do
|
806
|
-
allow(@plugin.logger).to receive(:warn)
|
807
|
-
@plugin.run
|
808
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
809
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
810
|
-
end
|
811
|
-
|
812
|
-
it "informs about macaddress being set using the ipv6 setup" do
|
813
|
-
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
|
814
|
-
allow(@plugin.logger).to receive(:trace)
|
815
|
-
@plugin.run
|
816
|
-
end
|
817
|
-
end
|
818
|
-
|
819
|
-
describe "ipv6 only with ipv4 loopback" do
|
820
|
-
before do
|
821
|
-
@plugin["network"]["default_gateway"] = nil
|
822
|
-
@plugin["network"]["default_interface"] = nil
|
823
|
-
@plugin["network"]["interfaces"].each do |i, iv|
|
824
|
-
next if i == "lo"
|
825
|
-
|
826
|
-
iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
827
|
-
end
|
828
|
-
end
|
829
|
-
|
830
|
-
it_doesnt_fail
|
831
|
-
|
832
|
-
it "can't detect ipaddress" do
|
833
|
-
allow(@plugin.logger).to receive(:warn)
|
834
|
-
@plugin.run
|
835
|
-
expect(@plugin["ipaddress"]).to eq("127.0.0.1")
|
836
|
-
end
|
837
|
-
|
838
|
-
it "sets {ip6,mac}address" do
|
839
|
-
allow(@plugin.logger).to receive(:warn)
|
840
|
-
@plugin.run
|
841
|
-
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
842
|
-
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
843
|
-
end
|
844
|
-
|
845
|
-
it "informs about macaddress being set using the ipv6 setup" do
|
846
|
-
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
|
847
|
-
allow(@plugin.logger).to receive(:trace)
|
848
|
-
@plugin.run
|
849
|
-
end
|
850
|
-
end
|
851
|
-
end
|
852
|
-
|
853
|
-
# specs using network plugin data for each mocked OS (freebsd,linux,windows)
|
854
|
-
basic_data.keys.sort.each do |os|
|
855
|
-
describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
|
856
|
-
before do
|
857
|
-
@plugin["network"] = basic_data[os]["network"]
|
858
|
-
end
|
859
|
-
|
860
|
-
describe "{ip,mac}address are already set" do
|
861
|
-
before do
|
862
|
-
@plugin["ipaddress"] = "10.11.12.13"
|
863
|
-
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
864
|
-
@expected_results = {
|
865
|
-
"freebsd" => {
|
866
|
-
"ip6address" => "2001:470:d:cb4::1",
|
867
|
-
"macaddress" => "02:20:6f:d2:c4:00",
|
868
|
-
},
|
869
|
-
"linux" => {
|
870
|
-
"ip6address" => "3ffe:1111:2222::33",
|
871
|
-
"macaddress" => "00:16:3E:2F:36:79",
|
872
|
-
},
|
873
|
-
"windows" => {
|
874
|
-
"ip6address" => "fe80::698d:3e37:7950:b28c",
|
875
|
-
"macaddress" => "00:AA:BB:CC:DD:EE",
|
876
|
-
},
|
877
|
-
}
|
878
|
-
end
|
879
|
-
|
880
|
-
it_populates_ipaddress_attributes
|
881
|
-
|
882
|
-
it "detects ip6address" do
|
883
|
-
@plugin.run
|
884
|
-
expect(@plugin["ip6address"]).to eq(@expected_results[os]["ip6address"])
|
885
|
-
end
|
886
|
-
|
887
|
-
it "doesn't overwrite {ip,mac}address" do
|
888
|
-
@plugin.run
|
889
|
-
expect(@plugin["ipaddress"]).to eq("10.11.12.13")
|
890
|
-
expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
|
891
|
-
end
|
892
|
-
end
|
893
|
-
|
894
|
-
describe "ip6address is already set" do
|
895
|
-
describe "node has ipv4 and ipv6" do
|
896
|
-
before do
|
897
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
898
|
-
@expected_results = {
|
899
|
-
"freebsd" => {
|
900
|
-
"ipaddress" => "76.91.1.255",
|
901
|
-
"macaddress" => "00:00:24:c9:5e:b8",
|
902
|
-
},
|
903
|
-
"linux" => {
|
904
|
-
"ipaddress" => "192.168.66.33",
|
905
|
-
"macaddress" => "00:16:3E:2F:36:79",
|
906
|
-
},
|
907
|
-
"windows" => {
|
908
|
-
"ipaddress" => "172.19.0.130",
|
909
|
-
"macaddress" => "52:54:44:66:66:02",
|
910
|
-
},
|
911
|
-
}
|
912
|
-
end
|
913
|
-
|
914
|
-
it_populates_ipaddress_attributes
|
915
|
-
|
916
|
-
it "detects {ip,mac}address" do
|
917
|
-
@plugin.run
|
918
|
-
expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
|
919
|
-
expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
|
920
|
-
end
|
921
|
-
|
922
|
-
it "doesn't overwrite ip6address" do
|
923
|
-
@plugin.run
|
924
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
925
|
-
end
|
926
|
-
end
|
927
|
-
|
928
|
-
describe "ipv6 only node" do
|
929
|
-
before do
|
930
|
-
@plugin["network"]["default_gateway"] = nil
|
931
|
-
@plugin["network"]["default_interface"] = nil
|
932
|
-
@plugin["network"]["interfaces"].each_value do |val|
|
933
|
-
if val.key? "addresses"
|
934
|
-
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
935
|
-
end
|
936
|
-
end
|
937
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
938
|
-
@expected_results = {
|
939
|
-
"freebsd" => {
|
940
|
-
"macaddress" => "02:20:6f:d2:c4:00",
|
941
|
-
},
|
942
|
-
"linux" => {
|
943
|
-
"macaddress" => "00:16:3E:2F:36:79",
|
944
|
-
},
|
945
|
-
"windows" => {
|
946
|
-
"macaddress" => "52:54:44:66:66:02",
|
947
|
-
},
|
948
|
-
}
|
949
|
-
end
|
950
|
-
|
951
|
-
it_doesnt_fail
|
952
|
-
|
953
|
-
it "can't detect ipaddress (ipv4)" do
|
954
|
-
allow(@plugin.logger).to receive(:warn)
|
955
|
-
@plugin.run
|
956
|
-
expect(@plugin["ipaddress"]).to be_nil
|
957
|
-
end
|
958
|
-
|
959
|
-
it "takes the macaddress from ipv6" do
|
960
|
-
allow(@plugin.logger).to receive(:warn)
|
961
|
-
@plugin.run
|
962
|
-
expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
|
963
|
-
end
|
964
|
-
|
965
|
-
it "warns about not being able to set ipaddress" do
|
966
|
-
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
967
|
-
@plugin.run
|
968
|
-
end
|
969
|
-
|
970
|
-
it "doesn't overwrite ip6address" do
|
971
|
-
allow(@plugin.logger).to receive(:warn)
|
972
|
-
@plugin.run
|
973
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
974
|
-
end
|
975
|
-
end
|
976
|
-
end
|
977
|
-
|
978
|
-
describe "{mac,ip6}address are already set" do
|
979
|
-
describe "valid ipv4 setup" do
|
980
|
-
before do
|
981
|
-
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
982
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
983
|
-
@expected_results = {
|
984
|
-
"freebsd" => {
|
985
|
-
"ipaddress" => "76.91.1.255",
|
986
|
-
"macaddress" => "00:00:24:c9:5e:b8",
|
987
|
-
},
|
988
|
-
"linux" => {
|
989
|
-
"ipaddress" => "192.168.66.33",
|
990
|
-
"macaddress" => "00:16:3E:2F:36:79",
|
991
|
-
},
|
992
|
-
"windows" => {
|
993
|
-
"ipaddress" => "172.19.0.130",
|
994
|
-
"macaddress" => "52:54:44:66:66:02",
|
995
|
-
},
|
996
|
-
}
|
997
|
-
end
|
998
|
-
|
999
|
-
it_populates_ipaddress_attributes
|
1000
|
-
|
1001
|
-
it "detects ipaddress and does not overwrite macaddress" do
|
1002
|
-
@plugin.run
|
1003
|
-
expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
|
1004
|
-
expect(@plugin["macaddress"]).to eq(@plugin["macaddress"])
|
1005
|
-
end
|
1006
|
-
|
1007
|
-
it "doesn't overwrite ip6address" do
|
1008
|
-
@plugin.run
|
1009
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
1010
|
-
end
|
1011
|
-
end
|
1012
|
-
|
1013
|
-
describe "ipv6 only node" do
|
1014
|
-
before do
|
1015
|
-
@plugin["network"]["default_gateway"] = nil
|
1016
|
-
@plugin["network"]["default_interface"] = nil
|
1017
|
-
@plugin["network"]["interfaces"].each_value do |val|
|
1018
|
-
if val.key? "addresses"
|
1019
|
-
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
1020
|
-
end
|
1021
|
-
end
|
1022
|
-
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
1023
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
1024
|
-
end
|
1025
|
-
|
1026
|
-
it_doesnt_fail
|
1027
|
-
|
1028
|
-
it "can't set ipaddress" do
|
1029
|
-
allow(@plugin.logger).to receive(:warn)
|
1030
|
-
@plugin.run
|
1031
|
-
expect(@plugin["ipaddress"]).to be_nil
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
it "doesn't overwrite {ip6,mac}address" do
|
1035
|
-
allow(@plugin.logger).to receive(:warn)
|
1036
|
-
@plugin.run
|
1037
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
1038
|
-
expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
|
1039
|
-
end
|
1040
|
-
end
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
describe "{ip,mac,ip6}address are already set" do
|
1044
|
-
before do
|
1045
|
-
@plugin["ipaddress"] = "10.11.12.13"
|
1046
|
-
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
1047
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
it_populates_ipaddress_attributes
|
1051
|
-
|
1052
|
-
it "doesn't overwrite {ip,mac,ip6}address" do
|
1053
|
-
@plugin.run
|
1054
|
-
expect(@plugin["ipaddress"]).to eq("10.11.12.13")
|
1055
|
-
expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
|
1056
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
1057
|
-
end
|
1058
|
-
end
|
1059
|
-
|
1060
|
-
describe "{ip,ip6}address are already set" do
|
1061
|
-
before do
|
1062
|
-
@plugin["ipaddress"] = "10.11.12.13"
|
1063
|
-
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
1064
|
-
end
|
1065
|
-
|
1066
|
-
it_doesnt_fail
|
1067
|
-
|
1068
|
-
it "doesn't overwrite {ip,ip6}address" do
|
1069
|
-
@plugin.run
|
1070
|
-
expect(@plugin["ipaddress"]).to eq("10.11.12.13")
|
1071
|
-
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
1072
|
-
end
|
1073
|
-
end
|
1074
|
-
|
1075
|
-
end
|
1076
|
-
end
|
1077
|
-
end
|
1078
|
-
end
|