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
@@ -1,6 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jacques Marneweck (<jacques@powertrip.co.za>)
|
3
|
+
# Author:: Theodore Nordsieck (<theo@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) Jacques Marneweck
|
5
|
+
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
6
|
# License:: Apache License, Version 2.0
|
5
7
|
#
|
6
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,31 +23,27 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
|
|
21
23
|
describe Ohai::System, "plugin nodejs" do
|
22
24
|
|
23
25
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
27
|
-
@status = 0
|
26
|
+
@plugin = get_plugin("nodejs")
|
27
|
+
@plugin[:languages] = Mash.new
|
28
28
|
@stdout = "v0.8.11\n"
|
29
|
-
@
|
30
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"node -v"}).and_return([@status, @stdout, @stderr])
|
29
|
+
@plugin.stub(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
|
31
30
|
end
|
32
31
|
|
33
32
|
it "should get the nodejs version from running node -v" do
|
34
|
-
@
|
35
|
-
@
|
33
|
+
@plugin.should_receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
|
34
|
+
@plugin.run
|
36
35
|
end
|
37
36
|
|
38
37
|
it "should set languages[:nodejs][:version]" do
|
39
|
-
@
|
40
|
-
@
|
38
|
+
@plugin.run
|
39
|
+
@plugin.languages[:nodejs][:version].should eql("0.8.11")
|
41
40
|
end
|
42
41
|
|
43
42
|
it "should not set the languages[:nodejs] tree up if node command fails" do
|
44
|
-
@status = 1
|
45
43
|
@stdout = "v0.8.11\n"
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@ohai.languages.should_not have_key(:nodejs)
|
44
|
+
@plugin.stub(:shell_out).with("node -v").and_return(mock_shell_out(1, @stdout, ""))
|
45
|
+
@plugin.run
|
46
|
+
@plugin.languages.should_not have_key(:nodejs)
|
50
47
|
end
|
48
|
+
|
51
49
|
end
|
@@ -22,12 +22,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
22
22
|
|
23
23
|
describe Ohai::System, "plugin ohai" do
|
24
24
|
before(:each) do
|
25
|
-
@
|
26
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
25
|
+
@plugin = get_plugin("ohai")
|
27
26
|
end
|
28
27
|
|
29
28
|
it "should set [:chef_packages][:ohai][:version] to the current version" do
|
30
|
-
@
|
31
|
-
@
|
29
|
+
@plugin.run
|
30
|
+
@plugin[:chef_packages][:ohai][:version].should == Ohai::VERSION
|
32
31
|
end
|
33
32
|
end
|
@@ -21,26 +21,25 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "plugin ohai_time" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
24
|
+
@plugin = get_plugin("ohai_time")
|
26
25
|
end
|
27
26
|
|
28
27
|
it "should get the current time" do
|
29
28
|
Time.should_receive(:now)
|
30
|
-
@
|
29
|
+
@plugin.run
|
31
30
|
end
|
32
31
|
|
33
32
|
it "should turn the time into a floating point number" do
|
34
33
|
time = Time.now
|
35
34
|
time.should_receive(:to_f)
|
36
|
-
Time.stub
|
37
|
-
@
|
35
|
+
Time.stub(:now).and_return(time)
|
36
|
+
@plugin.run
|
38
37
|
end
|
39
38
|
|
40
39
|
it "should set ohai_time to the current time" do
|
41
40
|
time = Time.now
|
42
|
-
Time.stub
|
43
|
-
@
|
44
|
-
@
|
41
|
+
Time.stub(:now).and_return(time)
|
42
|
+
@plugin.run
|
43
|
+
@plugin[:ohai_time].should == time.to_f
|
45
44
|
end
|
46
|
-
end
|
45
|
+
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,14 +21,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "OpenBSD 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(:openbsd)
|
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
|
+
end
|
30
|
+
|
31
|
+
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
32
|
+
|
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"
|
29
43
|
end
|
30
|
-
|
31
|
-
it_should_check_from("openbsd::hostname", "hostname", "hostname -s", "katie")
|
32
|
-
|
33
|
-
it_should_check_from("openbsd::hostname", "fqdn", "hostname", "katie.bethell")
|
34
44
|
end
|
@@ -21,17 +21,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "OpenBSD 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(:openbsd)
|
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
|
|
37
37
|
end
|
@@ -21,20 +21,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "OpenBSD plugin platform" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@ohai[:os] = "openbsd"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should set platform to lowercased lsb[:id]" do
|
32
|
-
@ohai._require_plugin("openbsd::platform")
|
33
|
-
@ohai[:platform].should == "openbsd"
|
24
|
+
@plugin = get_plugin("openbsd/platform")
|
25
|
+
@plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
|
26
|
+
@plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
27
|
+
@plugin.stub(:collect_os).and_return(:openbsd)
|
34
28
|
end
|
35
29
|
|
36
30
|
it "should set platform_version to lsb[:release]" do
|
37
|
-
@
|
38
|
-
@
|
31
|
+
@plugin.run
|
32
|
+
@plugin[:platform_version].should == "4.5"
|
39
33
|
end
|
40
34
|
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (dan@getchef.com)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDIT"Net::HTTP Response"NS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
require 'ohai/plugins/openstack'
|
21
|
+
|
22
|
+
describe "OpenStack Plugin" do
|
23
|
+
|
24
|
+
let(:openstack_hint) { false }
|
25
|
+
let(:hp_hint) { false }
|
26
|
+
|
27
|
+
let(:ohai_system) { Ohai::System.new }
|
28
|
+
let(:ohai_data) { ohai_system.data }
|
29
|
+
|
30
|
+
let(:openstack_plugin) do
|
31
|
+
plugin = get_plugin("openstack", ohai_system)
|
32
|
+
plugin.stub(:hint?).with("openstack").and_return(openstack_hint)
|
33
|
+
plugin.stub(:hint?).with("hp").and_return(hp_hint)
|
34
|
+
plugin
|
35
|
+
end
|
36
|
+
|
37
|
+
before do
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when there is no relevant hint" do
|
41
|
+
|
42
|
+
it "does not set any openstack data" do
|
43
|
+
openstack_plugin.run
|
44
|
+
expect(ohai_data).to_not have_key("openstack")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when there is an `openstack` hint" do
|
50
|
+
let(:openstack_hint) { true }
|
51
|
+
|
52
|
+
context "and the metadata service is not available" do
|
53
|
+
|
54
|
+
before do
|
55
|
+
openstack_plugin.should_receive(:can_metadata_connect?).
|
56
|
+
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
|
57
|
+
and_return(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "does not set any openstack data" do
|
61
|
+
openstack_plugin.run
|
62
|
+
expect(ohai_data).to_not have_key("openstack")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "and the metadata service is available" do
|
67
|
+
|
68
|
+
let(:metadata_version) { "2009-04-04" }
|
69
|
+
|
70
|
+
let(:metadata_root) do
|
71
|
+
<<EOM
|
72
|
+
reservation-id
|
73
|
+
public-keys/
|
74
|
+
security-groups
|
75
|
+
public-ipv4
|
76
|
+
ami-manifest-path
|
77
|
+
instance-type
|
78
|
+
instance-id
|
79
|
+
local-ipv4
|
80
|
+
ari-id
|
81
|
+
local-hostname
|
82
|
+
placement/
|
83
|
+
ami-launch-index
|
84
|
+
public-hostname
|
85
|
+
hostname
|
86
|
+
ami-id
|
87
|
+
instance-action
|
88
|
+
aki-id
|
89
|
+
block-device-mapping/
|
90
|
+
EOM
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:metadata_values) do
|
94
|
+
{
|
95
|
+
"reservation-id" => "r-4tjvl99h",
|
96
|
+
"public-keys/" => "0=dan-default",
|
97
|
+
"public-keys/0/" => "openssh-key",
|
98
|
+
"public-keys/0/openssh-key" => "SSH KEY DATA",
|
99
|
+
"security-groups" => "default",
|
100
|
+
"public-ipv4" => "",
|
101
|
+
"ami-manifest-path" => "FIXME",
|
102
|
+
"instance-type" => "opc-tester",
|
103
|
+
"instance-id" => "i-0000162a",
|
104
|
+
"local-ipv4" => "172.31.7.23",
|
105
|
+
"ari-id" => "ari-00000037",
|
106
|
+
"local-hostname" => "ohai-7-system-test.opscode.us",
|
107
|
+
"placement/" => "availability-zone",
|
108
|
+
"placement/availability-zone" => "nova",
|
109
|
+
"ami-launch-index" => "0",
|
110
|
+
"public-hostname" => "ohai-7-system-test.opscode.us",
|
111
|
+
"hostname" => "ohai-7-system-test.opscode.us",
|
112
|
+
"ami-id" => "ami-00000035",
|
113
|
+
"instance-action" => "none",
|
114
|
+
"aki-id" => "aki-00000036",
|
115
|
+
"block-device-mapping/" => "ami\nroot",
|
116
|
+
"block-device-mapping/ami" => "vda",
|
117
|
+
"block-device-mapping/root" => "/dev/vda"
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
let(:http_client) { double("Net::HTTP", :read_timeout= => nil) }
|
122
|
+
|
123
|
+
def expect_get(url, response_body)
|
124
|
+
http_client.should_receive(:get).
|
125
|
+
with(url).
|
126
|
+
and_return(double("HTTP Response", :code => "200", :body => response_body))
|
127
|
+
end
|
128
|
+
|
129
|
+
before do
|
130
|
+
openstack_plugin.should_receive(:can_metadata_connect?).
|
131
|
+
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
|
132
|
+
and_return(true)
|
133
|
+
|
134
|
+
Net::HTTP.stub(:start).
|
135
|
+
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR).
|
136
|
+
and_return(http_client)
|
137
|
+
|
138
|
+
openstack_plugin.stub(:best_api_version).and_return(metadata_version)
|
139
|
+
|
140
|
+
expect_get("/#{metadata_version}/meta-data/", metadata_root)
|
141
|
+
|
142
|
+
metadata_values.each do |md_id, md_value|
|
143
|
+
expect_get("/#{metadata_version}/meta-data/#{md_id}", md_value)
|
144
|
+
end
|
145
|
+
|
146
|
+
openstack_plugin.run
|
147
|
+
end
|
148
|
+
|
149
|
+
it "reads the reservation_id from the metadata service" do
|
150
|
+
expect(ohai_data['openstack']['reservation_id']).to eq("r-4tjvl99h")
|
151
|
+
end
|
152
|
+
it "reads the public_keys_0_openssh_key from the metadata service" do
|
153
|
+
expect(ohai_data['openstack']['public_keys_0_openssh_key']).to eq("SSH KEY DATA")
|
154
|
+
end
|
155
|
+
it "reads the security_groups from the metadata service" do
|
156
|
+
expect(ohai_data['openstack']['security_groups']).to eq(["default"])
|
157
|
+
end
|
158
|
+
it "reads the public_ipv4 from the metadata service" do
|
159
|
+
expect(ohai_data['openstack']['public_ipv4']).to eq("")
|
160
|
+
end
|
161
|
+
it "reads the ami_manifest_path from the metadata service" do
|
162
|
+
expect(ohai_data['openstack']['ami_manifest_path']).to eq("FIXME")
|
163
|
+
end
|
164
|
+
it "reads the instance_type from the metadata service" do
|
165
|
+
expect(ohai_data['openstack']['instance_type']).to eq("opc-tester")
|
166
|
+
end
|
167
|
+
it "reads the instance_id from the metadata service" do
|
168
|
+
expect(ohai_data['openstack']['instance_id']).to eq("i-0000162a")
|
169
|
+
end
|
170
|
+
it "reads the local_ipv4 from the metadata service" do
|
171
|
+
expect(ohai_data['openstack']['local_ipv4']).to eq("172.31.7.23")
|
172
|
+
end
|
173
|
+
it "reads the ari_id from the metadata service" do
|
174
|
+
expect(ohai_data['openstack']['ari_id']).to eq("ari-00000037")
|
175
|
+
end
|
176
|
+
it "reads the local_hostname from the metadata service" do
|
177
|
+
expect(ohai_data['openstack']['local_hostname']).to eq("ohai-7-system-test.opscode.us")
|
178
|
+
end
|
179
|
+
it "reads the placement_availability_zone from the metadata service" do
|
180
|
+
expect(ohai_data['openstack']['placement_availability_zone']).to eq("nova")
|
181
|
+
end
|
182
|
+
it "reads the ami_launch_index from the metadata service" do
|
183
|
+
expect(ohai_data['openstack']['ami_launch_index']).to eq("0")
|
184
|
+
end
|
185
|
+
it "reads the public_hostname from the metadata service" do
|
186
|
+
expect(ohai_data['openstack']['public_hostname']).to eq("ohai-7-system-test.opscode.us")
|
187
|
+
end
|
188
|
+
it "reads the hostname from the metadata service" do
|
189
|
+
expect(ohai_data['openstack']['hostname']).to eq("ohai-7-system-test.opscode.us")
|
190
|
+
end
|
191
|
+
it "reads the ami_id from the metadata service" do
|
192
|
+
expect(ohai_data['openstack']['ami_id']).to eq("ami-00000035")
|
193
|
+
end
|
194
|
+
it "reads the instance_action from the metadata service" do
|
195
|
+
expect(ohai_data['openstack']['instance_action']).to eq("none")
|
196
|
+
end
|
197
|
+
it "reads the aki_id from the metadata service" do
|
198
|
+
expect(ohai_data['openstack']['aki_id']).to eq("aki-00000036")
|
199
|
+
end
|
200
|
+
it "reads the block_device_mapping_ami from the metadata service" do
|
201
|
+
expect(ohai_data['openstack']['block_device_mapping_ami']).to eq("vda")
|
202
|
+
end
|
203
|
+
it "reads the block_device_mapping_root from the metadata service" do
|
204
|
+
expect(ohai_data['openstack']['block_device_mapping_root']).to eq("/dev/vda")
|
205
|
+
end
|
206
|
+
it "reads the provider from the metadata service" do
|
207
|
+
expect(ohai_data['openstack']['provider']).to eq("openstack")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
@@ -23,12 +23,9 @@ ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os']
|
|
23
23
|
|
24
24
|
describe Ohai::System, "plugin os" do
|
25
25
|
before(:each) do
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@ohai[:languages][:ruby] = Mash.new
|
30
|
-
@ohai[:kernel] = Mash.new
|
31
|
-
@ohai[:kernel][:release] = "kings of leon"
|
26
|
+
@plugin = get_plugin("os")
|
27
|
+
@plugin[:kernel] = Mash.new
|
28
|
+
@plugin[:kernel][:release] = "kings of leon"
|
32
29
|
end
|
33
30
|
|
34
31
|
after do
|
@@ -36,8 +33,8 @@ describe Ohai::System, "plugin os" do
|
|
36
33
|
end
|
37
34
|
|
38
35
|
it "should set os_version to kernel_release" do
|
39
|
-
@
|
40
|
-
@
|
36
|
+
@plugin.run
|
37
|
+
@plugin[:os_version].should == @plugin[:kernel][:release]
|
41
38
|
end
|
42
39
|
|
43
40
|
describe "on linux" do
|
@@ -46,8 +43,8 @@ describe Ohai::System, "plugin os" do
|
|
46
43
|
end
|
47
44
|
|
48
45
|
it "should set the os to linux" do
|
49
|
-
@
|
50
|
-
@
|
46
|
+
@plugin.run
|
47
|
+
@plugin[:os].should == "linux"
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
@@ -57,8 +54,8 @@ describe Ohai::System, "plugin os" do
|
|
57
54
|
end
|
58
55
|
|
59
56
|
it "should set the os to darwin" do
|
60
|
-
@
|
61
|
-
@
|
57
|
+
@plugin.run
|
58
|
+
@plugin[:os].should == "darwin"
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
@@ -68,8 +65,8 @@ describe Ohai::System, "plugin os" do
|
|
68
65
|
end
|
69
66
|
|
70
67
|
it "sets the os to solaris2" do
|
71
|
-
@
|
72
|
-
@
|
68
|
+
@plugin.run
|
69
|
+
@plugin[:os].should == "solaris2"
|
73
70
|
end
|
74
71
|
end
|
75
72
|
|
@@ -79,8 +76,8 @@ describe Ohai::System, "plugin os" do
|
|
79
76
|
end
|
80
77
|
|
81
78
|
it "sets the os to the ruby 'host_os'" do
|
82
|
-
@
|
83
|
-
@
|
79
|
+
@plugin.run
|
80
|
+
@plugin[:os].should == "tron"
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|