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
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -21,41 +21,34 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "Linux 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(:linux)
|
26
|
+
@plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
|
27
|
+
@plugin.stub(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
|
28
|
+
@plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
29
29
|
end
|
30
30
|
|
31
31
|
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
32
|
-
|
32
|
+
|
33
33
|
it_should_check_from("linux::hostname", "fqdn", "hostname --fqdn", "katie.bethell")
|
34
34
|
|
35
|
-
|
35
|
+
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
36
|
+
|
37
|
+
describe "when domain name is unset" do
|
36
38
|
before(:each) do
|
37
|
-
@
|
39
|
+
@plugin.should_receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
|
38
40
|
end
|
39
41
|
|
40
42
|
it "should not raise an error" do
|
41
|
-
lambda { @
|
43
|
+
lambda { @plugin.run }.should_not raise_error
|
42
44
|
end
|
43
45
|
|
44
46
|
it "should not set fqdn" do
|
45
|
-
@
|
46
|
-
@
|
47
|
+
@plugin.run
|
48
|
+
@plugin.fqdn.should == nil
|
47
49
|
end
|
50
|
+
|
48
51
|
end
|
49
52
|
|
50
|
-
describe "when hostname --fqdn is emtpy" do
|
51
|
-
before(:each) do
|
52
|
-
@ohai.stub!(:from).with("hostname --fqdn").
|
53
|
-
and_return("", "katie.bethell")
|
54
|
-
end
|
55
|
-
it "should call it twice" do
|
56
|
-
@ohai._require_plugin("linux::hostname")
|
57
|
-
@ohai.fqdn.should == "katie.bethell"
|
58
|
-
end
|
59
|
-
end
|
60
53
|
end
|
61
54
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
#
|
3
|
+
# Author:: Theodore Nordsieck (<theo@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008-2013 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,16 +17,29 @@
|
|
16
17
|
# limitations under the License.
|
17
18
|
#
|
18
19
|
|
19
|
-
|
20
20
|
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
21
21
|
|
22
22
|
describe Ohai::System, "Linux kernel plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
@env_lsmod = <<-ENV_LSMOD
|
25
|
+
Module Size Used by
|
26
|
+
dm_crypt 22321 0
|
27
|
+
psmouse 81038 0
|
28
|
+
acpiphp 23314 0
|
29
|
+
microcode 18286 0
|
30
|
+
serio_raw 13031 0
|
31
|
+
virtio_balloon 13168 0
|
32
|
+
floppy 55441 0
|
33
|
+
ENV_LSMOD
|
34
|
+
@plugin = get_plugin("kernel")
|
35
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
36
|
+
@plugin.stub(:init_kernel).and_return({})
|
37
|
+
@plugin.stub(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
|
38
|
+
@plugin.stub(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
|
39
|
+
@plugin.should_receive(:shell_out).with("env lsmod").at_least(1).times
|
40
|
+
@plugin.run
|
28
41
|
end
|
29
42
|
|
30
|
-
it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", "Linux")
|
31
|
-
|
43
|
+
it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""])
|
44
|
+
|
45
|
+
end
|
@@ -23,128 +23,126 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
23
23
|
|
24
24
|
describe Ohai::System, "Linux lsb plugin" do
|
25
25
|
before(:each) do
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
29
|
-
@ohai.extend(SimpleFromFile)
|
26
|
+
@plugin = get_plugin("linux/lsb")
|
27
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
30
28
|
end
|
31
29
|
|
32
30
|
describe "on systems with /etc/lsb-release" do
|
33
31
|
before(:each) do
|
34
|
-
@
|
35
|
-
@
|
32
|
+
@double_file = double("/etc/lsb-release")
|
33
|
+
@double_file.stub(:each).
|
36
34
|
and_yield("DISTRIB_ID=Ubuntu").
|
37
35
|
and_yield("DISTRIB_RELEASE=8.04").
|
38
36
|
and_yield("DISTRIB_CODENAME=hardy").
|
39
37
|
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
|
40
|
-
File.stub
|
41
|
-
File.stub
|
38
|
+
File.stub(:open).with("/etc/lsb-release").and_return(@double_file)
|
39
|
+
File.stub(:exists?).with("/etc/lsb-release").and_return(true)
|
42
40
|
end
|
43
41
|
|
44
42
|
it "should set lsb[:id]" do
|
45
|
-
@
|
46
|
-
@
|
43
|
+
@plugin.run
|
44
|
+
@plugin[:lsb][:id].should == "Ubuntu"
|
47
45
|
end
|
48
46
|
|
49
47
|
it "should set lsb[:release]" do
|
50
|
-
@
|
51
|
-
@
|
48
|
+
@plugin.run
|
49
|
+
@plugin[:lsb][:release].should == "8.04"
|
52
50
|
end
|
53
51
|
|
54
52
|
it "should set lsb[:codename]" do
|
55
|
-
@
|
56
|
-
@
|
53
|
+
@plugin.run
|
54
|
+
@plugin[:lsb][:codename].should == "hardy"
|
57
55
|
end
|
58
56
|
|
59
57
|
it "should set lsb[:description]" do
|
60
|
-
@
|
61
|
-
@
|
58
|
+
@plugin.run
|
59
|
+
@plugin[:lsb][:description].should == "Ubuntu 8.04"
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
63
|
describe "on systems with /usr/bin/lsb_release" do
|
66
64
|
before(:each) do
|
67
|
-
File.stub
|
68
|
-
File.stub
|
65
|
+
File.stub(:exists?).with("/etc/lsb-release").and_return(false)
|
66
|
+
File.stub(:exists?).with("/usr/bin/lsb_release").and_return(true)
|
69
67
|
|
70
|
-
@stdin =
|
68
|
+
@stdin = double("STDIN", { :close => true })
|
71
69
|
@pid = 10
|
72
|
-
@stderr =
|
73
|
-
@stdout =
|
70
|
+
@stderr = double("STDERR")
|
71
|
+
@stdout = double("STDOUT")
|
74
72
|
@status = 0
|
75
73
|
|
76
74
|
end
|
77
75
|
|
78
76
|
describe "on Centos 5.4 correctly" do
|
79
77
|
before(:each) do
|
80
|
-
@stdout
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
@
|
78
|
+
@stdout = <<-LSB_RELEASE
|
79
|
+
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
|
80
|
+
Distributor ID: CentOS
|
81
|
+
Description: CentOS release 5.4 (Final)
|
82
|
+
Release: 5.4
|
83
|
+
Codename: Final
|
84
|
+
LSB_RELEASE
|
85
|
+
@plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
|
88
86
|
end
|
89
87
|
|
90
88
|
it "should set lsb[:id]" do
|
91
|
-
@
|
92
|
-
@
|
89
|
+
@plugin.run
|
90
|
+
@plugin[:lsb][:id].should == "CentOS"
|
93
91
|
end
|
94
92
|
|
95
93
|
it "should set lsb[:release]" do
|
96
|
-
@
|
97
|
-
@
|
94
|
+
@plugin.run
|
95
|
+
@plugin[:lsb][:release].should == "5.4"
|
98
96
|
end
|
99
97
|
|
100
98
|
it "should set lsb[:codename]" do
|
101
|
-
@
|
102
|
-
@
|
99
|
+
@plugin.run
|
100
|
+
@plugin[:lsb][:codename].should == "Final"
|
103
101
|
end
|
104
102
|
|
105
103
|
it "should set lsb[:description]" do
|
106
|
-
@
|
107
|
-
@
|
104
|
+
@plugin.run
|
105
|
+
@plugin[:lsb][:description].should == "CentOS release 5.4 (Final)"
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
111
109
|
describe "on Fedora 14 correctly" do
|
112
110
|
before(:each) do
|
113
|
-
@stdout
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
@
|
111
|
+
@stdout = <<-LSB_RELEASE
|
112
|
+
LSB Version: :core-4.0-ia32:core-4.0-noarch
|
113
|
+
Distributor ID: Fedora
|
114
|
+
Description: Fedora release 14 (Laughlin)
|
115
|
+
Release: 14
|
116
|
+
Codename: Laughlin
|
117
|
+
LSB_RELEASE
|
118
|
+
@plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
|
121
119
|
end
|
122
120
|
|
123
121
|
it "should set lsb[:id]" do
|
124
|
-
@
|
125
|
-
@
|
122
|
+
@plugin.run
|
123
|
+
@plugin[:lsb][:id].should == "Fedora"
|
126
124
|
end
|
127
125
|
|
128
126
|
it "should set lsb[:release]" do
|
129
|
-
@
|
130
|
-
@
|
127
|
+
@plugin.run
|
128
|
+
@plugin[:lsb][:release].should == "14"
|
131
129
|
end
|
132
130
|
|
133
131
|
it "should set lsb[:codename]" do
|
134
|
-
@
|
135
|
-
@
|
132
|
+
@plugin.run
|
133
|
+
@plugin[:lsb][:codename].should == "Laughlin"
|
136
134
|
end
|
137
135
|
|
138
136
|
it "should set lsb[:description]" do
|
139
|
-
@
|
140
|
-
@
|
137
|
+
@plugin.run
|
138
|
+
@plugin[:lsb][:description].should == "Fedora release 14 (Laughlin)"
|
141
139
|
end
|
142
140
|
end
|
143
141
|
end
|
144
142
|
|
145
143
|
it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
|
146
|
-
File.stub
|
147
|
-
File.stub
|
148
|
-
@
|
144
|
+
File.stub(:exists?).with("/etc/lsb-release").and_return(false)
|
145
|
+
File.stub(:exists?).with("/usr/bin/lsb_release").and_return(false)
|
146
|
+
@plugin.attribute?(:lsb).should be(false)
|
149
147
|
end
|
150
148
|
end
|
@@ -25,28 +25,17 @@ rescue LoadError => e
|
|
25
25
|
raise e
|
26
26
|
end
|
27
27
|
|
28
|
-
def prepare_data
|
29
|
-
@ifconfig_lines = @linux_ifconfig.split("\n")
|
30
|
-
@route_lines = @linux_route_n.split("\n")
|
31
|
-
@arp_lines = @linux_arp_an.split("\n")
|
32
|
-
@ipaddr_lines = @linux_ip_addr.split("\n")
|
33
|
-
@iplink_lines = @linux_ip_link_s_d.split("\n")
|
34
|
-
@ipneighbor_lines = @linux_ip_neighbor_show.split("\n")
|
35
|
-
@ipneighbor_lines_inet6 = @linux_ip_inet6_neighbor_show.split("\n")
|
36
|
-
@ip_route_lines = @linux_ip_route.split("\n")
|
37
|
-
@ip_route_inet6_lines = @linux_ip_route_inet6.split("\n")
|
38
|
-
end
|
39
|
-
|
40
28
|
def do_stubs
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
29
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
30
|
+
@plugin.stub(:shell_out).with("ip addr").and_return(mock_shell_out(0, @linux_ip_addr, ""))
|
31
|
+
@plugin.stub(:shell_out).with("ip -d -s link").and_return(mock_shell_out(0, @linux_ip_link_s_d, ""))
|
32
|
+
@plugin.stub(:shell_out).with("ip -f inet neigh show").and_return(mock_shell_out(0, @linux_ip_neighbor_show, ""))
|
33
|
+
@plugin.stub(:shell_out).with("ip -f inet6 neigh show").and_return(mock_shell_out(0, @linux_ip_inet6_neighbor_show, ""))
|
34
|
+
@plugin.stub(:shell_out).with("ip -f inet route show").and_return(mock_shell_out(0, @linux_ip_route, ""))
|
35
|
+
@plugin.stub(:shell_out).with("ip -f inet6 route show").and_return(mock_shell_out(0, @linux_ip_route_inet6, ""))
|
36
|
+
@plugin.stub(:shell_out).with("route -n").and_return(mock_shell_out(0, @linux_route_n, ""))
|
37
|
+
@plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @linux_ifconfig, ""))
|
38
|
+
@plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @linux_arp_an, ""))
|
50
39
|
end
|
51
40
|
|
52
41
|
describe Ohai::System, "Linux Network Plugin" do
|
@@ -256,7 +245,6 @@ NEIGHBOR_SHOW
|
|
256
245
|
192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
|
257
246
|
172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
|
258
247
|
192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
|
259
|
-
10.5.4.0/24 \\ nexthop via 10.5.4.1 dev eth0 weight 1\\ nexthop via 10.5.4.2 dev eth0 weight 1
|
260
248
|
default via 10.116.201.1 dev eth0
|
261
249
|
IP_ROUTE_SCOPE
|
262
250
|
|
@@ -267,208 +255,192 @@ fe80::/64 dev eth0.11 proto kernel metric 256
|
|
267
255
|
default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
268
256
|
IP_ROUTE_SCOPE
|
269
257
|
|
270
|
-
@
|
271
|
-
@
|
272
|
-
@
|
273
|
-
@stdin_iplink = StringIO.new
|
274
|
-
@stdin_ipneighbor = StringIO.new
|
275
|
-
@stdin_ipneighbor_inet6 = StringIO.new
|
276
|
-
@stdin_ip_route = StringIO.new
|
277
|
-
@stdin_ip_route_inet6 = StringIO.new
|
278
|
-
|
279
|
-
prepare_data
|
280
|
-
|
281
|
-
@ohai = Ohai::System.new
|
282
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
283
|
-
|
284
|
-
@ohai.stub(:popen4).with("ifconfig -a")
|
285
|
-
@ohai.stub(:popen4).with("arp -an")
|
286
|
-
|
287
|
-
Ohai::Log.should_receive(:warn).with(/unable to detect/).exactly(3).times
|
288
|
-
@ohai._require_plugin("network")
|
258
|
+
@plugin = get_plugin("linux/network")
|
259
|
+
@plugin.stub(:shell_out).with("ifconfig -a").and_return([0, @linux_ifconfig, ""])
|
260
|
+
@plugin.stub(:shell_out).with("arp -an").and_return([0, @linux_arp_an, ""])
|
289
261
|
end
|
290
262
|
|
291
263
|
["ifconfig","iproute2"].each do |network_method|
|
292
264
|
|
293
265
|
describe "gathering IP layer address info via #{network_method}" do
|
294
266
|
before do
|
295
|
-
File.stub
|
267
|
+
File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
|
296
268
|
do_stubs
|
297
269
|
end
|
298
270
|
|
299
271
|
it "completes the run" do
|
300
272
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
301
|
-
@
|
302
|
-
@
|
273
|
+
@plugin.run
|
274
|
+
@plugin['network'].should_not be_nil
|
303
275
|
end
|
304
276
|
|
305
277
|
it "detects the interfaces" do
|
306
|
-
@
|
307
|
-
@
|
278
|
+
@plugin.run
|
279
|
+
@plugin['network']['interfaces'].keys.sort.should == ["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "foo:veth0@eth0", "lo", "tun0", "venet0", "venet0:0"]
|
308
280
|
end
|
309
281
|
|
310
282
|
it "detects the ipv4 addresses of the ethernet interface" do
|
311
|
-
@
|
312
|
-
@
|
313
|
-
@
|
314
|
-
@
|
315
|
-
@
|
283
|
+
@plugin.run
|
284
|
+
@plugin['network']['interfaces']['eth0']['addresses'].keys.should include('10.116.201.76')
|
285
|
+
@plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['netmask'].should == '255.255.255.0'
|
286
|
+
@plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['broadcast'].should == '10.116.201.255'
|
287
|
+
@plugin['network']['interfaces']['eth0']['addresses']['10.116.201.76']['family'].should == 'inet'
|
316
288
|
end
|
317
289
|
|
318
290
|
it "detects the ipv4 addresses of an ethernet subinterface" do
|
319
|
-
@
|
320
|
-
@
|
321
|
-
@
|
322
|
-
@
|
323
|
-
@
|
291
|
+
@plugin.run
|
292
|
+
@plugin['network']['interfaces']['eth0.11']['addresses'].keys.should include('192.168.0.16')
|
293
|
+
@plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['netmask'].should == '255.255.255.0'
|
294
|
+
@plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['broadcast'].should == '192.168.0.255'
|
295
|
+
@plugin['network']['interfaces']['eth0.11']['addresses']['192.168.0.16']['family'].should == 'inet'
|
324
296
|
end
|
325
297
|
|
326
298
|
it "detects the ipv6 addresses of the ethernet interface" do
|
327
|
-
@
|
328
|
-
@
|
329
|
-
@
|
330
|
-
@
|
331
|
-
@
|
299
|
+
@plugin.run
|
300
|
+
@plugin['network']['interfaces']['eth0']['addresses'].keys.should include('fe80::1031:3dff:fe02:bea2')
|
301
|
+
@plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['scope'].should == 'Link'
|
302
|
+
@plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['prefixlen'].should == '64'
|
303
|
+
@plugin['network']['interfaces']['eth0']['addresses']['fe80::1031:3dff:fe02:bea2']['family'].should == 'inet6'
|
332
304
|
end
|
333
305
|
|
334
306
|
it "detects the ipv6 addresses of an ethernet subinterface" do
|
335
|
-
@
|
307
|
+
@plugin.run
|
336
308
|
%w[ 1111:2222:3333:4444::2 1111:2222:3333:4444::3 ].each do |addr|
|
337
|
-
@
|
338
|
-
@
|
339
|
-
@
|
340
|
-
@
|
309
|
+
@plugin['network']['interfaces']['eth0.11']['addresses'].keys.should include(addr)
|
310
|
+
@plugin['network']['interfaces']['eth0.11']['addresses'][addr]['scope'].should == 'Global'
|
311
|
+
@plugin['network']['interfaces']['eth0.11']['addresses'][addr]['prefixlen'].should == '64'
|
312
|
+
@plugin['network']['interfaces']['eth0.11']['addresses'][addr]['family'].should == 'inet6'
|
341
313
|
end
|
342
314
|
end
|
343
315
|
|
344
316
|
it "detects the mac addresses of the ethernet interface" do
|
345
|
-
@
|
346
|
-
@
|
347
|
-
@
|
317
|
+
@plugin.run
|
318
|
+
@plugin['network']['interfaces']['eth0']['addresses'].keys.should include('12:31:3D:02:BE:A2')
|
319
|
+
@plugin['network']['interfaces']['eth0']['addresses']['12:31:3D:02:BE:A2']['family'].should == 'lladdr'
|
348
320
|
end
|
349
321
|
|
350
322
|
it "detects the encapsulation type of the ethernet interface" do
|
351
|
-
@
|
352
|
-
@
|
323
|
+
@plugin.run
|
324
|
+
@plugin['network']['interfaces']['eth0']['encapsulation'].should == 'Ethernet'
|
353
325
|
end
|
354
326
|
|
355
327
|
it "detects the flags of the ethernet interface" do
|
356
|
-
@
|
328
|
+
@plugin.run
|
357
329
|
if network_method == "ifconfig"
|
358
|
-
@
|
330
|
+
@plugin['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','MULTICAST','RUNNING','UP']
|
359
331
|
else
|
360
|
-
@
|
332
|
+
@plugin['network']['interfaces']['eth0']['flags'].sort.should == ['BROADCAST','LOWER_UP','MULTICAST','UP']
|
361
333
|
end
|
362
334
|
end
|
363
335
|
|
364
336
|
it "detects the number of the ethernet interface" do
|
365
|
-
@
|
366
|
-
@
|
337
|
+
@plugin.run
|
338
|
+
@plugin['network']['interfaces']['eth0']['number'].should == "0"
|
367
339
|
end
|
368
340
|
|
369
341
|
it "detects the mtu of the ethernet interface" do
|
370
|
-
@
|
371
|
-
@
|
342
|
+
@plugin.run
|
343
|
+
@plugin['network']['interfaces']['eth0']['mtu'].should == "1500"
|
372
344
|
end
|
373
345
|
|
374
346
|
it "detects the ipv4 addresses of the loopback interface" do
|
375
|
-
@
|
376
|
-
@
|
377
|
-
@
|
378
|
-
@
|
347
|
+
@plugin.run
|
348
|
+
@plugin['network']['interfaces']['lo']['addresses'].keys.should include('127.0.0.1')
|
349
|
+
@plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['netmask'].should == '255.0.0.0'
|
350
|
+
@plugin['network']['interfaces']['lo']['addresses']['127.0.0.1']['family'].should == 'inet'
|
379
351
|
end
|
380
352
|
|
381
353
|
it "detects the ipv6 addresses of the loopback interface" do
|
382
|
-
@
|
383
|
-
@
|
384
|
-
@
|
385
|
-
@
|
386
|
-
@
|
354
|
+
@plugin.run
|
355
|
+
@plugin['network']['interfaces']['lo']['addresses'].keys.should include('::1')
|
356
|
+
@plugin['network']['interfaces']['lo']['addresses']['::1']['scope'].should == 'Node'
|
357
|
+
@plugin['network']['interfaces']['lo']['addresses']['::1']['prefixlen'].should == '128'
|
358
|
+
@plugin['network']['interfaces']['lo']['addresses']['::1']['family'].should == 'inet6'
|
387
359
|
end
|
388
360
|
|
389
361
|
it "detects the encapsulation type of the loopback interface" do
|
390
|
-
@
|
391
|
-
@
|
362
|
+
@plugin.run
|
363
|
+
@plugin['network']['interfaces']['lo']['encapsulation'].should == 'Loopback'
|
392
364
|
end
|
393
365
|
|
394
366
|
it "detects the flags of the ethernet interface" do
|
395
|
-
@
|
367
|
+
@plugin.run
|
396
368
|
if network_method == "ifconfig"
|
397
|
-
@
|
369
|
+
@plugin['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','RUNNING','UP']
|
398
370
|
else
|
399
|
-
@
|
371
|
+
@plugin['network']['interfaces']['lo']['flags'].sort.should == ['LOOPBACK','LOWER_UP','UP']
|
400
372
|
end
|
401
373
|
end
|
402
374
|
|
403
375
|
|
404
376
|
it "detects the mtu of the loopback interface" do
|
405
|
-
@
|
406
|
-
@
|
377
|
+
@plugin.run
|
378
|
+
@plugin['network']['interfaces']['lo']['mtu'].should == "16436"
|
407
379
|
end
|
408
380
|
|
409
381
|
it "detects the arp entries" do
|
410
|
-
@
|
411
|
-
@
|
382
|
+
@plugin.run
|
383
|
+
@plugin['network']['interfaces']['eth0']['arp']['10.116.201.1'].should == 'fe:ff:ff:ff:ff:ff'
|
412
384
|
end
|
413
385
|
|
414
386
|
end
|
415
387
|
|
416
388
|
describe "gathering interface counters via #{network_method}" do
|
417
389
|
before do
|
418
|
-
File.stub
|
390
|
+
File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
|
419
391
|
do_stubs
|
420
|
-
@
|
392
|
+
@plugin.run
|
421
393
|
end
|
422
394
|
|
423
395
|
it "detects the ethernet counters" do
|
424
|
-
@
|
425
|
-
@
|
426
|
-
@
|
427
|
-
@
|
428
|
-
@
|
429
|
-
@
|
430
|
-
@
|
396
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['bytes'].should == "691785313"
|
397
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['packets'].should == "1919690"
|
398
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['collisions'].should == "0"
|
399
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['queuelen'].should == "1000"
|
400
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['errors'].should == "0"
|
401
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['carrier'].should == "0"
|
402
|
+
@plugin['counters']['network']['interfaces']['eth0']['tx']['drop'].should == "0"
|
431
403
|
|
432
|
-
@
|
433
|
-
@
|
434
|
-
@
|
435
|
-
@
|
436
|
-
@
|
404
|
+
@plugin['counters']['network']['interfaces']['eth0']['rx']['bytes'].should == "1392844460"
|
405
|
+
@plugin['counters']['network']['interfaces']['eth0']['rx']['packets'].should == "2659966"
|
406
|
+
@plugin['counters']['network']['interfaces']['eth0']['rx']['errors'].should == "0"
|
407
|
+
@plugin['counters']['network']['interfaces']['eth0']['rx']['overrun'].should == "0"
|
408
|
+
@plugin['counters']['network']['interfaces']['eth0']['rx']['drop'].should == "0"
|
437
409
|
end
|
438
410
|
|
439
411
|
it "detects the loopback counters" do
|
440
|
-
@
|
441
|
-
@
|
442
|
-
@
|
443
|
-
@
|
444
|
-
@
|
445
|
-
@
|
446
|
-
|
447
|
-
@
|
448
|
-
@
|
449
|
-
@
|
450
|
-
@
|
451
|
-
@
|
412
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['bytes'].should == "35224"
|
413
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['packets'].should == "524"
|
414
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['collisions'].should == "0"
|
415
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['errors'].should == "0"
|
416
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['carrier'].should == "0"
|
417
|
+
@plugin['counters']['network']['interfaces']['lo']['tx']['drop'].should == "0"
|
418
|
+
|
419
|
+
@plugin['counters']['network']['interfaces']['lo']['rx']['bytes'].should == "35224"
|
420
|
+
@plugin['counters']['network']['interfaces']['lo']['rx']['packets'].should == "524"
|
421
|
+
@plugin['counters']['network']['interfaces']['lo']['rx']['errors'].should == "0"
|
422
|
+
@plugin['counters']['network']['interfaces']['lo']['rx']['overrun'].should == "0"
|
423
|
+
@plugin['counters']['network']['interfaces']['lo']['rx']['drop'].should == "0"
|
452
424
|
end
|
453
425
|
end
|
454
426
|
|
455
427
|
describe "setting the node's default IP address attribute with #{network_method}" do
|
456
428
|
before do
|
457
|
-
File.stub
|
429
|
+
File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" )
|
458
430
|
do_stubs
|
459
431
|
end
|
460
432
|
|
461
433
|
describe "without a subinterface" do
|
462
434
|
before do
|
463
|
-
@
|
435
|
+
@plugin.run
|
464
436
|
end
|
465
437
|
|
466
438
|
it "finds the default interface by asking which iface has the default route" do
|
467
|
-
@
|
439
|
+
@plugin['network']['default_interface'].should == 'eth0'
|
468
440
|
end
|
469
441
|
|
470
442
|
it "finds the default gateway by asking which iface has the default route" do
|
471
|
-
@
|
443
|
+
@plugin['network']['default_gateway'].should == '10.116.201.1'
|
472
444
|
end
|
473
445
|
end
|
474
446
|
|
@@ -484,18 +456,17 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
|
|
484
456
|
10.116.201.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
|
485
457
|
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
|
486
458
|
ROUTE_N
|
487
|
-
prepare_data
|
488
459
|
do_stubs
|
489
460
|
|
490
|
-
@
|
461
|
+
@plugin.run
|
491
462
|
end
|
492
463
|
|
493
464
|
it "finds the default interface by asking which iface has the default route" do
|
494
|
-
@
|
465
|
+
@plugin['network']['default_interface'].should == 'eth0'
|
495
466
|
end
|
496
467
|
|
497
468
|
it "finds the default interface by asking which iface has the default route" do
|
498
|
-
@
|
469
|
+
@plugin['network']['default_gateway'].should == '0.0.0.0'
|
499
470
|
end
|
500
471
|
end
|
501
472
|
|
@@ -512,18 +483,17 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
|
|
512
483
|
0.0.0.0 192.168.0.15 0.0.0.0 UG 0 0 0 eth0.11
|
513
484
|
ROUTE_N
|
514
485
|
|
515
|
-
prepare_data
|
516
486
|
do_stubs
|
517
487
|
|
518
|
-
@
|
488
|
+
@plugin.run
|
519
489
|
end
|
520
490
|
|
521
491
|
it "finds the default interface by asking which iface has the default route" do
|
522
|
-
@
|
492
|
+
@plugin['network']["default_interface"].should == 'eth0.11'
|
523
493
|
end
|
524
494
|
|
525
495
|
it "finds the default interface by asking which iface has the default route" do
|
526
|
-
@
|
496
|
+
@plugin['network']["default_gateway"].should == '192.168.0.15'
|
527
497
|
end
|
528
498
|
end
|
529
499
|
end
|
@@ -531,82 +501,80 @@ ROUTE_N
|
|
531
501
|
|
532
502
|
describe "for newer network features using iproute2 only" do
|
533
503
|
before do
|
534
|
-
File.stub
|
504
|
+
File.stub(:exist?).with("/sbin/ip").and_return(true) # iproute2 only
|
535
505
|
do_stubs
|
536
506
|
end
|
537
507
|
|
538
508
|
it "completes the run" do
|
539
509
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
540
|
-
@
|
541
|
-
@
|
510
|
+
@plugin.run
|
511
|
+
@plugin['network'].should_not be_nil
|
542
512
|
end
|
543
513
|
|
544
514
|
it "finds the default inet6 interface if there's a inet6 default route" do
|
545
|
-
@
|
546
|
-
@
|
515
|
+
@plugin.run
|
516
|
+
@plugin['network']['default_inet6_interface'].should == 'eth0.11'
|
547
517
|
end
|
548
518
|
|
549
519
|
it "finds the default inet6 gateway if there's a inet6 default route" do
|
550
|
-
@
|
551
|
-
@
|
520
|
+
@plugin.run
|
521
|
+
@plugin['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::1'
|
552
522
|
end
|
553
523
|
|
554
524
|
it "finds inet6 neighbours" do
|
555
|
-
@
|
556
|
-
@
|
525
|
+
@plugin.run
|
526
|
+
@plugin['network']['interfaces']['eth0.11']['neighbour_inet6']['1111:2222:3333:4444::1'].should == '00:1c:0e:12:34:56'
|
557
527
|
end
|
558
528
|
|
559
529
|
it "detects the ipv4 addresses of an ethernet interface with a crazy name" do
|
560
|
-
@
|
561
|
-
@
|
562
|
-
@
|
563
|
-
@
|
530
|
+
@plugin.run
|
531
|
+
@plugin['network']['interfaces']['foo:veth0@eth0']['addresses'].keys.should include('192.168.212.2')
|
532
|
+
@plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['netmask'].should == '255.255.255.0'
|
533
|
+
@plugin['network']['interfaces']['foo:veth0@eth0']['addresses']['192.168.212.2']['family'].should == 'inet'
|
564
534
|
end
|
565
535
|
|
566
536
|
it "generates a fake interface for ip aliases for backward compatibility" do
|
567
|
-
@
|
568
|
-
@
|
569
|
-
@
|
570
|
-
@
|
537
|
+
@plugin.run
|
538
|
+
@plugin['network']['interfaces']['eth0:5']['addresses'].keys.should include('192.168.5.1')
|
539
|
+
@plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['netmask'].should == '255.255.255.0'
|
540
|
+
@plugin['network']['interfaces']['eth0:5']['addresses']['192.168.5.1']['family'].should == 'inet'
|
571
541
|
end
|
572
542
|
|
573
543
|
it "adds the vlan information of an interface" do
|
574
|
-
@
|
575
|
-
@
|
576
|
-
@
|
544
|
+
@plugin.run
|
545
|
+
@plugin['network']['interfaces']['eth0.11']['vlan']['id'].should == '11'
|
546
|
+
@plugin['network']['interfaces']['eth0.11']['vlan']['flags'].should == [ 'REORDER_HDR' ]
|
577
547
|
end
|
578
548
|
|
579
549
|
it "adds the state of an interface" do
|
580
|
-
@
|
581
|
-
@
|
550
|
+
@plugin.run
|
551
|
+
@plugin['network']['interfaces']['eth0.11']['state'].should == 'up'
|
582
552
|
end
|
583
553
|
|
584
554
|
describe "when dealing with routes" do
|
585
555
|
it "adds routes" do
|
586
|
-
@
|
587
|
-
@
|
588
|
-
@
|
589
|
-
@
|
590
|
-
@
|
591
|
-
@
|
592
|
-
@ohai['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
|
593
|
-
@ohai['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
|
556
|
+
@plugin.run
|
557
|
+
@plugin['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family =>"inet" )
|
558
|
+
@plugin['network']['interfaces']['foo:veth0@eth0']['routes'].should include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family =>"inet" )
|
559
|
+
@plugin['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
|
560
|
+
@plugin['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
|
561
|
+
@plugin['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "default", :via => "1111:2222:3333:4444::1", :metric => "1024", :family => "inet6")
|
594
562
|
end
|
595
563
|
|
596
564
|
describe "when there isn't a source field in route entries " do
|
597
565
|
it "doesn't set ipaddress" do
|
598
|
-
@
|
599
|
-
@
|
566
|
+
@plugin.run
|
567
|
+
@plugin['ipaddress'].should be nil
|
600
568
|
end
|
601
569
|
|
602
570
|
it "doesn't set macaddress" do
|
603
|
-
@
|
604
|
-
@
|
571
|
+
@plugin.run
|
572
|
+
@plugin['macaddress'].should be nil
|
605
573
|
end
|
606
574
|
|
607
575
|
it "doesn't set ip6address" do
|
608
|
-
@
|
609
|
-
@
|
576
|
+
@plugin.run
|
577
|
+
@plugin['ip6address'].should be nil
|
610
578
|
end
|
611
579
|
end
|
612
580
|
|
@@ -628,24 +596,23 @@ fe80::/64 dev eth0.11 proto kernel metric 256
|
|
628
596
|
default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
|
629
597
|
IP_ROUTE_SCOPE
|
630
598
|
|
631
|
-
prepare_data
|
632
599
|
do_stubs
|
633
600
|
end
|
634
601
|
|
635
602
|
it "completes the run" do
|
636
603
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
637
|
-
@
|
638
|
-
@
|
604
|
+
@plugin.run
|
605
|
+
@plugin['network'].should_not be_nil
|
639
606
|
end
|
640
607
|
|
641
608
|
it "sets ipaddress" do
|
642
|
-
@
|
643
|
-
@
|
609
|
+
@plugin.run
|
610
|
+
@plugin['ipaddress'].should == "10.116.201.76"
|
644
611
|
end
|
645
612
|
|
646
613
|
it "sets ip6address" do
|
647
|
-
@
|
648
|
-
@
|
614
|
+
@plugin.run
|
615
|
+
@plugin['ip6address'].should == "1111:2222:3333:4444::3"
|
649
616
|
end
|
650
617
|
end
|
651
618
|
|
@@ -669,26 +636,25 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
|
669
636
|
default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023
|
670
637
|
IP_ROUTE_SCOPE
|
671
638
|
|
672
|
-
prepare_data
|
673
639
|
do_stubs
|
674
640
|
end
|
675
641
|
|
676
642
|
it "completes the run" do
|
677
643
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
678
|
-
@
|
679
|
-
@
|
644
|
+
@plugin.run
|
645
|
+
@plugin['network'].should_not be_nil
|
680
646
|
end
|
681
647
|
|
682
648
|
it "sets default ipv4 interface and gateway" do
|
683
|
-
@
|
684
|
-
@
|
685
|
-
@
|
649
|
+
@plugin.run
|
650
|
+
@plugin['network']['default_interface'].should == 'eth0'
|
651
|
+
@plugin['network']['default_gateway'].should == '10.116.201.254'
|
686
652
|
end
|
687
653
|
|
688
654
|
it "sets default ipv6 interface and gateway" do
|
689
|
-
@
|
690
|
-
@
|
691
|
-
@
|
655
|
+
@plugin.run
|
656
|
+
@plugin['network']['default_inet6_interface'].should == 'eth0.11'
|
657
|
+
@plugin['network']['default_inet6_gateway'].should == '1111:2222:3333:4444::ffff'
|
692
658
|
end
|
693
659
|
end
|
694
660
|
|
@@ -712,24 +678,23 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
|
712
678
|
default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:3333:4444::2
|
713
679
|
IP_ROUTE_SCOPE
|
714
680
|
|
715
|
-
prepare_data
|
716
681
|
do_stubs
|
717
682
|
end
|
718
683
|
|
719
684
|
it "completes the run" do
|
720
685
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
721
|
-
@
|
722
|
-
@
|
686
|
+
@plugin.run
|
687
|
+
@plugin['network'].should_not be_nil
|
723
688
|
end
|
724
689
|
|
725
690
|
it "sets ipaddress" do
|
726
|
-
@
|
727
|
-
@
|
691
|
+
@plugin.run
|
692
|
+
@plugin["ipaddress"].should == "10.116.201.74"
|
728
693
|
end
|
729
694
|
|
730
695
|
it "sets ip6address" do
|
731
|
-
@
|
732
|
-
@
|
696
|
+
@plugin.run
|
697
|
+
@plugin["ip6address"].should == "1111:2222:3333:4444::2"
|
733
698
|
end
|
734
699
|
end
|
735
700
|
|
@@ -751,25 +716,24 @@ fe80::/64 dev eth0.11 proto kernel metric 256
|
|
751
716
|
default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
752
717
|
IP_ROUTE_SCOPE
|
753
718
|
|
754
|
-
prepare_data
|
755
719
|
do_stubs
|
756
720
|
end
|
757
721
|
|
758
722
|
it "completes the run" do
|
759
723
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
760
|
-
@
|
761
|
-
@
|
724
|
+
@plugin.run
|
725
|
+
@plugin['network'].should_not be_nil
|
762
726
|
end
|
763
727
|
|
764
728
|
it "sets ipaddress" do
|
765
|
-
@
|
766
|
-
@
|
729
|
+
@plugin.run
|
730
|
+
@plugin['ipaddress'].should == "10.116.201.76"
|
767
731
|
end
|
768
732
|
|
769
733
|
describe "when about to set macaddress" do
|
770
734
|
it "sets macaddress" do
|
771
|
-
@
|
772
|
-
@
|
735
|
+
@plugin.run
|
736
|
+
@plugin['macaddress'].should == "12:31:3D:02:BE:A2"
|
773
737
|
end
|
774
738
|
|
775
739
|
describe "when then interface has the NOARP flag" do
|
@@ -779,26 +743,25 @@ IP_ROUTE_SCOPE
|
|
779
743
|
default via 172.16.19.1 dev tun0
|
780
744
|
IP_ROUTE
|
781
745
|
|
782
|
-
prepare_data
|
783
746
|
do_stubs
|
784
747
|
end
|
785
748
|
|
786
749
|
it "completes the run" do
|
787
750
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
788
|
-
@
|
789
|
-
@
|
751
|
+
@plugin.run
|
752
|
+
@plugin['network'].should_not be_nil
|
790
753
|
end
|
791
754
|
|
792
755
|
it "doesn't set macaddress" do
|
793
|
-
@
|
794
|
-
@
|
756
|
+
@plugin.run
|
757
|
+
@plugin['macaddress'].should be_nil
|
795
758
|
end
|
796
759
|
end
|
797
760
|
end
|
798
761
|
|
799
762
|
it "sets ip6address" do
|
800
|
-
@
|
801
|
-
@
|
763
|
+
@plugin.run
|
764
|
+
@plugin['ip6address'].should == "1111:2222:3333:4444::3"
|
802
765
|
end
|
803
766
|
end
|
804
767
|
|
@@ -808,19 +771,18 @@ IP_ROUTE
|
|
808
771
|
default dev venet0 scope link
|
809
772
|
IP_ROUTE
|
810
773
|
|
811
|
-
prepare_data
|
812
774
|
do_stubs
|
813
775
|
end
|
814
776
|
|
815
777
|
it "completes the run" do
|
816
778
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
817
|
-
@
|
818
|
-
@
|
779
|
+
@plugin.run
|
780
|
+
@plugin['network'].should_not be_nil
|
819
781
|
end
|
820
782
|
|
821
783
|
it "doesn't set ipaddress" do
|
822
|
-
@
|
823
|
-
@
|
784
|
+
@plugin.run
|
785
|
+
@plugin['ipaddress'].should be_nil
|
824
786
|
end
|
825
787
|
end
|
826
788
|
|
@@ -831,19 +793,18 @@ fe80::/64 dev eth0 proto kernel metric 256
|
|
831
793
|
default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7 metric 1024
|
832
794
|
IP_ROUTE_SCOPE
|
833
795
|
|
834
|
-
prepare_data
|
835
796
|
do_stubs
|
836
797
|
end
|
837
798
|
|
838
799
|
it "completes the run" do
|
839
800
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
840
|
-
@
|
841
|
-
@
|
801
|
+
@plugin.run
|
802
|
+
@plugin['network'].should_not be_nil
|
842
803
|
end
|
843
804
|
|
844
805
|
it "doesn't set ip6address" do
|
845
|
-
@
|
846
|
-
@
|
806
|
+
@plugin.run
|
807
|
+
@plugin['ip6address'].should be_nil
|
847
808
|
end
|
848
809
|
|
849
810
|
end
|
@@ -864,24 +825,23 @@ fe80::/64 dev eth0.11 proto kernel metric 256
|
|
864
825
|
1111:2222:3333:4444::/64 dev eth0.11 metric 1024 src 1111:2222:3333:4444::3
|
865
826
|
IP_ROUTE
|
866
827
|
|
867
|
-
prepare_data
|
868
828
|
do_stubs
|
869
829
|
end
|
870
830
|
|
871
831
|
it "completes the run" do
|
872
832
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
873
|
-
@
|
874
|
-
@
|
833
|
+
@plugin.run
|
834
|
+
@plugin['network'].should_not be_nil
|
875
835
|
end
|
876
836
|
|
877
837
|
it "doesn't set ipaddress" do
|
878
|
-
@
|
879
|
-
@
|
838
|
+
@plugin.run
|
839
|
+
@plugin['ipaddress'].should be_nil
|
880
840
|
end
|
881
841
|
|
882
842
|
it "doesn't set ip6address" do
|
883
|
-
@
|
884
|
-
@
|
843
|
+
@plugin.run
|
844
|
+
@plugin['ip6address'].should be_nil
|
885
845
|
end
|
886
846
|
end
|
887
847
|
|
@@ -902,31 +862,30 @@ fe80::/64 dev eth0.11 proto kernel metric 256
|
|
902
862
|
default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
903
863
|
IP_ROUTE
|
904
864
|
|
905
|
-
prepare_data
|
906
865
|
do_stubs
|
907
866
|
end
|
908
867
|
|
909
868
|
it "completes the run" do
|
910
869
|
Ohai::Log.should_not_receive(:debug).with(/Plugin linux::network threw exception/)
|
911
|
-
@
|
912
|
-
@
|
870
|
+
@plugin.run
|
871
|
+
@plugin['network'].should_not be_nil
|
913
872
|
end
|
914
873
|
|
915
874
|
it "doesn't add bogus routes" do
|
916
|
-
@
|
917
|
-
@
|
918
|
-
@
|
919
|
-
@
|
875
|
+
@plugin.run
|
876
|
+
@plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.116.201.0/26", :proto => "kernel", :family => "inet", :via => "10.116.201.39" )
|
877
|
+
@plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "10.118.19.0/26", :proto => "kernel", :family => "inet", :via => "10.118.19.39" )
|
878
|
+
@plugin['network']['interfaces']['eth0']['routes'].should_not include Mash.new( :destination => "1111:2222:3333:4444::/64", :family => "inet6", :metric => "1024" )
|
920
879
|
end
|
921
880
|
|
922
881
|
it "doesn't set ipaddress" do
|
923
|
-
@
|
924
|
-
@
|
882
|
+
@plugin.run
|
883
|
+
@plugin['ipaddress'].should be_nil
|
925
884
|
end
|
926
885
|
|
927
886
|
it "doesn't set ip6address" do
|
928
|
-
@
|
929
|
-
@
|
887
|
+
@plugin.run
|
888
|
+
@plugin['ip6address'].should be_nil
|
930
889
|
end
|
931
890
|
end
|
932
891
|
|
@@ -936,14 +895,13 @@ IP_ROUTE
|
|
936
895
|
@linux_ip_route = <<-IP_ROUTE
|
937
896
|
192.168.122.0/24 dev virbr0 proto kernel src 192.168.122.1
|
938
897
|
IP_ROUTE
|
939
|
-
prepare_data
|
940
898
|
do_stubs
|
941
899
|
end
|
942
900
|
|
943
901
|
it "logs a message and skips previously unseen interfaces in 'ip route show'" do
|
944
902
|
Ohai::Log.should_receive(:debug).with("Skipping previously unseen interface from 'ip route show': virbr0").once
|
945
|
-
Ohai::Log.
|
946
|
-
@
|
903
|
+
Ohai::Log.stub(:debug) # Catches the 'Loading plugin network' type messages
|
904
|
+
@plugin.run
|
947
905
|
end
|
948
906
|
end
|
949
907
|
end
|