ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -22,32 +22,27 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
|
|
22
22
|
describe Ohai::System, "plugin mono" do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
28
|
-
@status = 0
|
25
|
+
@plugin = get_plugin("mono")
|
26
|
+
@plugin[:languages] = Mash.new
|
29
27
|
@stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
|
30
|
-
@
|
31
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr])
|
28
|
+
@plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
|
32
29
|
end
|
33
30
|
|
34
31
|
it "should get the mono version from running mono -V" do
|
35
|
-
@
|
36
|
-
@
|
32
|
+
@plugin.should_receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
|
33
|
+
@plugin.run
|
37
34
|
end
|
38
35
|
|
39
36
|
it "should set languages[:mono][:version]" do
|
40
|
-
@
|
41
|
-
@
|
37
|
+
@plugin.run
|
38
|
+
@plugin.languages[:mono][:version].should eql("1.2.6")
|
42
39
|
end
|
43
40
|
|
44
41
|
it "should not set the languages[:mono] tree up if mono command fails" do
|
45
|
-
@status = 1
|
46
42
|
@stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@ohai.languages.should_not have_key(:mono)
|
43
|
+
@plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
|
44
|
+
@plugin.run
|
45
|
+
@plugin.languages.should_not have_key(:mono)
|
51
46
|
end
|
52
47
|
|
53
48
|
end
|
@@ -21,14 +21,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "NetBSD hostname plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
24
|
+
@plugin = get_plugin("hostname")
|
25
|
+
@plugin.stub(:collect_os).and_return(:netbsd)
|
26
|
+
@plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
|
27
|
+
@plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
28
|
+
@plugin.stub(:resolve_fqdn).and_return("katie.bethell")
|
29
29
|
end
|
30
30
|
|
31
|
-
it_should_check_from("
|
31
|
+
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
32
32
|
|
33
|
-
it_should_check_from("
|
33
|
+
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
34
|
+
|
35
|
+
it "should use #resolve_fqdn to find the fqdn" do
|
36
|
+
@plugin.run
|
37
|
+
@plugin[:fqdn].should == "katie.bethell"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should set the domain to everything after the first dot of the fqdn" do
|
41
|
+
@plugin.run
|
42
|
+
@plugin[:domain].should == "bethell"
|
43
|
+
end
|
34
44
|
end
|
@@ -21,16 +21,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "NetBSD kernel plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
24
|
+
@plugin = get_plugin("kernel")
|
25
|
+
@plugin.stub(:collect_os).and_return(:netbsd)
|
26
|
+
@plugin.stub(:init_kernel).and_return({})
|
27
|
+
@plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
|
28
|
+
@plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
|
29
|
+
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/bin/modstat" )}").and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should set the kernel_os to the kernel_name value" do
|
33
|
-
@
|
34
|
-
@
|
33
|
+
@plugin.run
|
34
|
+
@plugin[:kernel][:os].should == @plugin[:kernel][:name]
|
35
35
|
end
|
36
36
|
end
|
@@ -16,25 +16,23 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
21
20
|
|
22
21
|
describe Ohai::System, "NetBSD plugin platform" do
|
23
22
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@ohai[:os] = "netbsd"
|
23
|
+
@plugin = get_plugin("netbsd/platform")
|
24
|
+
@plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
|
25
|
+
@plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
26
|
+
@plugin.stub(:collect_os).and_return(:netbsd)
|
29
27
|
end
|
30
28
|
|
31
29
|
it "should set platform to lowercased lsb[:id]" do
|
32
|
-
@
|
33
|
-
@
|
30
|
+
@plugin.run
|
31
|
+
@plugin[:platform].should == "netbsd"
|
34
32
|
end
|
35
33
|
|
36
34
|
it "should set platform_version to lsb[:release]" do
|
37
|
-
@
|
38
|
-
@
|
35
|
+
@plugin.run
|
36
|
+
@plugin[:platform_version].should == "4.5"
|
39
37
|
end
|
40
38
|
end
|
@@ -20,11 +20,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
def it_does_not_fail
|
22
22
|
it "doesn't fail" do
|
23
|
-
Ohai::Log.
|
23
|
+
Ohai::Log.stub(:warn)
|
24
24
|
Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/)
|
25
|
-
@
|
26
|
-
%w
|
27
|
-
@
|
25
|
+
@plugin.run
|
26
|
+
%w{ ipaddress macaddress ip6address }.each do |attribute|
|
27
|
+
@plugin.should have_key(attribute)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,6 +32,143 @@ end
|
|
32
32
|
describe Ohai::System, "Network Plugin" do
|
33
33
|
|
34
34
|
basic_data = {
|
35
|
+
"freebsd" => {
|
36
|
+
"network" => {
|
37
|
+
"interfaces" => {
|
38
|
+
"vr0" => {
|
39
|
+
"type" => "vr",
|
40
|
+
"number" => "0",
|
41
|
+
"flags" => ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"],
|
42
|
+
"addresses" => {
|
43
|
+
"00:00:24:c9:5e:b8" => {"family" => "lladdr"},
|
44
|
+
"fe80::200:24ff:fec9:5eb8" => {
|
45
|
+
"family" => "inet6",
|
46
|
+
"zoneid" => "vr0",
|
47
|
+
"prefixlen" => "64",
|
48
|
+
"scopeid" => "0x1"
|
49
|
+
},
|
50
|
+
"76.91.1.255" => {
|
51
|
+
"family" => "inet",
|
52
|
+
"netmask" => "255.255.252.0",
|
53
|
+
"broadcast" => "255.255.255.255"
|
54
|
+
}
|
55
|
+
},
|
56
|
+
"arp" => {
|
57
|
+
"76.91.1.255" => "00:00:24:c9:5e:b8",
|
58
|
+
"76.91.0.1" => "00:01:5c:24:8c:01"
|
59
|
+
}
|
60
|
+
},
|
61
|
+
"vr1" => {
|
62
|
+
"type" => "vr",
|
63
|
+
"number" => "1",
|
64
|
+
"flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
|
65
|
+
"addresses" => {
|
66
|
+
"00:00:24:c9:5e:b9" => {"family" => "lladdr"},
|
67
|
+
"fe80::200:24ff:fec9:5eb9" => {
|
68
|
+
"family" => "inet6",
|
69
|
+
"zoneid" => "vr1",
|
70
|
+
"prefixlen" => "64",
|
71
|
+
"scopeid" => "0x2"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"vr2" => {
|
76
|
+
"type" => "vr",
|
77
|
+
"number" => "2",
|
78
|
+
"flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
|
79
|
+
"addresses" => {
|
80
|
+
"00:00:24:c9:5e:ba" => {"family" => "lladdr"},
|
81
|
+
"fe80::200:24ff:fec9:5eba" => {
|
82
|
+
"family" => "inet6",
|
83
|
+
"zoneid" => "vr2",
|
84
|
+
"prefixlen" => "64",
|
85
|
+
"scopeid" => "0x3"
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
"vr3" => {
|
90
|
+
"type" => "vr",
|
91
|
+
"number" => "3",
|
92
|
+
"flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
|
93
|
+
"addresses" => {
|
94
|
+
"00:00:24:c9:5e:bb" => {"family" => "lladdr"},
|
95
|
+
"fe80::200:24ff:fec9:5ebb" => {
|
96
|
+
"family" => "inet6",
|
97
|
+
"zoneid" => "vr3",
|
98
|
+
"prefixlen" => "64",
|
99
|
+
"scopeid" => "0x4"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
},
|
103
|
+
"ipfw0" => {
|
104
|
+
# OHAI-492: Ensure network plugin works with interfaces without addresses.
|
105
|
+
"type" => "ipfw",
|
106
|
+
"number" => "0",
|
107
|
+
"flags" => ["UP", "SIMPLEX", "MULTICAST"]
|
108
|
+
},
|
109
|
+
"lo0" => {
|
110
|
+
"type" => "lo",
|
111
|
+
"number" => "0",
|
112
|
+
"flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"],
|
113
|
+
"addresses" => {
|
114
|
+
"127.0.0.1" => {"family" => "inet", "netmask" => "255.0.0.0"},
|
115
|
+
"::1" => {"family" => "inet6", "prefixlen" => "128"},
|
116
|
+
"fe80::1" => {
|
117
|
+
"family" => "inet6",
|
118
|
+
"zoneid" => "lo0",
|
119
|
+
"prefixlen" => "64",
|
120
|
+
"scopeid" => "0x8"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
},
|
124
|
+
"bridge0" => {
|
125
|
+
"type" => "bridge",
|
126
|
+
"number" => "0",
|
127
|
+
"flags" => ["LEARNING", "DISCOVER", "AUTOEDGE", "AUTOPTP"],
|
128
|
+
"addresses" => {
|
129
|
+
"02:20:6f:d2:c4:00" => {"family"=>"lladdr"},
|
130
|
+
"192.168.2.1" => {
|
131
|
+
"family" => "inet",
|
132
|
+
"netmask" => "255.255.255.0",
|
133
|
+
"broadcast" => "192.168.2.255"
|
134
|
+
},
|
135
|
+
"2001:470:d:cb4::1" => {"family" => "inet6", "prefixlen" => "64"},
|
136
|
+
"fe80::cafe:babe:dead:beef" => {
|
137
|
+
"family" => "inet6",
|
138
|
+
"zoneid" => "bridge0",
|
139
|
+
"prefixlen" => "64",
|
140
|
+
"scopeid" => "0x9"
|
141
|
+
}
|
142
|
+
},
|
143
|
+
"arp" => {
|
144
|
+
"192.168.2.142" => "60:67:20:75:a2:0c",
|
145
|
+
"192.168.2.205" => "c0:c1:c0:f9:40:ed",
|
146
|
+
"192.168.2.160" => "cc:3a:61:cf:67:13",
|
147
|
+
"192.168.2.1" => "02:20:6f:d2:c4:00",
|
148
|
+
"192.168.2.135" => "f8:0c:f3:d7:c6:b6",
|
149
|
+
"192.168.2.165" => "f8:8f:ca:24:49:ad",
|
150
|
+
"192.168.2.158" => "48:5d:60:1f:ea:d1",
|
151
|
+
"192.168.2.150" => "60:a4:4c:60:b3:d9"
|
152
|
+
}
|
153
|
+
},
|
154
|
+
"gif0" => {
|
155
|
+
"type" => "gif",
|
156
|
+
"number" => "0",
|
157
|
+
"flags" => ["UP", "POINTOPOINT", "RUNNING", "MULTICAST"],
|
158
|
+
"addresses" => {
|
159
|
+
"fe80::200:24ff:fec9:5eb8" => {
|
160
|
+
"family" => "inet6",
|
161
|
+
"zoneid" => "gif0",
|
162
|
+
"prefixlen" => "64",
|
163
|
+
"scopeid" => "0xa"
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
},
|
168
|
+
"default_gateway" => "76.91.0.1",
|
169
|
+
"default_interface" => "vr0"
|
170
|
+
}
|
171
|
+
},
|
35
172
|
"linux" => {
|
36
173
|
"network" => {
|
37
174
|
# pp Hash[node['network']] from shef to get the network data
|
@@ -149,84 +286,76 @@ describe Ohai::System, "Network Plugin" do
|
|
149
286
|
|
150
287
|
describe "with linux" do
|
151
288
|
before(:each) do
|
152
|
-
@
|
153
|
-
@
|
154
|
-
@ohai["network"] = basic_data["linux"]["network"]
|
289
|
+
@plugin = get_plugin("network")
|
290
|
+
@plugin["network"] = basic_data["linux"]["network"]
|
155
291
|
end
|
156
292
|
|
157
293
|
describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
|
158
294
|
describe "simple setup" do
|
159
295
|
it_does_not_fail
|
160
296
|
|
161
|
-
it "logs 2 debug messages" do
|
162
|
-
Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
|
163
|
-
Ohai::Log.should_receive(:debug).with(/^\[inet\] Using default/).once
|
164
|
-
Ohai::Log.should_receive(:debug).with(/^\[inet6\] Using default/).once
|
165
|
-
@ohai._require_plugin("network")
|
166
|
-
end
|
167
|
-
|
168
297
|
it "detects {ip,ip6,mac}address" do
|
169
|
-
@
|
170
|
-
@
|
171
|
-
@
|
172
|
-
@
|
298
|
+
@plugin.run
|
299
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
300
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
301
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::33"
|
173
302
|
end
|
174
303
|
end
|
175
304
|
|
176
305
|
describe "default ipv4 and ipv6 gateway on different interfaces" do
|
177
306
|
describe "both interfaces have an ARP" do
|
178
307
|
before do
|
179
|
-
@
|
180
|
-
@
|
308
|
+
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
|
309
|
+
@plugin["network"]["default_inet6_interface"] = "eth1"
|
181
310
|
end
|
182
311
|
|
183
312
|
it_does_not_fail
|
184
313
|
|
185
314
|
it "detects {ip,ip6}address" do
|
186
|
-
@
|
187
|
-
@
|
188
|
-
@
|
315
|
+
@plugin.run
|
316
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
317
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
189
318
|
end
|
190
319
|
|
191
320
|
it "set macaddress from the ipv4 setup" do
|
192
|
-
@
|
193
|
-
@
|
321
|
+
@plugin.run
|
322
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
194
323
|
end
|
195
324
|
|
196
325
|
it "informs about this setup" do
|
197
326
|
Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
|
198
|
-
Ohai::Log.
|
199
|
-
@
|
327
|
+
Ohai::Log.stub(:debug)
|
328
|
+
@plugin.run
|
200
329
|
end
|
201
330
|
end
|
202
331
|
|
203
332
|
describe "ipv4 interface has no ARP" do
|
204
333
|
before do
|
205
|
-
@
|
334
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,kv| kv["family"] == "lladdr" }
|
206
335
|
# not really checked by this pluging
|
207
|
-
@
|
208
|
-
@
|
209
|
-
@
|
336
|
+
@plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
|
337
|
+
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
|
338
|
+
@plugin["network"]["default_inet6_interface"] = "eth1"
|
210
339
|
end
|
211
340
|
|
212
341
|
it_does_not_fail
|
213
342
|
|
214
343
|
it "detects {ip,ip6}address" do
|
215
|
-
@
|
216
|
-
@
|
217
|
-
@
|
344
|
+
@plugin.run
|
345
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
346
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
218
347
|
end
|
219
348
|
|
220
349
|
it "doesn't set macaddress, ipv4 setup is valid and has precedence over ipv6" do
|
221
350
|
Ohai::Log.should_not_receive(:warn).with(/^unable to detect macaddress/)
|
222
|
-
@
|
223
|
-
@
|
351
|
+
@plugin.run
|
352
|
+
@plugin["macaddress"].should be_nil
|
224
353
|
end
|
225
354
|
|
226
355
|
it "informs about this setup" do
|
227
356
|
Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
|
228
|
-
Ohai::Log.
|
229
|
-
@
|
357
|
+
Ohai::Log.stub(:debug)
|
358
|
+
@plugin.run
|
230
359
|
end
|
231
360
|
end
|
232
361
|
end
|
@@ -234,61 +363,56 @@ describe Ohai::System, "Network Plugin" do
|
|
234
363
|
describe "conflicting results from the linux::network plugin" do
|
235
364
|
describe "default interface doesn't match the default_gateway" do
|
236
365
|
before do
|
237
|
-
@
|
238
|
-
@
|
366
|
+
@plugin["network"]["default_interface"] = "eth1"
|
367
|
+
@plugin["network"]["default_inet6_interface"] = "eth1"
|
239
368
|
end
|
240
369
|
|
241
370
|
it_does_not_fail
|
242
371
|
|
243
372
|
it "picks {ip,ip6,mac}address" do
|
244
|
-
Ohai::Log.
|
245
|
-
@
|
246
|
-
@
|
247
|
-
@
|
248
|
-
@
|
373
|
+
Ohai::Log.stub(:warn)
|
374
|
+
@plugin.run
|
375
|
+
@plugin["ipaddress"].should == "192.168.99.11"
|
376
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:80"
|
377
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
249
378
|
end
|
250
379
|
|
251
380
|
it "warns about this conflict" do
|
252
381
|
Ohai::Log.should_receive(:warn).with(/^\[inet\] no ipaddress\/mask on eth1/).once
|
253
382
|
Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
|
254
|
-
@
|
383
|
+
@plugin.run
|
255
384
|
end
|
256
385
|
end
|
257
386
|
|
258
387
|
describe "there's a default gateway, none of the configured ip/mask theorically allows to reach it" do
|
259
388
|
before do
|
260
|
-
@
|
261
|
-
@
|
389
|
+
@plugin["network"]["default_gateway"] = "172.16.12.42"
|
390
|
+
@plugin["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
|
262
391
|
end
|
263
392
|
|
264
393
|
it "picks {ip,ip6,mac}address" do
|
265
|
-
Ohai::Log.
|
266
|
-
@
|
267
|
-
@
|
268
|
-
@
|
269
|
-
@
|
394
|
+
Ohai::Log.stub(:warn)
|
395
|
+
@plugin.run
|
396
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
397
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
398
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::33"
|
270
399
|
end
|
271
400
|
|
272
|
-
it "warns about this conflict" do
|
273
|
-
Ohai::Log.should_receive(:warn).with(/^\[inet\] no ipaddress\/mask on eth0/).once
|
274
|
-
Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ipaddress\/mask on eth0/).once
|
275
|
-
@ohai._require_plugin("network")
|
276
|
-
end
|
277
401
|
end
|
278
402
|
|
279
403
|
describe "no ip address for the given default interface/gateway" do
|
280
404
|
before do
|
281
|
-
@
|
405
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
|
282
406
|
end
|
283
407
|
|
284
408
|
it_does_not_fail
|
285
409
|
|
286
410
|
it "doesn't detect {ip,ip6,mac}address" do
|
287
|
-
Ohai::Log.
|
288
|
-
@
|
289
|
-
@
|
290
|
-
@
|
291
|
-
@
|
411
|
+
Ohai::Log.stub(:warn)
|
412
|
+
@plugin.run
|
413
|
+
@plugin["ipaddress"].should be_nil
|
414
|
+
@plugin["macaddress"].should be_nil
|
415
|
+
@plugin["ip6address"].should be_nil
|
292
416
|
end
|
293
417
|
|
294
418
|
it "warns about this conflict" do
|
@@ -297,17 +421,17 @@ describe Ohai::System, "Network Plugin" do
|
|
297
421
|
Ohai::Log.should_receive(:warn).with(/^\[inet\] no ip address on eth0/).once
|
298
422
|
Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
|
299
423
|
Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ip address on eth0/).once
|
300
|
-
@
|
424
|
+
@plugin.run
|
301
425
|
end
|
302
426
|
end
|
303
427
|
|
304
428
|
describe "no ip at all" do
|
305
429
|
before do
|
306
|
-
@
|
307
|
-
@
|
308
|
-
@
|
309
|
-
@
|
310
|
-
@
|
430
|
+
@plugin["network"]["default_gateway"] = nil
|
431
|
+
@plugin["network"]["default_interface"] = nil
|
432
|
+
@plugin["network"]["default_inet6_gateway"] = nil
|
433
|
+
@plugin["network"]["default_inet6_interface"] = nil
|
434
|
+
@plugin["network"]["interfaces"].each do |i,iv|
|
311
435
|
iv["addresses"].delete_if{|k,kv| %w[inet inet6].include? kv["family"]}
|
312
436
|
end
|
313
437
|
end
|
@@ -315,18 +439,18 @@ describe Ohai::System, "Network Plugin" do
|
|
315
439
|
it_does_not_fail
|
316
440
|
|
317
441
|
it "doesn't detect {ip,ip6,mac}address" do
|
318
|
-
Ohai::Log.
|
319
|
-
@
|
320
|
-
@
|
321
|
-
@
|
322
|
-
@
|
442
|
+
Ohai::Log.stub(:warn)
|
443
|
+
@plugin.run
|
444
|
+
@plugin["ipaddress"].should be_nil
|
445
|
+
@plugin["macaddress"].should be_nil
|
446
|
+
@plugin["ip6address"].should be_nil
|
323
447
|
end
|
324
448
|
|
325
449
|
it "should warn about it" do
|
326
450
|
Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
|
327
451
|
Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
|
328
452
|
Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
|
329
|
-
@
|
453
|
+
@plugin.run
|
330
454
|
end
|
331
455
|
end
|
332
456
|
end
|
@@ -334,7 +458,7 @@ describe Ohai::System, "Network Plugin" do
|
|
334
458
|
describe "several ipaddresses matching the default route" do
|
335
459
|
describe "bigger prefix not set on the default interface" do
|
336
460
|
before do
|
337
|
-
@
|
461
|
+
@plugin["network"]["interfaces"]["eth2"] = {
|
338
462
|
"flags" => ["BROADCAST", "MULTICAST", "UP"],
|
339
463
|
"number" => "2",
|
340
464
|
"addresses" => {
|
@@ -363,23 +487,23 @@ describe Ohai::System, "Network Plugin" do
|
|
363
487
|
it_does_not_fail
|
364
488
|
|
365
489
|
it "sets {ip,ip6,mac}address correctly" do
|
366
|
-
@
|
367
|
-
@
|
368
|
-
@
|
369
|
-
@
|
490
|
+
@plugin.run
|
491
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
492
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
493
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::33"
|
370
494
|
end
|
371
495
|
end
|
372
496
|
|
373
497
|
describe "bigger prefix set on the default interface" do
|
374
498
|
before do
|
375
|
-
@
|
499
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
|
376
500
|
"scope" => "Global",
|
377
501
|
"netmask" => "255.255.255.128",
|
378
502
|
"broadcast" => "192.168.66.127",
|
379
503
|
"prefixlen" => "25",
|
380
504
|
"family" => "inet"
|
381
505
|
}
|
382
|
-
@
|
506
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
|
383
507
|
"prefixlen" => "64",
|
384
508
|
"family" => "inet6",
|
385
509
|
"scope" => "Global"
|
@@ -389,16 +513,16 @@ describe Ohai::System, "Network Plugin" do
|
|
389
513
|
it_does_not_fail
|
390
514
|
|
391
515
|
it "sets {ip,ip6,mac}address correctly" do
|
392
|
-
@
|
393
|
-
@
|
394
|
-
@
|
395
|
-
@
|
516
|
+
@plugin.run
|
517
|
+
@plugin["ipaddress"].should == "192.168.66.99"
|
518
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
519
|
+
@plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
|
396
520
|
end
|
397
521
|
end
|
398
522
|
|
399
523
|
describe "smallest ip not set on the default_interface" do
|
400
524
|
before do
|
401
|
-
@
|
525
|
+
@plugin["network"]["interfaces"]["eth2"] = {
|
402
526
|
"flags" => ["BROADCAST", "MULTICAST", "UP"],
|
403
527
|
"number" => "2",
|
404
528
|
"addresses" => {
|
@@ -427,23 +551,23 @@ describe Ohai::System, "Network Plugin" do
|
|
427
551
|
it_does_not_fail
|
428
552
|
|
429
553
|
it "sets {ip,ip6,mac}address correctly" do
|
430
|
-
@
|
431
|
-
@
|
432
|
-
@
|
433
|
-
@
|
554
|
+
@plugin.run
|
555
|
+
@plugin["ipaddress"].should == "192.168.66.33"
|
556
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
557
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::33"
|
434
558
|
end
|
435
559
|
end
|
436
560
|
|
437
561
|
describe "smallest ip set on the default_interface" do
|
438
562
|
before do
|
439
|
-
@
|
563
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
|
440
564
|
"scope" => "Global",
|
441
565
|
"netmask" => "255.255.255.0",
|
442
566
|
"broadcast" => "192.168.66.255",
|
443
567
|
"prefixlen" => "24",
|
444
568
|
"family" => "inet"
|
445
569
|
}
|
446
|
-
@
|
570
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
|
447
571
|
"prefixlen" => "48",
|
448
572
|
"family" => "inet6",
|
449
573
|
"scope" => "Global"
|
@@ -453,10 +577,10 @@ describe Ohai::System, "Network Plugin" do
|
|
453
577
|
it_does_not_fail
|
454
578
|
|
455
579
|
it "sets {ip,ip6,mac}address correctly" do
|
456
|
-
@
|
457
|
-
@
|
458
|
-
@
|
459
|
-
@
|
580
|
+
@plugin.run
|
581
|
+
@plugin["ipaddress"].should == "192.168.66.32"
|
582
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
583
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::32"
|
460
584
|
end
|
461
585
|
end
|
462
586
|
end
|
@@ -464,12 +588,12 @@ describe Ohai::System, "Network Plugin" do
|
|
464
588
|
describe "no default route" do
|
465
589
|
describe "first interface is not the best choice" do
|
466
590
|
before do
|
467
|
-
@
|
468
|
-
@
|
469
|
-
@
|
470
|
-
@
|
591
|
+
@plugin["network"]["default_gateway"] = nil
|
592
|
+
@plugin["network"]["default_interface"] = nil
|
593
|
+
@plugin["network"]["default_inet6_gateway"] = nil
|
594
|
+
@plugin["network"]["default_inet6_interface"] = nil
|
471
595
|
# removing inet* addresses from eth0, to complicate things a bit
|
472
|
-
@
|
596
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
|
473
597
|
end
|
474
598
|
|
475
599
|
it_does_not_fail
|
@@ -477,22 +601,22 @@ describe Ohai::System, "Network Plugin" do
|
|
477
601
|
it "picks {ip,mac,ip6}address from the first interface" do
|
478
602
|
Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
|
479
603
|
Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
|
480
|
-
Ohai::Log.
|
481
|
-
@
|
482
|
-
@
|
483
|
-
@
|
484
|
-
@
|
604
|
+
Ohai::Log.stub(:debug)
|
605
|
+
@plugin.run
|
606
|
+
@plugin["ipaddress"].should == "192.168.99.11"
|
607
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:80"
|
608
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
485
609
|
end
|
486
610
|
end
|
487
611
|
|
488
612
|
describe "can choose from addresses with different scopes" do
|
489
613
|
before do
|
490
|
-
@
|
491
|
-
@
|
492
|
-
@
|
493
|
-
@
|
614
|
+
@plugin["network"]["default_gateway"] = nil
|
615
|
+
@plugin["network"]["default_interface"] = nil
|
616
|
+
@plugin["network"]["default_inet6_gateway"] = nil
|
617
|
+
@plugin["network"]["default_inet6_interface"] = nil
|
494
618
|
# just changing scopes to lInK for eth0 addresses
|
495
|
-
@
|
619
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"].each{|k,v| v[:scope]="lInK" if %w[inet inet6].include? v["family"]}
|
496
620
|
end
|
497
621
|
|
498
622
|
it_does_not_fail
|
@@ -500,11 +624,11 @@ describe Ohai::System, "Network Plugin" do
|
|
500
624
|
it "prefers global scope addressses to set {ip,mac,ip6}address" do
|
501
625
|
Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
|
502
626
|
Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
|
503
|
-
Ohai::Log.
|
504
|
-
@
|
505
|
-
@
|
506
|
-
@
|
507
|
-
@
|
627
|
+
Ohai::Log.stub(:debug)
|
628
|
+
@plugin.run
|
629
|
+
@plugin["ipaddress"].should == "192.168.99.11"
|
630
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:80"
|
631
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
508
632
|
end
|
509
633
|
end
|
510
634
|
end
|
@@ -512,36 +636,29 @@ describe Ohai::System, "Network Plugin" do
|
|
512
636
|
describe "link level default route" do
|
513
637
|
describe "simple setup" do
|
514
638
|
before do
|
515
|
-
@
|
516
|
-
@
|
517
|
-
@
|
518
|
-
@
|
639
|
+
@plugin["network"]["default_gateway"] = "0.0.0.0"
|
640
|
+
@plugin["network"]["default_interface"] = "eth1"
|
641
|
+
@plugin["network"]["default_inet6_gateway"] = "::"
|
642
|
+
@plugin["network"]["default_inet6_interface"] = "eth1"
|
519
643
|
end
|
520
644
|
|
521
645
|
it_does_not_fail
|
522
646
|
|
523
|
-
it "displays debug messages" do
|
524
|
-
Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
|
525
|
-
Ohai::Log.should_receive(:debug).with(/^link level default inet /).once
|
526
|
-
Ohai::Log.should_receive(:debug).with(/^link level default inet6 /).once
|
527
|
-
@ohai._require_plugin("network")
|
528
|
-
end
|
529
|
-
|
530
647
|
it "picks {ip,mac,ip6}address from the default interface" do
|
531
|
-
@
|
532
|
-
@
|
533
|
-
@
|
534
|
-
@
|
648
|
+
@plugin.run
|
649
|
+
@plugin["ipaddress"].should == "192.168.99.11"
|
650
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:80"
|
651
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
535
652
|
end
|
536
653
|
end
|
537
654
|
|
538
655
|
describe "can choose from addresses with different scopes" do
|
539
656
|
before do
|
540
|
-
@
|
541
|
-
@
|
542
|
-
@
|
543
|
-
@
|
544
|
-
@
|
657
|
+
@plugin["network"]["default_gateway"] = "0.0.0.0"
|
658
|
+
@plugin["network"]["default_interface"] = "eth1"
|
659
|
+
@plugin["network"]["default_inet6_gateway"] = "::"
|
660
|
+
@plugin["network"]["default_inet6_interface"] = "eth1"
|
661
|
+
@plugin["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
|
545
662
|
"scope" => "host",
|
546
663
|
"netmask" => "255.255.255.255",
|
547
664
|
"prefixlen" => "32",
|
@@ -551,25 +668,18 @@ describe Ohai::System, "Network Plugin" do
|
|
551
668
|
|
552
669
|
it_does_not_fail
|
553
670
|
|
554
|
-
it "displays debug messages" do
|
555
|
-
Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
|
556
|
-
Ohai::Log.should_receive(:debug).with(/^link level default inet /).once
|
557
|
-
Ohai::Log.should_receive(:debug).with(/^link level default inet6 /).once
|
558
|
-
@ohai._require_plugin("network")
|
559
|
-
end
|
560
|
-
|
561
671
|
it "picks {ip,mac,ip6}address from the default interface" do
|
562
|
-
@
|
563
|
-
@
|
564
|
-
@
|
565
|
-
@
|
672
|
+
@plugin.run
|
673
|
+
@plugin["ipaddress"].should == "192.168.99.11"
|
674
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:80"
|
675
|
+
@plugin["ip6address"].should == "3ffe:1111:3333::1"
|
566
676
|
end
|
567
677
|
end
|
568
678
|
end
|
569
679
|
|
570
680
|
describe "point to point address" do
|
571
681
|
before do
|
572
|
-
@
|
682
|
+
@plugin["network"]["interfaces"]["eth2"] = {
|
573
683
|
"flags" => ["POINTOPOINT", "BROADCAST", "MULTICAST", "UP"],
|
574
684
|
"number" => "2",
|
575
685
|
"addresses" => {
|
@@ -594,27 +704,27 @@ describe Ohai::System, "Network Plugin" do
|
|
594
704
|
}
|
595
705
|
}
|
596
706
|
}
|
597
|
-
@
|
598
|
-
@
|
599
|
-
@
|
600
|
-
@
|
707
|
+
@plugin["network"]["default_gateway"] = "192.168.99.126"
|
708
|
+
@plugin["network"]["default_interface"] = "eth2"
|
709
|
+
@plugin["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
|
710
|
+
@plugin["network"]["default_inet6_interface"] = "eth2"
|
601
711
|
end
|
602
712
|
|
603
713
|
it_does_not_fail
|
604
714
|
|
605
715
|
it "picks {ip,mac,ip6}address from the default interface" do
|
606
|
-
@
|
607
|
-
@
|
608
|
-
@
|
609
|
-
@
|
716
|
+
@plugin.run
|
717
|
+
@plugin["ipaddress"].should == "192.168.66.99"
|
718
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:81"
|
719
|
+
@plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
|
610
720
|
end
|
611
721
|
end
|
612
722
|
|
613
723
|
describe "ipv6 only node" do
|
614
724
|
before do
|
615
|
-
@
|
616
|
-
@
|
617
|
-
@
|
725
|
+
@plugin["network"]["default_gateway"] = nil
|
726
|
+
@plugin["network"]["default_interface"] = nil
|
727
|
+
@plugin["network"]["interfaces"].each do |i,iv|
|
618
728
|
iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
|
619
729
|
end
|
620
730
|
end
|
@@ -622,28 +732,28 @@ describe Ohai::System, "Network Plugin" do
|
|
622
732
|
it_does_not_fail
|
623
733
|
|
624
734
|
it "can't detect ipaddress" do
|
625
|
-
Ohai::Log.
|
626
|
-
@
|
627
|
-
@
|
735
|
+
Ohai::Log.stub(:warn)
|
736
|
+
@plugin.run
|
737
|
+
@plugin["ipaddress"].should be_nil
|
628
738
|
end
|
629
739
|
|
630
740
|
it "warns about not being able to set {ip,mac}address (ipv4)" do
|
631
741
|
Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
|
632
742
|
Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
|
633
|
-
@
|
743
|
+
@plugin.run
|
634
744
|
end
|
635
745
|
|
636
746
|
it "sets {ip6,mac}address" do
|
637
|
-
Ohai::Log.
|
638
|
-
@
|
639
|
-
@
|
640
|
-
@
|
747
|
+
Ohai::Log.stub(:warn)
|
748
|
+
@plugin.run
|
749
|
+
@plugin["ip6address"].should == "3ffe:1111:2222::33"
|
750
|
+
@plugin["macaddress"].should == "00:16:3E:2F:36:79"
|
641
751
|
end
|
642
752
|
|
643
753
|
it "informs about macaddress being set using the ipv6 setup" do
|
644
754
|
Ohai::Log.should_receive(:debug).with(/^macaddress set to 00:16:3E:2F:36:79 from the ipv6 setup/).once
|
645
|
-
Ohai::Log.
|
646
|
-
@
|
755
|
+
Ohai::Log.stub(:debug)
|
756
|
+
@plugin.run
|
647
757
|
end
|
648
758
|
end
|
649
759
|
|
@@ -652,16 +762,17 @@ describe Ohai::System, "Network Plugin" do
|
|
652
762
|
basic_data.keys.sort.each do |os|
|
653
763
|
describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
|
654
764
|
before(:each) do
|
655
|
-
@
|
656
|
-
@ohai.stub!(:require_plugin).twice.and_return(true)
|
657
|
-
@ohai["network"] = basic_data[os]["network"]
|
765
|
+
@plugin["network"] = basic_data[os]["network"]
|
658
766
|
end
|
659
767
|
|
660
768
|
describe "{ip,mac}address are already set" do
|
661
769
|
before do
|
662
|
-
@
|
663
|
-
@
|
770
|
+
@plugin["ipaddress"] = "10.11.12.13"
|
771
|
+
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
664
772
|
@expected_results = {
|
773
|
+
"freebsd" => {
|
774
|
+
"ip6address" => "::1"
|
775
|
+
},
|
665
776
|
"linux" => {
|
666
777
|
"ip6address" => "3ffe:1111:2222::33"
|
667
778
|
},
|
@@ -674,22 +785,26 @@ describe Ohai::System, "Network Plugin" do
|
|
674
785
|
it_does_not_fail
|
675
786
|
|
676
787
|
it "detects ip6address" do
|
677
|
-
@
|
678
|
-
@
|
788
|
+
@plugin.run
|
789
|
+
@plugin["ip6address"].should == @expected_results[os]["ip6address"]
|
679
790
|
end
|
680
791
|
|
681
792
|
it "doesn't overwrite {ip,mac}address" do
|
682
|
-
@
|
683
|
-
@
|
684
|
-
@
|
793
|
+
@plugin.run
|
794
|
+
@plugin["ipaddress"].should == "10.11.12.13"
|
795
|
+
@plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
|
685
796
|
end
|
686
797
|
end
|
687
798
|
|
688
799
|
describe "ip6address is already set" do
|
689
800
|
describe "node has ipv4 and ipv6" do
|
690
801
|
before do
|
691
|
-
@
|
802
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
692
803
|
@expected_results = {
|
804
|
+
"freebsd" => {
|
805
|
+
"ipaddress" => "76.91.1.255",
|
806
|
+
"macaddress" => "00:00:24:c9:5e:b8"
|
807
|
+
},
|
693
808
|
"linux" => {
|
694
809
|
"ipaddress" => "192.168.66.33",
|
695
810
|
"macaddress" => "00:16:3E:2F:36:79"
|
@@ -704,51 +819,53 @@ describe Ohai::System, "Network Plugin" do
|
|
704
819
|
it_does_not_fail
|
705
820
|
|
706
821
|
it "detects {ip,mac}address" do
|
707
|
-
@
|
708
|
-
@
|
709
|
-
@
|
822
|
+
@plugin.run
|
823
|
+
@plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
|
824
|
+
@plugin["macaddress"].should == @expected_results[os]["macaddress"]
|
710
825
|
end
|
711
826
|
|
712
827
|
it "doesn't overwrite ip6address" do
|
713
|
-
@
|
714
|
-
@
|
828
|
+
@plugin.run
|
829
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
715
830
|
end
|
716
831
|
end
|
717
832
|
|
718
833
|
describe "ipv6 only node" do
|
719
834
|
before do
|
720
|
-
@
|
721
|
-
@
|
722
|
-
@
|
723
|
-
iv
|
835
|
+
@plugin["network"]["default_gateway"] = nil
|
836
|
+
@plugin["network"]["default_interface"] = nil
|
837
|
+
@plugin["network"]["interfaces"].each do |i,iv|
|
838
|
+
if iv.has_key? "addresses"
|
839
|
+
iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
|
840
|
+
end
|
724
841
|
end
|
725
|
-
@
|
842
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
726
843
|
end
|
727
844
|
|
728
845
|
it_does_not_fail
|
729
846
|
|
730
847
|
it "can't detect ipaddress (ipv4)" do
|
731
|
-
Ohai::Log.
|
732
|
-
@
|
733
|
-
@
|
848
|
+
Ohai::Log.stub(:warn)
|
849
|
+
@plugin.run
|
850
|
+
@plugin["ipaddress"].should be_nil
|
734
851
|
end
|
735
852
|
|
736
853
|
it "can't detect macaddress either" do
|
737
|
-
Ohai::Log.
|
738
|
-
@
|
739
|
-
@
|
854
|
+
Ohai::Log.stub(:warn)
|
855
|
+
@plugin.run
|
856
|
+
@plugin["macaddress"].should be_nil
|
740
857
|
end
|
741
858
|
|
742
859
|
it "warns about not being able to set {ip,mac}address" do
|
743
860
|
Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
|
744
861
|
Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
|
745
|
-
@
|
862
|
+
@plugin.run
|
746
863
|
end
|
747
864
|
|
748
865
|
it "doesn't overwrite ip6address" do
|
749
|
-
Ohai::Log.
|
750
|
-
@
|
751
|
-
@
|
866
|
+
Ohai::Log.stub(:warn)
|
867
|
+
@plugin.run
|
868
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
752
869
|
end
|
753
870
|
end
|
754
871
|
end
|
@@ -756,9 +873,13 @@ describe Ohai::System, "Network Plugin" do
|
|
756
873
|
describe "{mac,ip6}address are already set" do
|
757
874
|
describe "valid ipv4 setup" do
|
758
875
|
before do
|
759
|
-
@
|
760
|
-
@
|
876
|
+
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
877
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
761
878
|
@expected_results = {
|
879
|
+
"freebsd" => {
|
880
|
+
"ipaddress" => "76.91.1.255",
|
881
|
+
"macaddress" => "00:00:24:c9:5e:b8"
|
882
|
+
},
|
762
883
|
"linux" => {
|
763
884
|
"ipaddress" => "192.168.66.33",
|
764
885
|
"macaddress" => "00:16:3E:2F:36:79"
|
@@ -773,75 +894,77 @@ describe Ohai::System, "Network Plugin" do
|
|
773
894
|
it_does_not_fail
|
774
895
|
|
775
896
|
it "detects ipaddress and overwrite macaddress" do
|
776
|
-
@
|
777
|
-
@
|
778
|
-
@
|
897
|
+
@plugin.run
|
898
|
+
@plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
|
899
|
+
@plugin["macaddress"].should == @expected_results[os]["macaddress"]
|
779
900
|
end
|
780
901
|
|
781
902
|
it "doesn't overwrite ip6address" do
|
782
|
-
@
|
783
|
-
@
|
903
|
+
@plugin.run
|
904
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
784
905
|
end
|
785
906
|
end
|
786
907
|
|
787
908
|
describe "ipv6 only node" do
|
788
909
|
before do
|
789
|
-
@
|
790
|
-
@
|
791
|
-
@
|
792
|
-
iv
|
910
|
+
@plugin["network"]["default_gateway"] = nil
|
911
|
+
@plugin["network"]["default_interface"] = nil
|
912
|
+
@plugin["network"]["interfaces"].each do |i,iv|
|
913
|
+
if iv.has_key? "addresses"
|
914
|
+
iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
|
915
|
+
end
|
793
916
|
end
|
794
|
-
@
|
795
|
-
@
|
917
|
+
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
918
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
796
919
|
end
|
797
920
|
|
798
921
|
it_does_not_fail
|
799
922
|
|
800
923
|
it "can't set ipaddress" do
|
801
|
-
Ohai::Log.
|
802
|
-
@
|
803
|
-
@
|
924
|
+
Ohai::Log.stub(:warn)
|
925
|
+
@plugin.run
|
926
|
+
@plugin["ipaddress"].should be_nil
|
804
927
|
end
|
805
928
|
|
806
929
|
it "doesn't overwrite {ip6,mac}address" do
|
807
|
-
Ohai::Log.
|
808
|
-
@
|
809
|
-
@
|
810
|
-
@
|
930
|
+
Ohai::Log.stub(:warn)
|
931
|
+
@plugin.run
|
932
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
933
|
+
@plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
|
811
934
|
end
|
812
935
|
end
|
813
936
|
end
|
814
937
|
|
815
938
|
describe "{ip,mac,ip6}address are already set" do
|
816
939
|
before do
|
817
|
-
@
|
818
|
-
@
|
819
|
-
@
|
940
|
+
@plugin["ipaddress"] = "10.11.12.13"
|
941
|
+
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
942
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
820
943
|
end
|
821
944
|
|
822
945
|
it_does_not_fail
|
823
946
|
|
824
947
|
it "doesn't overwrite {ip,mac,ip6}address" do
|
825
|
-
@
|
826
|
-
@
|
827
|
-
@
|
828
|
-
@
|
948
|
+
@plugin.run
|
949
|
+
@plugin["ipaddress"].should == "10.11.12.13"
|
950
|
+
@plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
|
951
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
829
952
|
end
|
830
953
|
end
|
831
954
|
|
832
955
|
describe "{ip,ip6}address are already set" do
|
833
956
|
before do
|
834
|
-
@
|
835
|
-
@
|
957
|
+
@plugin["ipaddress"] = "10.11.12.13"
|
958
|
+
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
836
959
|
end
|
837
960
|
|
838
961
|
it_does_not_fail
|
839
962
|
|
840
963
|
it "doesn't overwrite {ip,mac,ip6}address" do
|
841
|
-
@
|
842
|
-
@
|
843
|
-
@
|
844
|
-
@
|
964
|
+
@plugin.run
|
965
|
+
@plugin["ipaddress"].should == "10.11.12.13"
|
966
|
+
@plugin["macaddress"].should == nil
|
967
|
+
@plugin["ip6address"].should == "3ffe:8888:9999::1"
|
845
968
|
end
|
846
969
|
end
|
847
970
|
|