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
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
2
2
|
|
3
3
|
describe Ohai::System, "plugin etc" do
|
4
4
|
before(:each) do
|
5
|
-
@
|
6
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
5
|
+
@plugin = get_plugin("passwd")
|
7
6
|
end
|
8
7
|
|
9
8
|
PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
|
@@ -12,31 +11,31 @@ describe Ohai::System, "plugin etc" do
|
|
12
11
|
it "should include a list of all users" do
|
13
12
|
Etc.should_receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
|
14
13
|
and_yield(PasswdEntry.new('www', 800, 800, '/var/www', '/bin/false', 'Serving the web since 1970'))
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
14
|
+
@plugin.run
|
15
|
+
@plugin[:etc][:passwd]['root'].should == Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')
|
16
|
+
@plugin[:etc][:passwd]['www'].should == Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www')
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should set the current user" do
|
21
20
|
Etc.should_receive(:getlogin).and_return('chef')
|
22
|
-
@
|
23
|
-
@
|
21
|
+
@plugin.run
|
22
|
+
@plugin[:current_user].should == 'chef'
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should set the available groups" do
|
27
26
|
Etc.should_receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy']))
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
27
|
+
@plugin.run
|
28
|
+
@plugin[:etc][:group]['admin'].should == Mash.new(:gid => 100, :members => ['root', 'chef'])
|
29
|
+
@plugin[:etc][:group]['www'].should == Mash.new(:gid => 800, :members => ['www', 'deploy'])
|
31
30
|
end
|
32
31
|
|
33
32
|
if "".respond_to?(:force_encoding)
|
34
33
|
it "sets the encoding of strings to the default external encoding" do
|
35
34
|
fields = ["root", 1, 1, '/root', '/bin/zsh', 'BOFH']
|
36
35
|
fields.each {|f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
|
37
|
-
Etc.stub
|
38
|
-
@
|
39
|
-
root = @
|
36
|
+
Etc.stub(:passwd).and_yield(PasswdEntry.new(*fields))
|
37
|
+
@plugin.run
|
38
|
+
root = @plugin[:etc][:passwd]['root']
|
40
39
|
root['gecos'].encoding.should == Encoding.default_external
|
41
40
|
end
|
42
41
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Joshua Timberman(<joshua@opscode.com>)
|
3
|
-
#
|
3
|
+
# Author:: Theodore Nordsieck (<theo@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2009-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");
|
@@ -20,63 +21,38 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
20
21
|
|
21
22
|
describe Ohai::System, "plugin perl" do
|
22
23
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@stderr = StringIO.new
|
28
|
-
@stdout = StringIO.new(<<-OUT)
|
29
|
-
version='5.8.8';
|
30
|
-
archname='darwin-thread-multi-2level';
|
31
|
-
OUT
|
32
|
-
@stdin = StringIO.new
|
33
|
-
@status = 0
|
34
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([
|
35
|
-
@status,
|
36
|
-
@stdout,
|
37
|
-
@stderr
|
38
|
-
])
|
24
|
+
@plugin = get_plugin("perl")
|
25
|
+
@plugin[:languages] = Mash.new
|
26
|
+
@stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
|
27
|
+
@plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
39
28
|
end
|
40
29
|
|
41
30
|
it "should run perl -V:version -V:archname" do
|
42
|
-
@
|
43
|
-
@
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should iterate over each line of perl command's stdout" do
|
47
|
-
@stdout.should_receive(:each_line).and_return(true)
|
48
|
-
@ohai._require_plugin("perl")
|
31
|
+
@plugin.should_receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
32
|
+
@plugin.run
|
49
33
|
end
|
50
34
|
|
51
35
|
it "should set languages[:perl][:version]" do
|
52
|
-
@
|
53
|
-
@
|
36
|
+
@plugin.run
|
37
|
+
@plugin.languages[:perl][:version].should eql("5.8.8")
|
54
38
|
end
|
55
39
|
|
56
40
|
it "should set languages[:perl][:archname]" do
|
57
|
-
@
|
58
|
-
@
|
41
|
+
@plugin.run
|
42
|
+
@plugin.languages[:perl][:archname].should eql("darwin-thread-multi-2level")
|
59
43
|
end
|
60
44
|
|
61
45
|
it "should set languages[:perl] if perl command succeeds" do
|
62
|
-
@
|
63
|
-
@
|
64
|
-
|
65
|
-
@stdout,
|
66
|
-
@stderr
|
67
|
-
])
|
68
|
-
@ohai._require_plugin("perl")
|
69
|
-
@ohai.languages.should have_key(:perl)
|
46
|
+
@plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
47
|
+
@plugin.run
|
48
|
+
@plugin.languages.should have_key(:perl)
|
70
49
|
end
|
71
50
|
|
72
51
|
it "should not set languages[:perl] if perl command fails" do
|
73
|
-
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
@stderr
|
78
|
-
])
|
79
|
-
@ohai._require_plugin("perl")
|
80
|
-
@ohai.languages.should_not have_key(:perl)
|
52
|
+
@status = 1
|
53
|
+
@plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(1, @stdout, ""))
|
54
|
+
@plugin.run
|
55
|
+
@plugin.languages.should_not have_key(:perl)
|
81
56
|
end
|
57
|
+
|
82
58
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
|
+
# Author:: Theodore Nordsieck (<theo@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2009 VMware, Inc.
|
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");
|
@@ -16,37 +18,40 @@
|
|
16
18
|
# limitations under the License.
|
17
19
|
#
|
18
20
|
|
21
|
+
require 'json'
|
19
22
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
|
20
23
|
|
21
24
|
describe Ohai::System, "plugin php" do
|
22
25
|
|
23
26
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
27
|
-
@status = 0
|
27
|
+
@plugin = get_plugin("php")
|
28
|
+
@plugin[:languages] = Mash.new
|
28
29
|
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
|
29
|
-
@
|
30
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"php -v"}).and_return([@status, @stdout, @stderr])
|
30
|
+
@plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should get the php version from running php -V" do
|
34
|
-
@
|
35
|
-
@
|
34
|
+
@plugin.should_receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
35
|
+
@plugin.run
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should set languages[:php][:version]" do
|
39
|
-
@
|
40
|
-
@
|
39
|
+
@plugin.run
|
40
|
+
@plugin.languages[:php][:version].should eql("5.1.6")
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should not set the languages[:php] tree up if php command fails" do
|
44
|
-
@status = 1
|
45
44
|
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
|
45
|
+
@plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
|
46
|
+
@plugin.run
|
47
|
+
@plugin.languages.should_not have_key(:php)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should parse builddate even if it's suhosin patched" do
|
51
|
+
@stdout = "PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30) \nCopyright (c) 1997-2013 The PHP Group\nZend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies"
|
52
|
+
@plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
53
|
+
@plugin.run
|
54
|
+
@plugin.languages[:php][:builddate].should eql("Aug 30 2013 04:30:30")
|
50
55
|
end
|
51
56
|
|
52
57
|
end
|
@@ -21,51 +21,46 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "plugin platform" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
24
|
+
@plugin = get_plugin("platform")
|
25
|
+
@plugin.stub(:collect_os).and_return(:default)
|
26
|
+
@plugin[:os] = 'monkey'
|
27
|
+
@plugin[:os_version] = 'poop'
|
28
28
|
end
|
29
|
-
|
30
|
-
it "should require the os platform plugin" do
|
31
|
-
@ohai.should_receive(:require_plugin).with("monkey::platform")
|
32
|
-
@ohai._require_plugin("platform")
|
33
|
-
end
|
34
|
-
|
29
|
+
|
35
30
|
it "should set the platform and platform family to the os if it was not set earlier" do
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
31
|
+
@plugin.run
|
32
|
+
@plugin[:platform].should eql("monkey")
|
33
|
+
@plugin[:platform_family].should eql("monkey")
|
39
34
|
end
|
40
35
|
|
41
36
|
it "should not set the platform to the os if it was set earlier" do
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
37
|
+
@plugin[:platform] = 'lars'
|
38
|
+
@plugin.run
|
39
|
+
@plugin[:platform].should eql("lars")
|
45
40
|
end
|
46
41
|
|
47
42
|
it "should set the platform_family to the platform if platform was set earlier but not platform_family" do
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
43
|
+
@plugin[:platform] = 'lars'
|
44
|
+
@plugin[:platform_family] = 'jack'
|
45
|
+
@plugin.run
|
46
|
+
@plugin[:platform_family].should eql("jack")
|
52
47
|
end
|
53
48
|
|
54
49
|
it "should not set the platform_family if the platform_family was set earlier." do
|
55
|
-
@
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@
|
50
|
+
@plugin[:platform] = 'lars'
|
51
|
+
@plugin.run
|
52
|
+
@plugin[:platform].should eql("lars")
|
53
|
+
@plugin[:platform_family].should eql("lars")
|
59
54
|
end
|
60
55
|
|
61
56
|
it "should set the platform_version to the os_version if it was not set earlier" do
|
62
|
-
@
|
63
|
-
@
|
57
|
+
@plugin.run
|
58
|
+
@plugin[:os_version].should eql("poop")
|
64
59
|
end
|
65
60
|
|
66
61
|
it "should not set the platform to the os if it was set earlier" do
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
62
|
+
@plugin[:platform_version] = 'ulrich'
|
63
|
+
@plugin.run
|
64
|
+
@plugin[:platform_version].should eql("ulrich")
|
70
65
|
end
|
71
66
|
end
|
@@ -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");
|
@@ -22,32 +23,27 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
22
23
|
describe Ohai::System, "plugin python" do
|
23
24
|
|
24
25
|
before(:each) do
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
28
|
-
@status = 0
|
26
|
+
@plugin = get_plugin("python")
|
27
|
+
@plugin[:languages] = Mash.new
|
29
28
|
@stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n"
|
30
|
-
@
|
31
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr])
|
29
|
+
@plugin.stub(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, ""))
|
32
30
|
end
|
33
31
|
|
34
32
|
it "should get the python version from printing sys.version and sys.platform" do
|
35
|
-
@
|
36
|
-
@
|
33
|
+
@plugin.should_receive(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, ""))
|
34
|
+
@plugin.run
|
37
35
|
end
|
38
36
|
|
39
37
|
it "should set languages[:python][:version]" do
|
40
|
-
@
|
41
|
-
@
|
38
|
+
@plugin.run
|
39
|
+
@plugin.languages[:python][:version].should eql("2.5.2")
|
42
40
|
end
|
43
41
|
|
44
42
|
it "should not set the languages[:python] tree up if python command fails" do
|
45
|
-
@status = 1
|
46
43
|
@stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n"
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@ohai.languages.should_not have_key(:python)
|
44
|
+
@plugin.stub(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(1, @stdout, ""))
|
45
|
+
@plugin.run
|
46
|
+
@plugin.languages.should_not have_key(:python)
|
51
47
|
end
|
52
|
-
|
48
|
+
|
53
49
|
end
|
@@ -19,9 +19,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
19
19
|
|
20
20
|
describe Ohai::System, "plugin rackspace" do
|
21
21
|
before(:each) do
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
22
|
+
@plugin = get_plugin("rackspace")
|
23
|
+
@plugin[:hostname] = "katie"
|
24
|
+
@plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> {
|
25
25
|
"1.2.3.4"=> {
|
26
26
|
"broadcast"=> "67.23.20.255",
|
27
27
|
"netmask"=> "255.255.255.0",
|
@@ -40,64 +40,70 @@ describe Ohai::System, "plugin rackspace" do
|
|
40
40
|
"40:40:95:47:6E:ED"=> {
|
41
41
|
"family"=> "lladdr"
|
42
42
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
"
|
57
|
-
|
58
|
-
|
43
|
+
}}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
@plugin[:network][:interfaces][:eth1] = {:addresses => {
|
48
|
+
"fe80::4240:f5ff:feab:2836" => {
|
49
|
+
"scope"=> "Link",
|
50
|
+
"prefixlen"=> "64",
|
51
|
+
"family"=> "inet6"
|
52
|
+
},
|
53
|
+
"5.6.7.8"=> {
|
54
|
+
"broadcast"=> "10.176.191.255",
|
55
|
+
"netmask"=> "255.255.224.0",
|
56
|
+
"family"=> "inet"
|
57
|
+
},
|
58
|
+
"40:40:F5:AB:28:36" => {
|
59
|
+
"family"=> "lladdr"
|
60
|
+
}
|
59
61
|
}}
|
60
62
|
|
61
63
|
# In olden days we could detect rackspace by a -rscloud suffix on the kernel
|
62
64
|
# This is here to make #has_rackspace_kernel? fail until we remove that check
|
63
|
-
@
|
65
|
+
@plugin[:kernel] = { :release => "1.2.13-not-rackspace" }
|
64
66
|
|
65
67
|
# We need a generic stub here for the later stubs with arguments to work
|
66
68
|
# Because, magic.
|
67
|
-
@
|
69
|
+
@plugin.stub(:shell_out).and_return(mock_shell_out(1, "", ""))
|
68
70
|
end
|
69
71
|
|
70
72
|
shared_examples_for "!rackspace" do
|
71
73
|
it "should NOT create rackspace" do
|
72
|
-
@
|
73
|
-
@
|
74
|
+
@plugin.run
|
75
|
+
@plugin[:rackspace].should be_nil
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
79
|
shared_examples_for "rackspace" do
|
78
80
|
|
79
81
|
it "should create rackspace" do
|
80
|
-
@
|
81
|
-
@
|
82
|
+
@plugin.run
|
83
|
+
@plugin[:rackspace].should_not be_nil
|
82
84
|
end
|
83
85
|
|
84
86
|
it "should have all required attributes" do
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@
|
88
|
-
@
|
89
|
-
@
|
90
|
-
@
|
91
|
-
@
|
87
|
+
@plugin.run
|
88
|
+
@plugin[:rackspace][:public_ip].should_not be_nil
|
89
|
+
@plugin[:rackspace][:private_ip].should_not be_nil
|
90
|
+
@plugin[:rackspace][:public_ipv4].should_not be_nil
|
91
|
+
@plugin[:rackspace][:local_ipv4].should_not be_nil
|
92
|
+
@plugin[:rackspace][:public_ipv6].should_not be_nil
|
93
|
+
@plugin[:rackspace][:local_ipv6].should be_nil
|
94
|
+
@plugin[:rackspace][:local_hostname].should_not be_nil
|
95
|
+
@plugin[:rackspace][:public_hostname].should_not be_nil
|
92
96
|
end
|
93
97
|
|
94
98
|
it "should have correct values for all attributes" do
|
95
|
-
@
|
96
|
-
@
|
97
|
-
@
|
98
|
-
@
|
99
|
-
@
|
100
|
-
@
|
99
|
+
@plugin.run
|
100
|
+
@plugin[:rackspace][:public_ip].should == "1.2.3.4"
|
101
|
+
@plugin[:rackspace][:private_ip].should == "5.6.7.8"
|
102
|
+
@plugin[:rackspace][:public_ipv4].should == "1.2.3.4"
|
103
|
+
@plugin[:rackspace][:local_ipv4].should == "5.6.7.8"
|
104
|
+
@plugin[:rackspace][:public_ipv6].should == "2a00:1a48:7805:111:e875:efaf:ff08:75"
|
105
|
+
@plugin[:rackspace][:local_hostname].should == 'katie'
|
106
|
+
@plugin[:rackspace][:public_hostname].should == "1-2-3-4.static.cloud-ips.com"
|
101
107
|
end
|
102
108
|
|
103
109
|
it "should capture region information" do
|
@@ -108,9 +114,9 @@ server_id = "21301000"
|
|
108
114
|
created_at = "2012-12-06T22:08:16Z"
|
109
115
|
region = "dfw"
|
110
116
|
OUT
|
111
|
-
@
|
112
|
-
@
|
113
|
-
@
|
117
|
+
@plugin.stub(:shell_out).with("xenstore-ls vm-data/provider_data").and_return(mock_shell_out(0, provider_data, ""))
|
118
|
+
@plugin.run
|
119
|
+
@plugin[:rackspace][:region].should == "dfw"
|
114
120
|
end
|
115
121
|
end
|
116
122
|
|
@@ -118,10 +124,38 @@ OUT
|
|
118
124
|
it_should_behave_like "rackspace"
|
119
125
|
|
120
126
|
before(:each) do
|
121
|
-
File.stub
|
122
|
-
File.stub
|
123
|
-
File.stub
|
124
|
-
File.stub
|
127
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
|
128
|
+
File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
|
129
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
130
|
+
File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'with no public interfaces (empty eth0)' do
|
134
|
+
before do
|
135
|
+
# unset public (eth0) addresses
|
136
|
+
@plugin[:network][:interfaces][:eth0]['addresses'] = {}
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should have all required attributes" do
|
140
|
+
@plugin.run
|
141
|
+
# expliticly nil
|
142
|
+
@plugin[:rackspace][:public_ip].should be_nil
|
143
|
+
@plugin[:rackspace][:public_ipv4].should be_nil
|
144
|
+
@plugin[:rackspace][:public_ipv6].should be_nil
|
145
|
+
@plugin[:rackspace][:public_hostname].should be_nil
|
146
|
+
# per normal
|
147
|
+
@plugin[:rackspace][:private_ip].should_not be_nil
|
148
|
+
@plugin[:rackspace][:local_ipv4].should_not be_nil
|
149
|
+
@plugin[:rackspace][:local_ipv6].should be_nil
|
150
|
+
@plugin[:rackspace][:local_hostname].should_not be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should have correct values for all attributes" do
|
154
|
+
@plugin.run
|
155
|
+
@plugin[:rackspace][:private_ip].should == "5.6.7.8"
|
156
|
+
@plugin[:rackspace][:local_ipv4].should == "5.6.7.8"
|
157
|
+
@plugin[:rackspace][:local_hostname].should == 'katie'
|
158
|
+
end
|
125
159
|
end
|
126
160
|
end
|
127
161
|
|
@@ -129,8 +163,8 @@ OUT
|
|
129
163
|
it_should_behave_like "!rackspace"
|
130
164
|
|
131
165
|
before(:each) do
|
132
|
-
File.stub
|
133
|
-
File.stub
|
166
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
|
167
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
|
134
168
|
end
|
135
169
|
end
|
136
170
|
|
@@ -138,10 +172,13 @@ OUT
|
|
138
172
|
it_should_behave_like "!rackspace"
|
139
173
|
|
140
174
|
before(:each) do
|
141
|
-
File.stub
|
142
|
-
File.stub
|
143
|
-
File.stub
|
144
|
-
File.stub
|
175
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
|
176
|
+
File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
|
177
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
|
178
|
+
File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
|
179
|
+
|
180
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
|
181
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
|
145
182
|
end
|
146
183
|
end
|
147
184
|
|
@@ -149,10 +186,8 @@ OUT
|
|
149
186
|
it_should_behave_like "rackspace"
|
150
187
|
|
151
188
|
before(:each) do
|
152
|
-
stderr = StringIO.new
|
153
189
|
stdout = "Rackspace\n"
|
154
|
-
|
155
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ])
|
190
|
+
@plugin.stub(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
156
191
|
end
|
157
192
|
end
|
158
193
|
|
@@ -160,10 +195,8 @@ OUT
|
|
160
195
|
it_should_behave_like "!rackspace"
|
161
196
|
|
162
197
|
before(:each) do
|
163
|
-
stderr = StringIO.new
|
164
198
|
stdout = "cumulonimbus\n"
|
165
|
-
|
166
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ])
|
199
|
+
@plugin.stub(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
167
200
|
end
|
168
201
|
end
|
169
202
|
end
|