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
@@ -18,11 +18,9 @@
|
|
18
18
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
20
20
|
|
21
|
-
ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os']
|
22
|
-
|
23
21
|
describe Ohai::System, 'root_group' do
|
24
22
|
before(:each) do
|
25
|
-
@
|
23
|
+
@plugin = get_plugin("root_group")
|
26
24
|
end
|
27
25
|
|
28
26
|
describe 'unix platform', :unix_only do
|
@@ -31,49 +29,49 @@ describe Ohai::System, 'root_group' do
|
|
31
29
|
# apparently didn't apply to this api. we're just trying to fake
|
32
30
|
# Etc.getgrgid(Etc.getpwnam('root').gid).name
|
33
31
|
@pwnam = Object.new
|
34
|
-
@pwnam.stub
|
35
|
-
Etc.stub
|
32
|
+
@pwnam.stub(:gid).and_return(0)
|
33
|
+
Etc.stub(:getpwnam).with('root').and_return(@pwnam)
|
36
34
|
@grgid = Object.new
|
37
|
-
Etc.stub
|
35
|
+
Etc.stub(:getgrgid).and_return(@grgid)
|
38
36
|
end
|
39
37
|
|
40
38
|
describe 'with wheel group' do
|
41
39
|
before(:each) do
|
42
|
-
@grgid.stub
|
40
|
+
@grgid.stub(:name).and_return('wheel')
|
43
41
|
end
|
44
42
|
it 'should have a root_group of wheel' do
|
45
|
-
@
|
46
|
-
@
|
43
|
+
@plugin.run
|
44
|
+
@plugin[:root_group].should == 'wheel'
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
48
|
describe 'with root group' do
|
51
49
|
before(:each) do
|
52
|
-
@grgid.stub
|
50
|
+
@grgid.stub(:name).and_return('root')
|
53
51
|
end
|
54
52
|
it 'should have a root_group of root' do
|
55
|
-
@
|
56
|
-
@
|
53
|
+
@plugin.run
|
54
|
+
@plugin[:root_group].should == 'root'
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
describe 'platform hpux with sys group' do
|
61
59
|
before(:each) do
|
62
|
-
@pwnam.stub
|
63
|
-
@grgid.stub
|
60
|
+
@pwnam.stub(:gid).and_return(3)
|
61
|
+
@grgid.stub(:name).and_return('sys')
|
64
62
|
end
|
65
63
|
it 'should have a root_group of sys' do
|
66
|
-
@
|
67
|
-
@
|
64
|
+
@plugin.run
|
65
|
+
@plugin[:root_group].should == 'sys'
|
68
66
|
end
|
69
67
|
end
|
70
68
|
describe 'platform aix with system group' do
|
71
69
|
before(:each) do
|
72
|
-
@grgid.stub
|
70
|
+
@grgid.stub(:name).and_return('system')
|
73
71
|
end
|
74
72
|
it 'should have a root_group of system' do
|
75
|
-
@
|
76
|
-
@
|
73
|
+
@plugin.run
|
74
|
+
@plugin[:root_group].should == 'system'
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -19,17 +19,16 @@
|
|
19
19
|
|
20
20
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
21
21
|
|
22
|
-
ruby_bin = File.join(::
|
22
|
+
ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_install_name'])
|
23
23
|
|
24
24
|
describe Ohai::System, "plugin ruby" do
|
25
25
|
|
26
26
|
before(:all) do
|
27
|
-
@
|
28
|
-
@
|
27
|
+
@plugin = get_plugin("ruby")
|
28
|
+
@plugin[:languages] = Mash.new
|
29
|
+
@plugin.run
|
29
30
|
|
30
|
-
@
|
31
|
-
|
32
|
-
@ruby_ohai_data_pristine = @ohai[:languages][:ruby]
|
31
|
+
@ruby_ohai_data_pristine = @plugin[:languages][:ruby]
|
33
32
|
end
|
34
33
|
|
35
34
|
before(:each) do
|
@@ -40,16 +39,16 @@ describe Ohai::System, "plugin ruby" do
|
|
40
39
|
:platform => RUBY_PLATFORM,
|
41
40
|
:version => RUBY_VERSION,
|
42
41
|
:release_date => RUBY_RELEASE_DATE,
|
43
|
-
:target => ::
|
44
|
-
:target_cpu => ::
|
45
|
-
:target_vendor => ::
|
46
|
-
:target_os => ::
|
47
|
-
:host => ::
|
48
|
-
:host_cpu => ::
|
49
|
-
:host_os => ::
|
50
|
-
:host_vendor => ::
|
51
|
-
:gems_dir => %x{#{ruby_bin} #{::
|
52
|
-
:gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::
|
42
|
+
:target => ::RbConfig::CONFIG['target'],
|
43
|
+
:target_cpu => ::RbConfig::CONFIG['target_cpu'],
|
44
|
+
:target_vendor => ::RbConfig::CONFIG['target_vendor'],
|
45
|
+
:target_os => ::RbConfig::CONFIG['target_os'],
|
46
|
+
:host => ::RbConfig::CONFIG['host'],
|
47
|
+
:host_cpu => ::RbConfig::CONFIG['host_cpu'],
|
48
|
+
:host_os => ::RbConfig::CONFIG['host_os'],
|
49
|
+
:host_vendor => ::RbConfig::CONFIG['host_vendor'],
|
50
|
+
:gems_dir => %x{#{ruby_bin} #{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp!,
|
51
|
+
:gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::RbConfig::CONFIG['bindir']}/#{bin}"
|
53
52
|
}.find{|bin| ::File.exists? bin},
|
54
53
|
:ruby_bin => ruby_bin
|
55
54
|
}.each do |attribute, value|
|
@@ -33,6 +33,8 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
33
33
|
|
34
34
|
before(:each) do
|
35
35
|
@ohai = Ohai::System.new
|
36
|
+
@plugin = get_plugin("sigar/network", @ohai)
|
37
|
+
@plugin.stub(:collect_os).and_return(:sigar)
|
36
38
|
@sigar = double("Sigar")
|
37
39
|
@net_info_conf={
|
38
40
|
:default_gateway => "192.168.1.254",
|
@@ -111,35 +113,32 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
111
113
|
net_arp.stub(k).and_return(v)
|
112
114
|
end
|
113
115
|
@sigar.stub(:fqdn).and_return("localhost.localdomain")
|
114
|
-
@sigar.should_receive(:net_info).
|
116
|
+
@sigar.should_receive(:net_info).once.times.and_return(net_info)
|
115
117
|
@sigar.should_receive(:net_interface_list).once.and_return(["eth0"])
|
116
118
|
@sigar.should_receive(:net_interface_config).with("eth0").and_return(net_conf)
|
117
119
|
@sigar.should_receive(:net_interface_stat).with("eth0").and_return(net_stat)
|
118
120
|
@sigar.should_receive(:arp_list).once.and_return([net_arp])
|
119
121
|
|
120
|
-
# Since we
|
122
|
+
# Since we double net_route_list here, flags never gets called
|
121
123
|
@sigar.should_receive(:net_route_list).once.and_return([net_route])
|
122
|
-
Sigar.should_receive(:new).
|
123
|
-
|
124
|
-
@
|
125
|
-
Ohai::Log.should_receive(:warn).with(/unable to detect ip6address/).once
|
126
|
-
@ohai.require_plugin("network")
|
127
|
-
@ohai.require_plugin("sigar::network_route")
|
124
|
+
Sigar.should_receive(:new).once.and_return(@sigar)
|
125
|
+
|
126
|
+
@plugin.run
|
128
127
|
end
|
129
128
|
|
130
129
|
it "should set the routes" do
|
131
|
-
@
|
130
|
+
@plugin[:network][:interfaces][:eth0].should have_key(:route)
|
132
131
|
end
|
133
132
|
|
134
133
|
it "should set the route details" do
|
135
134
|
@net_route_conf.each_pair do |k,v|
|
136
|
-
# Work around the above
|
135
|
+
# Work around the above doubleing of net_route_list skipping the call to flags()
|
137
136
|
if k == :flags
|
138
137
|
v="U"
|
139
|
-
@
|
138
|
+
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k] = v
|
140
139
|
end
|
141
|
-
@
|
142
|
-
@
|
140
|
+
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"].should have_key(k)
|
141
|
+
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k].should eql(v)
|
143
142
|
end
|
144
143
|
end
|
145
144
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
18
|
+
|
19
|
+
describe Ohai::System, "Solaris2.X cpu plugin" do
|
20
|
+
before(:each) do
|
21
|
+
@plugin = get_plugin("solaris2/cpu")
|
22
|
+
@plugin.stub(:collect_os).and_return("solaris2")
|
23
|
+
@plugin.stub(:shell_out).with("psrinfo | wc -l").and_return(mock_shell_out(0, "32\n", ""))
|
24
|
+
@plugin.stub(:shell_out).with("psrinfo -p").and_return(mock_shell_out(0, "4\n", ""))
|
25
|
+
|
26
|
+
psrinfo_output = <<-END.strip
|
27
|
+
x86 (GenuineIntel 206D7 family 6 model 45 step 7 clock 2600 MHz)
|
28
|
+
Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz
|
29
|
+
x86 (CrazyTown 206D7 family 12 model 93 step 9 clock 2900 MHz)
|
30
|
+
Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz
|
31
|
+
END
|
32
|
+
@plugin.stub(:shell_out).with('psrinfo -v -p | grep Hz').and_return(mock_shell_out(0, psrinfo_output, ""))
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get the total virtual processor count" do
|
36
|
+
@plugin.run
|
37
|
+
@plugin['cpu']['total'].should eql(32)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should get the total processor count' do
|
41
|
+
@plugin.run
|
42
|
+
@plugin['cpu']['real'].should eql(4)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'per-cpu information' do
|
46
|
+
it "should include vendor_id for processors" do
|
47
|
+
@plugin.run
|
48
|
+
@plugin['cpu']['0']['vendor_id'].should eql('GenuineIntel')
|
49
|
+
@plugin['cpu']['1']['vendor_id'].should eql('CrazyTown')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should include family for processors" do
|
53
|
+
@plugin.run
|
54
|
+
@plugin['cpu']["0"]["family"].should eql("6")
|
55
|
+
@plugin['cpu']["1"]["family"].should eql("12")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should include model for processors" do
|
59
|
+
@plugin.run
|
60
|
+
@plugin['cpu']["0"]["model"].should eql("45")
|
61
|
+
@plugin['cpu']["1"]["model"].should eql("93")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should include stepping for processors" do
|
65
|
+
@plugin.run
|
66
|
+
@plugin['cpu']["0"]["stepping"].should eql("7")
|
67
|
+
@plugin['cpu']["1"]["stepping"].should eql("9")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should include model name for processors" do
|
71
|
+
@plugin.run
|
72
|
+
@plugin['cpu']["0"]["model_name"].should eql("Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz")
|
73
|
+
@plugin['cpu']["1"]["model_name"].should eql("Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should include mhz name for processors" do
|
77
|
+
@plugin.run
|
78
|
+
@plugin['cpu']["0"]["mhz"].should eql("2600")
|
79
|
+
@plugin['cpu']["1"]["mhz"].should eql("2900")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -20,19 +20,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
describe Ohai::System, "Solaris2.X hostname plugin" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
Socket.stub
|
23
|
+
@plugin = get_plugin("hostname")
|
24
|
+
@plugin.stub(:collect_os).and_return(:solaris2)
|
25
|
+
@plugin.stub(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
|
26
|
+
@plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
|
27
|
+
# Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh")
|
31
|
-
|
32
|
-
it "should get the fqdn value from
|
33
|
-
|
34
|
-
@
|
35
|
-
@ohai["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
|
31
|
+
|
32
|
+
it "should get the fqdn value from #resolve_fqdn" do
|
33
|
+
@plugin.run
|
34
|
+
@plugin["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
|
36
35
|
end
|
37
|
-
|
38
|
-
end
|
36
|
+
|
37
|
+
end
|
@@ -134,31 +134,27 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
134
134
|
TOOMUCH
|
135
135
|
|
136
136
|
before(:each) do
|
137
|
-
@
|
138
|
-
@
|
139
|
-
@
|
140
|
-
@
|
137
|
+
@plugin = get_plugin("kernel")
|
138
|
+
@plugin.stub(:collect_os).and_return(:solaris2)
|
139
|
+
@plugin.stub(:init_kernel).and_return({})
|
140
|
+
@plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
|
141
|
+
@plugin.stub(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
|
141
142
|
end
|
142
143
|
|
143
|
-
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", "SunOS")
|
144
|
+
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
|
144
145
|
|
145
146
|
it "gives excruciating detail about kernel modules" do
|
146
|
-
|
147
|
-
@modinfo_stdout = StringIO.new(MODINFO)
|
148
|
-
@ohai.stub!(:popen4).with("modinfo").and_yield(nil, stdin, @modinfo_stdout, nil)
|
147
|
+
@plugin.run
|
149
148
|
|
150
|
-
@
|
151
|
-
|
152
|
-
@ohai[:kernel][:modules].should have(107).modules
|
149
|
+
@plugin[:kernel][:modules].should have(107).modules
|
153
150
|
|
154
151
|
# Teh daterz
|
155
152
|
# Id Loadaddr Size Info Rev Module Name
|
156
153
|
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
|
157
154
|
teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"}
|
158
|
-
@
|
159
|
-
@
|
160
|
-
@
|
155
|
+
@plugin[:kernel][:modules].keys.should include("specfs")
|
156
|
+
@plugin[:kernel][:modules].keys.should_not include("Module")
|
157
|
+
@plugin[:kernel][:modules]["specfs"].should == teh_daterz
|
161
158
|
end
|
162
159
|
|
163
|
-
|
164
160
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
-
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
2
|
# License:: Apache License, Version 2.0
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,17 +14,17 @@
|
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
18
16
|
|
19
|
-
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
20
18
|
|
21
|
-
|
19
|
+
describe Ohai::System, "Solaris2.X memory plugin" do
|
20
|
+
before(:each) do
|
21
|
+
@plugin = get_plugin("solaris2/memory")
|
22
|
+
@plugin.stub(:collect_os).and_return("solaris2")
|
23
|
+
@plugin.stub(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if line =~ /kern.boottime=(.+)/
|
27
|
-
uptime_seconds Time.new.to_i - Time.parse($1).to_i
|
28
|
-
uptime self._seconds_to_human(uptime_seconds)
|
29
|
-
end
|
26
|
+
it "should get the total memory" do
|
27
|
+
@plugin.run
|
28
|
+
@plugin['memory']['total'].should eql(8194)
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
@@ -21,7 +21,29 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
describe Ohai::System, "Solaris2.X network plugin" do
|
22
22
|
|
23
23
|
before do
|
24
|
-
|
24
|
+
@solaris_arp_rn = <<-ARP_RN
|
25
|
+
Net to Media Table: IPv4
|
26
|
+
Device IP Address Mask Flags Phys Addr
|
27
|
+
------ -------------------- --------------- ----- ---------------
|
28
|
+
rtls0 172.31.4.1 255.255.255.255 00:14:69:81:0b:c0
|
29
|
+
rtls0 172.31.4.44 255.255.255.255 00:0c:29:c4:9a:11
|
30
|
+
rtls0 172.31.5.16 255.255.255.255 de:ad:be:ef:3b:ba
|
31
|
+
rtls0 172.31.4.16 255.255.255.255 d8:d3:85:65:39:40
|
32
|
+
rtls0 172.31.4.12 255.255.255.255 d8:d3:85:bb:43:b0
|
33
|
+
rtls0 172.31.4.115 255.255.255.255 52:54:00:0d:b7:5b
|
34
|
+
rtls0 172.31.4.126 255.255.255.255 52:54:00:2d:93:0c
|
35
|
+
rtls0 172.31.4.125 255.255.255.255 02:08:20:2e:29:8d
|
36
|
+
rtls0 172.31.4.121 255.255.255.255 52:54:00:25:8a:3f
|
37
|
+
rtls0 172.31.4.103 255.255.255.255 SP 52:54:00:7f:22:e7
|
38
|
+
rtls0 172.31.4.102 255.255.255.255 02:08:20:88:38:18
|
39
|
+
rtls0 172.31.4.106 255.255.255.255 02:08:20:6d:cc:aa
|
40
|
+
rtls0 172.31.4.83 255.255.255.255 02:08:20:05:8e:75
|
41
|
+
rtls0 172.31.4.82 255.255.255.255 52:54:00:2d:93:0c
|
42
|
+
rtls0 172.31.4.81 255.255.255.255 02:08:20:37:80:87
|
43
|
+
rtls0 224.0.0.0 240.0.0.0 SM 01:00:5e:00:00:00
|
44
|
+
ARP_RN
|
45
|
+
|
46
|
+
@solaris_ifconfig = <<-ENDIFCONFIG
|
25
47
|
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
26
48
|
inet 127.0.0.1 netmask ff000000
|
27
49
|
e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
|
@@ -61,7 +83,7 @@ vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
|
|
61
83
|
inet6 fe80::203:baff:fe17:4444/128
|
62
84
|
ENDIFCONFIG
|
63
85
|
|
64
|
-
solaris_netstat_rn = <<-NETSTAT_RN
|
86
|
+
@solaris_netstat_rn = <<-NETSTAT_RN
|
65
87
|
Routing Table: IPv4
|
66
88
|
Destination Gateway Flags Ref Use Interface
|
67
89
|
-------------------- -------------------- ----- ----- ---------- ---------
|
@@ -87,41 +109,43 @@ destination: default
|
|
87
109
|
0 0 0 0 0 0 1500 0
|
88
110
|
ROUTE_GET
|
89
111
|
|
90
|
-
@
|
91
|
-
@ifconfig_lines = solaris_ifconfig.split("\n")
|
112
|
+
@ifconfig_lines = @solaris_ifconfig.split("\n")
|
92
113
|
|
93
|
-
@
|
94
|
-
@
|
95
|
-
@
|
114
|
+
@plugin = get_plugin("solaris2/network")
|
115
|
+
@plugin.stub(:collect_os).and_return(:solaris2)
|
116
|
+
@plugin[:network] = Mash.new
|
96
117
|
|
97
|
-
@
|
98
|
-
@
|
118
|
+
@plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
119
|
+
@plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
|
120
|
+
@plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
|
99
121
|
end
|
100
122
|
|
101
123
|
describe "gathering IP layer address info" do
|
102
124
|
before do
|
103
|
-
@
|
104
|
-
@
|
125
|
+
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
|
126
|
+
@plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
127
|
+
@plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
|
128
|
+
@plugin.run
|
105
129
|
end
|
106
130
|
|
107
131
|
it "completes the run" do
|
108
|
-
@
|
132
|
+
@plugin['network'].should_not be_nil
|
109
133
|
end
|
110
134
|
|
111
135
|
it "detects the interfaces" do
|
112
|
-
@
|
136
|
+
@plugin['network']['interfaces'].keys.sort.should == ["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"]
|
113
137
|
end
|
114
138
|
|
115
139
|
it "detects the ip addresses of the interfaces" do
|
116
|
-
@
|
140
|
+
@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys.should include('72.2.115.28')
|
117
141
|
end
|
118
142
|
|
119
143
|
it "detects the encapsulation type of the interfaces" do
|
120
|
-
@
|
144
|
+
@plugin['network']['interfaces']['e1000g0:3']['encapsulation'].should == 'Ethernet'
|
121
145
|
end
|
122
146
|
|
123
147
|
it "detects the L3PROTECT network flag" do
|
124
|
-
@
|
148
|
+
@plugin['network']['interfaces']['net0']['flags'].should include('L3PROTECT')
|
125
149
|
end
|
126
150
|
end
|
127
151
|
|
@@ -129,13 +153,13 @@ ROUTE_GET
|
|
129
153
|
|
130
154
|
describe "setting the node's default IP address attribute" do
|
131
155
|
before do
|
132
|
-
@stdout =
|
133
|
-
@
|
134
|
-
@
|
156
|
+
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
|
157
|
+
@plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
158
|
+
@plugin.run
|
135
159
|
end
|
136
160
|
|
137
161
|
it "finds the default interface by asking which iface has the default route" do
|
138
|
-
@
|
162
|
+
@plugin[:network][:default_interface].should == 'e1000g0'
|
139
163
|
end
|
140
164
|
end
|
141
165
|
end
|