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,14 +21,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "FreeBSD 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(:freebsd)
|
26
|
+
@plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
|
27
|
+
@plugin.stub(:shell_out).with("hostname -f").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("freebsd::hostname", "hostname", "hostname -s", "katie")
|
32
|
-
|
32
|
+
|
33
33
|
it_should_check_from("freebsd::hostname", "fqdn", "hostname -f", "katie.bethell")
|
34
|
+
|
35
|
+
it_should_check_from("freebsd::hostname", "machinename", "hostname", "katie.local")
|
34
36
|
end
|
@@ -21,17 +21,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "FreeBSD 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(:freebsd)
|
26
|
+
@plugin.stub(:init_kernel).and_return({:name => "freebsd"})
|
27
|
+
@plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
|
28
|
+
@plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
|
29
|
+
@plugin.stub(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).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
|
|
37
37
|
end
|
@@ -21,20 +21,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "FreeBSD plugin platform" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@ohai[:os] = "freebsd"
|
24
|
+
@plugin = get_plugin("freebsd/platform")
|
25
|
+
@plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
|
26
|
+
@plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
|
27
|
+
@plugin.stub(:collect_os).and_return(:freebsd)
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
it "should set platform to lowercased lsb[:id]" do
|
32
|
-
@
|
33
|
-
@
|
31
|
+
@plugin.run
|
32
|
+
@plugin[:platform].should == "freebsd"
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should set platform_version to lsb[:release]" do
|
37
|
-
@
|
38
|
-
@
|
36
|
+
@plugin.run
|
37
|
+
@plugin[:platform_version].should == "7.1"
|
39
38
|
end
|
40
39
|
end
|
@@ -21,74 +21,74 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "FreeBSD virtualization plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@pid = 42
|
31
|
-
@ohai.stub(:popen4).with("/sbin/kldstat")
|
32
|
-
@ohai.stub(:from)
|
24
|
+
@plugin = get_plugin("freebsd/virtualization")
|
25
|
+
@plugin.stub(:collect_os).and_return(:freebsd)
|
26
|
+
@plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
|
27
|
+
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
|
28
|
+
@plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
|
29
|
+
@plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
|
33
30
|
end
|
34
31
|
|
35
32
|
context "jails" do
|
36
33
|
it "detects we are in a jail" do
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
34
|
+
@plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
|
35
|
+
@plugin.run
|
36
|
+
@plugin[:virtualization][:system].should == "jail"
|
37
|
+
@plugin[:virtualization][:role].should == "guest"
|
41
38
|
end
|
42
39
|
|
43
|
-
it "detects we are
|
44
|
-
|
45
|
-
|
46
|
-
@
|
47
|
-
@
|
40
|
+
it "detects we are hosting jails" do
|
41
|
+
# from http://www.freebsd.org/doc/handbook/jails-application.html
|
42
|
+
@jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www"
|
43
|
+
@plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, ""))
|
44
|
+
@plugin.run
|
45
|
+
@plugin[:virtualization][:system].should == "jail"
|
46
|
+
@plugin[:virtualization][:role].should == "host"
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
|
52
51
|
context "when on a virtualbox guest" do
|
53
52
|
before do
|
54
|
-
@
|
53
|
+
@vbox_guest = <<-OUT
|
55
54
|
Id Refs Address Size Name
|
56
55
|
1 40 0xffffffff80100000 d20428 kernel
|
57
56
|
7 3 0xffffffff81055000 41e88 vboxguest.ko
|
58
57
|
OUT
|
59
|
-
@
|
58
|
+
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, @vbox_guest, ""))
|
60
59
|
end
|
61
60
|
|
62
61
|
it "detects we are a guest" do
|
63
|
-
@
|
64
|
-
@
|
65
|
-
@
|
62
|
+
@plugin.run
|
63
|
+
@plugin[:virtualization][:system].should == "vbox"
|
64
|
+
@plugin[:virtualization][:role].should == "guest"
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
68
|
context "when on a virtualbox host" do
|
70
69
|
before do
|
71
|
-
@stdout =
|
70
|
+
@stdout = <<-OUT
|
72
71
|
Id Refs Address Size Name
|
73
72
|
1 40 0xffffffff80100000 d20428 kernel
|
74
73
|
7 3 0xffffffff81055000 41e88 vboxdrv.ko
|
75
74
|
OUT
|
76
|
-
@
|
75
|
+
@plugin.stub(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
|
77
76
|
end
|
78
77
|
|
79
78
|
it "detects we are a host" do
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
79
|
+
@plugin.run
|
80
|
+
@plugin[:virtualization][:system].should == "vbox"
|
81
|
+
@plugin[:virtualization][:role].should == "host"
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
85
|
context "when on a QEMU guest" do
|
87
86
|
it "detects we are a guest" do
|
88
|
-
@
|
89
|
-
@
|
90
|
-
@
|
91
|
-
@
|
87
|
+
@qemu_guest = 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)'
|
88
|
+
@plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, @qemu_guest, ""))
|
89
|
+
@plugin.run
|
90
|
+
@plugin[:virtualization][:system].should == "kvm"
|
91
|
+
@plugin[:virtualization][:role].should == "guest"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -16,24 +16,24 @@
|
|
16
16
|
#
|
17
17
|
|
18
18
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
19
|
-
require '
|
19
|
+
require 'open-uri'
|
20
20
|
|
21
21
|
describe Ohai::System, "plugin gce" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@ohai.stub(:require_plugin).and_return(true)
|
23
|
+
@plugin = get_plugin("gce")
|
25
24
|
end
|
26
25
|
|
27
26
|
shared_examples_for "!gce" do
|
28
|
-
it
|
29
|
-
@
|
27
|
+
it "should NOT attempt to fetch the gce metadata" do
|
28
|
+
@plugin.should_not_receive(:http_client)
|
29
|
+
@plugin.run
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
shared_examples_for "gce" do
|
34
34
|
before(:each) do
|
35
35
|
@http_client = double("Net::HTTP client")
|
36
|
-
|
36
|
+
@plugin.stub(:http_client).and_return(@http_client)
|
37
37
|
IO.stub(:select).and_return([[],[1],[]])
|
38
38
|
t = double("connection")
|
39
39
|
t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
|
@@ -46,14 +46,15 @@ describe Ohai::System, "plugin gce" do
|
|
46
46
|
with("/computeMetadata/v1beta1/?recursive=true/").
|
47
47
|
and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code=>"200"))
|
48
48
|
|
49
|
-
@
|
49
|
+
@plugin.run
|
50
50
|
|
51
|
-
@
|
52
|
-
@
|
51
|
+
@plugin[:gce].should_not be_nil
|
52
|
+
@plugin[:gce]['instance'].should eq("hostname"=>"test-host")
|
53
53
|
end
|
54
|
+
|
54
55
|
end
|
55
56
|
|
56
|
-
describe "with hint file" do
|
57
|
+
describe "with hint file and with metadata connection" do
|
57
58
|
it_should_behave_like "gce"
|
58
59
|
|
59
60
|
before(:each) do
|
@@ -64,26 +65,19 @@ describe Ohai::System, "plugin gce" do
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
|
-
describe "without hint file" do
|
68
|
+
describe "without hint file and without metadata connection" do
|
68
69
|
it_should_behave_like "!gce"
|
69
70
|
|
70
71
|
before(:each) do
|
71
72
|
File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
|
72
73
|
File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
|
81
|
-
File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
|
82
|
-
|
83
|
-
File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
|
84
|
-
File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
|
85
|
-
File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
|
86
|
-
File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
|
74
|
+
|
75
|
+
# Raise Errno::ENOENT to simulate the scenario in which metadata server
|
76
|
+
# can not be connected
|
77
|
+
t = double("connection")
|
78
|
+
t.stub(:connect_nonblock).and_raise(Errno::ENOENT)
|
79
|
+
Socket.stub(:new).and_return(t)
|
80
|
+
Socket.stub(:pack_sockaddr_in).and_return(nil)
|
87
81
|
end
|
88
82
|
end
|
89
83
|
|
@@ -22,32 +22,26 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
|
|
22
22
|
describe Ohai::System, "plugin groovy" 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("groovy")
|
26
|
+
@plugin[:languages] = Mash.new
|
29
27
|
@stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n"
|
30
|
-
@
|
31
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr])
|
28
|
+
@plugin.stub(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
|
32
29
|
end
|
33
30
|
|
34
31
|
it "should get the groovy version from running groovy -v" do
|
35
|
-
@
|
36
|
-
@
|
32
|
+
@plugin.should_receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
|
33
|
+
@plugin.run
|
37
34
|
end
|
38
35
|
|
39
36
|
it "should set languages[:groovy][:version]" do
|
40
|
-
@
|
41
|
-
@
|
37
|
+
@plugin.run
|
38
|
+
@plugin.languages[:groovy][:version].should eql("1.6.3")
|
42
39
|
end
|
43
40
|
|
44
41
|
it "should not set the languages[:groovy] tree up if groovy command fails" do
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr])
|
49
|
-
@ohai._require_plugin("groovy")
|
50
|
-
@ohai.languages.should_not have_key(:groovy)
|
42
|
+
@plugin.stub(:shell_out).with("groovy -v").and_return(mock_shell_out(1, @stdout, ""))
|
43
|
+
@plugin.run
|
44
|
+
@plugin.languages.should_not have_key(:groovy)
|
51
45
|
end
|
52
46
|
|
53
47
|
end
|
@@ -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,29 +21,54 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "hostname plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
24
|
+
@plugin = get_plugin("hostname")
|
25
|
+
@plugin.stub(:collect_os).and_return(:default)
|
26
|
+
@plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
context "when sigar is not installed" do
|
30
|
+
before(:each) do
|
31
|
+
@plugin.stub(:sigar_is_available?).and_return(false)
|
32
|
+
@plugin.should_not_receive(:get_fqdn_from_sigar)
|
33
|
+
@plugin.stub(:resolve_fqdn).and_return("katie.bethell")
|
34
|
+
end
|
35
|
+
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
it "should use #resolve_fqdn to find the fqdn" do
|
38
|
+
@plugin.run
|
39
|
+
@plugin[:fqdn].should == "katie.bethell"
|
40
|
+
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
it "should set the domain to everything after the first dot of the fqdn" do
|
43
|
+
@plugin.run
|
44
|
+
@plugin[:domain].should == "bethell"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should set the [short] hostname to everything before the first dot of the fqdn" do
|
48
|
+
@plugin.run
|
49
|
+
@plugin[:hostname].should == "katie"
|
50
|
+
end
|
42
51
|
end
|
43
52
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
context "when sigar is installed" do
|
54
|
+
before(:each) do
|
55
|
+
@plugin.stub(:sigar_is_available?).and_return(true)
|
56
|
+
@plugin.stub(:get_fqdn_from_sigar).and_return("katie.bethell")
|
57
|
+
end
|
58
|
+
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
59
|
+
it "should set the fqdn to the returned value from sigar" do
|
60
|
+
@plugin.run
|
61
|
+
@plugin[:fqdn].should == "katie.bethell"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should set the domain to everything after the first dot of the fqdn" do
|
65
|
+
@plugin.run
|
66
|
+
@plugin[:domain].should == "bethell"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should set the [short] hostname to everything before the first dot of the fqdn" do
|
70
|
+
@plugin.run
|
71
|
+
@plugin[:hostname].should == "katie"
|
72
|
+
end
|
48
73
|
end
|
49
74
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'ipaddr_extensions'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Ohai::System, "plugin ip_scopes" do
|
9
|
+
let(:plugin) { get_plugin('ip_scopes') }
|
10
|
+
let(:network) { Mash.new(:interfaces => interfaces) }
|
11
|
+
let(:interfaces) { Hash[
|
12
|
+
interface1, { :addresses => addresses1, :type => interface1_type },
|
13
|
+
interface2, { :addresses => addresses2, :type => interface2_type }] }
|
14
|
+
let(:interface1) { :eth0 }
|
15
|
+
let(:interface2) { :eth1 }
|
16
|
+
let(:addresses1) { {} }
|
17
|
+
let(:addresses2) { {} }
|
18
|
+
let(:interface1_type) { 'eth' }
|
19
|
+
let(:interface2_type) { 'eth' }
|
20
|
+
|
21
|
+
before { plugin[:network] = network }
|
22
|
+
|
23
|
+
if defined?(IPAddrExtensions)
|
24
|
+
context 'with ipaddr_extensions gem' do
|
25
|
+
let(:ip1) { '10.0.0.1' }
|
26
|
+
let(:ip2) { '1.2.3.4' }
|
27
|
+
let(:ip3) { 'fe80::8638:35ff:fe4e:dc74' }
|
28
|
+
|
29
|
+
let(:addresses1) { Hash[ip1, {}] }
|
30
|
+
let(:addresses2) { Hash[ip2, {}, ip3, {}] }
|
31
|
+
|
32
|
+
it "adds ip_scope to each address's information hash" do
|
33
|
+
plugin.run
|
34
|
+
expect(plugin[:network][:interfaces][:eth0][:addresses]['10.0.0.1'][:ip_scope]).to eq('RFC1918 PRIVATE')
|
35
|
+
expect(plugin[:network][:interfaces][:eth1][:addresses]['1.2.3.4'][:ip_scope]).to eq('GLOBAL UNICAST')
|
36
|
+
expect(plugin[:network][:interfaces][:eth1][:addresses]['fe80::8638:35ff:fe4e:dc74'][:ip_scope]).to eq('LINK LOCAL UNICAST')
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'privateaddress attribute' do
|
40
|
+
before { plugin.run }
|
41
|
+
|
42
|
+
context 'when host has multiple RFC1918 ethernet addresses' do
|
43
|
+
let(:ip1) { '10.0.0.1' }
|
44
|
+
let(:ip2) { '192.168.1.1' }
|
45
|
+
let(:interface1_type) { 'eth' }
|
46
|
+
let(:interface2_type) { 'eth' }
|
47
|
+
|
48
|
+
it 'picks the last RFC1918 address' do
|
49
|
+
expect(plugin[:privateaddress]).to eq('192.168.1.1')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when host has virtual and ethernet RFC1918 addresses' do
|
54
|
+
let(:ip1) { '10.0.0.1' }
|
55
|
+
let(:ip2) { '192.168.1.1' }
|
56
|
+
let(:interface1_type) { 'eth' }
|
57
|
+
let(:interface2_type) { 'ppp' }
|
58
|
+
|
59
|
+
it 'picks the non-virtual address' do
|
60
|
+
expect(plugin[:privateaddress]).to eq('10.0.0.1')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when host only has virtual RFC1918 addresses' do
|
65
|
+
let(:ip1) { '10.0.0.1' }
|
66
|
+
let(:ip2) { '192.168.1.1' }
|
67
|
+
let(:interface1_type) { 'ppp' }
|
68
|
+
let(:interface2_type) { 'ppp' }
|
69
|
+
|
70
|
+
it 'ignores them' do
|
71
|
+
expect(plugin[:privateaddress]).to be nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
unless defined?(IPAddrExtensions)
|
79
|
+
context 'without the ipaddr_extensions gem' do
|
80
|
+
let(:addresses1) { Hash['10.0.0.1', {}] }
|
81
|
+
|
82
|
+
before do
|
83
|
+
# standin for raising on `require 'ipaddr_extensions'`
|
84
|
+
plugin[:network][:interfaces].stub(:keys).and_raise(LoadError)
|
85
|
+
plugin.run
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'does not add ip_scope to addresses' do
|
89
|
+
expect(plugin[:network][:interfaces][:eth0][:addresses]['10.0.0.1'][:ip_scope]).to be nil
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'does not add a privateaddress attribute' do
|
93
|
+
expect(plugin[:privateaddress]).to be nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|