ohai 6.14.0 → 6.16.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai/mixin/ec2_metadata.rb +61 -6
- data/lib/ohai/plugins/cloud.rb +69 -5
- data/lib/ohai/plugins/darwin/system_profiler.rb +44 -7
- data/lib/ohai/plugins/freebsd/virtualization.rb +16 -0
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +1 -0
- data/lib/ohai/plugins/linode.rb +53 -0
- data/lib/ohai/plugins/linux/platform.rb +6 -2
- data/lib/ohai/plugins/network.rb +130 -44
- data/lib/ohai/plugins/{aix/ssh_host_key.rb → nodejs.rb} +15 -7
- data/lib/ohai/plugins/openstack.rb +46 -0
- data/lib/ohai/plugins/rackspace.rb +35 -1
- data/lib/ohai/plugins/solaris2/filesystem.rb +1 -1
- data/lib/ohai/plugins/solaris2/network.rb +2 -1
- data/lib/ohai/plugins/solaris2/platform.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +63 -0
- data/lib/ohai/plugins/virtualization.rb +1 -1
- data/lib/ohai/plugins/windows/cpu.rb +20 -3
- data/lib/ohai/plugins/windows/kernel.rb +0 -19
- data/lib/ohai/plugins/windows/kernel_devices.rb +39 -0
- data/lib/ohai/system.rb +3 -2
- data/lib/ohai/version.rb +1 -1
- data/spec/spec_helper.rb +14 -1
- data/spec/support/platform_helpers.rb +31 -0
- data/spec/{ohai → unit}/mixin/command_spec.rb +0 -0
- data/spec/{ohai → unit}/mixin/from_file_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/c_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/chef_spec.rb +20 -12
- data/spec/unit/plugins/cloud_spec.rb +159 -0
- data/spec/{ohai → unit}/plugins/darwin/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/darwin/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/darwin/network_spec.rb +4 -2
- data/spec/{ohai → unit}/plugins/darwin/platform_spec.rb +0 -0
- data/spec/unit/plugins/darwin/system_profiler_output.rb +79525 -0
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +48 -0
- data/spec/{ohai → unit}/plugins/dmi_spec.rb +0 -0
- data/spec/unit/plugins/ec2_spec.rb +199 -0
- data/spec/{ohai → unit}/plugins/erlang_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/eucalyptus_spec.rb +5 -5
- data/spec/{ohai → unit}/plugins/fail_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/freebsd/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/freebsd/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/freebsd/platform_spec.rb +0 -0
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +99 -0
- data/spec/{ohai → unit}/plugins/groovy_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/java_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/kernel_spec.rb +0 -0
- data/spec/unit/plugins/linode_spec.rb +156 -0
- data/spec/{ohai → unit}/plugins/linux/cpu_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/filesystem_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/lsb_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/network_spec.rb +3 -60
- data/spec/{ohai → unit}/plugins/linux/platform_spec.rb +10 -0
- data/spec/{ohai → unit}/plugins/linux/uptime_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/linux/virtualization_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/lua_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/mono_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/netbsd/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/netbsd/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/netbsd/platform_spec.rb +0 -0
- data/spec/unit/plugins/network_spec.rb +829 -0
- data/spec/unit/plugins/nodejs_spec.rb +51 -0
- data/spec/{ohai → unit}/plugins/ohai_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/ohai_time_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/openbsd/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/openbsd/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/openbsd/platform_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/os_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/passwd_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/perl_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/php_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/platform_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/python_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/rackspace_spec.rb +26 -0
- data/spec/{ohai → unit}/plugins/ruby_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/sigar/network_route_spec.rb +1 -0
- data/spec/{ohai → unit}/plugins/solaris2/hostname_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/solaris2/kernel_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/solaris2/network_spec.rb +8 -1
- data/spec/{ohai → unit}/plugins/solaris2/platform_spec.rb +0 -0
- data/spec/{ohai → unit}/plugins/solaris2/virtualization_spec.rb +0 -0
- data/spec/unit/plugins/ssh_host_keys_spec.rb +77 -0
- data/spec/{ohai → unit}/system_spec.rb +0 -0
- metadata +221 -184
- data/lib/ohai/plugins/darwin/ssh_host_key.rb +0 -25
- data/lib/ohai/plugins/freebsd/ssh_host_key.rb +0 -26
- data/lib/ohai/plugins/hpux/ssh_host_key.rb +0 -26
- data/lib/ohai/plugins/linux/ssh_host_key.rb +0 -26
- data/lib/ohai/plugins/netbsd/ssh_host_key.rb +0 -26
- data/lib/ohai/plugins/openbsd/ssh_host_key.rb +0 -26
- data/lib/ohai/plugins/solaris2/ssh_host_key.rb +0 -26
- data/spec/ohai/plugins/cloud_spec.rb +0 -113
- data/spec/ohai/plugins/ec2_spec.rb +0 -120
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author::
|
3
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Author:: Jacques Marneweck (<jacques@powertrip.co.za>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Jacques Marneweck. All rights reserved.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,11 +16,19 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
provides "
|
19
|
+
provides "languages/nodejs"
|
20
20
|
|
21
|
-
require_plugin "
|
21
|
+
require_plugin "languages"
|
22
22
|
|
23
|
-
|
23
|
+
output = nil
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
nodejs = Mash.new
|
26
|
+
|
27
|
+
status, stdout, stderr = run_command(:no_status_check => true, :command => "node -v")
|
28
|
+
if status == 0
|
29
|
+
output = stdout.split
|
30
|
+
if output.length >= 1
|
31
|
+
nodejs[:version] = output[0][1..output[0].length]
|
32
|
+
end
|
33
|
+
languages[:nodejs] = nodejs if nodejs[:version]
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Ray (<matt@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, 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 CONDITIONS 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
|
+
provides "openstack"
|
19
|
+
|
20
|
+
require 'ohai/mixin/ec2_metadata'
|
21
|
+
|
22
|
+
extend Ohai::Mixin::Ec2Metadata
|
23
|
+
|
24
|
+
# does it matter that it's not hitting latest?
|
25
|
+
#Ec2Metadata::EC2_METADATA_URL = "/latest/meta-data"
|
26
|
+
|
27
|
+
# Adds openstack Mash
|
28
|
+
if hint?('openstack') || hint?('hp')
|
29
|
+
Ohai::Log.debug("ohai openstack")
|
30
|
+
openstack Mash.new
|
31
|
+
#for now, use the metadata service
|
32
|
+
if can_metadata_connect?(EC2_METADATA_ADDR,80)
|
33
|
+
Ohai::Log.debug("connecting to the OpenStack metadata service")
|
34
|
+
self.fetch_metadata.each {|k, v| openstack[k] = v }
|
35
|
+
case
|
36
|
+
when hint?('hp')
|
37
|
+
openstack['provider'] = 'hp'
|
38
|
+
else
|
39
|
+
openstack['provider'] = 'openstack'
|
40
|
+
end
|
41
|
+
else
|
42
|
+
Ohai::Log.debug("unable to connect to the OpenStack metadata service")
|
43
|
+
end
|
44
|
+
else
|
45
|
+
Ohai::Log.debug("NOT ohai openstack")
|
46
|
+
end
|
@@ -58,8 +58,39 @@ end
|
|
58
58
|
# eth<Symbol>:: Interface name of public or private ip
|
59
59
|
def get_ip_address(name, eth)
|
60
60
|
network[:interfaces][eth][:addresses].each do |key, info|
|
61
|
-
|
61
|
+
if info['family'] == 'inet'
|
62
|
+
rackspace[name] = key
|
63
|
+
break # break when we found an address
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Names rackspace ipv6 address for interface
|
69
|
+
#
|
70
|
+
# === Parameters
|
71
|
+
# name<Symbol>:: Use :public_ip or :private_ip
|
72
|
+
# eth<Symbol>:: Interface name of public or private ip
|
73
|
+
def get_global_ipv6_address(name, eth)
|
74
|
+
network[:interfaces][eth][:addresses].each do |key, info|
|
75
|
+
# check if we got an ipv6 address and if its in global scope
|
76
|
+
if info['family'] == 'inet6' && info['scope'] == 'Global'
|
77
|
+
rackspace[name] = key
|
78
|
+
break # break when we found an address
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get the rackspace region
|
84
|
+
#
|
85
|
+
def get_region()
|
86
|
+
status, stdout, stderr = run_command(:no_status_check => true, :command => "xenstore-ls vm-data/provider_data")
|
87
|
+
if status == 0
|
88
|
+
stdout.split("\n").each do |line|
|
89
|
+
rackspace[:region] = line.split[2].delete('\"') if line =~ /^region/
|
90
|
+
end
|
62
91
|
end
|
92
|
+
rescue Ohai::Exceptions::Exec
|
93
|
+
Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
|
63
94
|
end
|
64
95
|
|
65
96
|
# Adds rackspace Mash
|
@@ -67,9 +98,12 @@ if looks_like_rackspace?
|
|
67
98
|
rackspace Mash.new
|
68
99
|
get_ip_address(:public_ip, :eth0)
|
69
100
|
get_ip_address(:private_ip, :eth1)
|
101
|
+
get_region()
|
70
102
|
# public_ip + private_ip are deprecated in favor of public_ipv4 and local_ipv4 to standardize.
|
71
103
|
rackspace[:public_ipv4] = rackspace[:public_ip]
|
104
|
+
get_global_ipv6_address(:public_ipv6, :eth0)
|
72
105
|
rackspace[:public_hostname] = "#{rackspace[:public_ip].gsub('.','-')}.static.cloud-ips.com"
|
73
106
|
rackspace[:local_ipv4] = rackspace[:private_ip]
|
107
|
+
get_global_ipv6_address(:local_ipv6, :eth1)
|
74
108
|
rackspace[:local_hostname] = hostname
|
75
109
|
end
|
@@ -60,6 +60,7 @@ require 'scanf'
|
|
60
60
|
def encaps_lookup(ifname)
|
61
61
|
return "Ethernet" if ifname.eql?("e1000g")
|
62
62
|
return "Ethernet" if ifname.eql?("eri")
|
63
|
+
return "Ethernet" if ifname.eql?("net")
|
63
64
|
return "Loopback" if ifname.eql?("lo")
|
64
65
|
"Unknown"
|
65
66
|
end
|
@@ -82,7 +83,7 @@ popen4("ifconfig -a") do |pid, stdin, stdout, stderr|
|
|
82
83
|
iface[cint] = Mash.new unless iface[cint]
|
83
84
|
iface[cint][:mtu] = $2
|
84
85
|
iface[cint][:index] = $3
|
85
|
-
if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
86
|
+
if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|L3PROTECT|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
86
87
|
flags = $1.split(',')
|
87
88
|
else
|
88
89
|
flags = Array.new
|
@@ -39,6 +39,8 @@ end
|
|
39
39
|
File.open("/etc/release") do |file|
|
40
40
|
while line = file.gets
|
41
41
|
case line
|
42
|
+
when /^.*(SmartOS).*$/
|
43
|
+
platform "smartos"
|
42
44
|
when /^\s*(OmniOS).*r(\d+).*$/
|
43
45
|
platform "omnios"
|
44
46
|
platform_version $2
|
@@ -54,8 +56,6 @@ File.open("/etc/release") do |file|
|
|
54
56
|
platform "solaris2"
|
55
57
|
when /^\s*(NexentaCore)\s.*$/
|
56
58
|
platform "nexentacore"
|
57
|
-
when /^\s*(SmartOS)\s.*$/
|
58
|
-
platform "smartos"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan <btm@opscode.com>
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, 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 CONDITIONS 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
|
+
provides "keys/ssh"
|
20
|
+
require_plugin "keys"
|
21
|
+
|
22
|
+
keys[:ssh] = Mash.new
|
23
|
+
|
24
|
+
def is_dsa_or_rsa?(file)
|
25
|
+
case IO.read(file).split[0]
|
26
|
+
when "ssh-dss"
|
27
|
+
"dsa"
|
28
|
+
when "ssh-rsa"
|
29
|
+
"rsa"
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
sshd_config = if File.exists?("/etc/ssh/sshd_config")
|
36
|
+
"/etc/ssh/sshd_config"
|
37
|
+
elsif File.exists?("/etc/sshd_config")
|
38
|
+
# Darwin
|
39
|
+
"/etc/sshd_config"
|
40
|
+
else
|
41
|
+
Ohai::Log.debug("Failed to find sshd configuration file")
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
if sshd_config
|
46
|
+
File.open(sshd_config) do |conf|
|
47
|
+
conf.each_line do |line|
|
48
|
+
if line.match(/^hostkey\s/i)
|
49
|
+
pub_file = "#{line.split[1]}.pub"
|
50
|
+
key_type = is_dsa_or_rsa?(pub_file)
|
51
|
+
keys[:ssh]["host_#{key_type}_public"] = IO.read(pub_file).split[1] unless key_type.nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
else
|
56
|
+
if keys[:ssh][:host_dsa_public].nil? && File.exists?("/etc/ssh/ssh_host_dsa_key.pub")
|
57
|
+
keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
58
|
+
end
|
59
|
+
|
60
|
+
if keys[:ssh][:host_rsa_public].nil? && File.exists?("/etc/ssh/ssh_host_rsa_key.pub")
|
61
|
+
keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
62
|
+
end
|
63
|
+
end
|
@@ -73,7 +73,7 @@ unless virtualization.nil? || !(virtualization[:role].eql?("host"))
|
|
73
73
|
virtualization[:storage][pool][:volumes] = Mash.new
|
74
74
|
sp.list_volumes.each do |v|
|
75
75
|
virtualization[:storage][pool][:volumes][v] = Mash.new
|
76
|
-
sv = sp.lookup_volume_by_name
|
76
|
+
sv = sp.lookup_volume_by_name v
|
77
77
|
['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)}
|
78
78
|
['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)}
|
79
79
|
end
|
@@ -25,7 +25,24 @@ cpu_number = 0
|
|
25
25
|
index = 0
|
26
26
|
|
27
27
|
WMI::Win32_Processor.find(:all).each do |processor|
|
28
|
-
|
28
|
+
#
|
29
|
+
# On Windows Server 2003 R2 (i.e. 5.2.*), numberofcores property
|
30
|
+
# doesn't exist on the Win32_Processor class unless the user has
|
31
|
+
# patched their system with:
|
32
|
+
# http://support.microsoft.com/kb/932370
|
33
|
+
#
|
34
|
+
# We're returning nil for cpu["cores"] and cpu["count"]
|
35
|
+
# when we don't see numberofcores property
|
36
|
+
#
|
37
|
+
|
38
|
+
number_of_cores = nil
|
39
|
+
begin
|
40
|
+
number_of_cores = processor.numberofcores
|
41
|
+
cpu_number += number_of_cores
|
42
|
+
rescue NoMethodError => e
|
43
|
+
Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370")
|
44
|
+
end
|
45
|
+
|
29
46
|
current_cpu = index.to_s
|
30
47
|
index += 1
|
31
48
|
cpuinfo[current_cpu] = Mash.new
|
@@ -35,7 +52,7 @@ WMI::Win32_Processor.find(:all).each do |processor|
|
|
35
52
|
cpuinfo[current_cpu]["stepping"] = processor.stepping
|
36
53
|
cpuinfo[current_cpu]["physical_id"] = processor.deviceid
|
37
54
|
#cpuinfo[current_cpu]["core_id"] = XXX
|
38
|
-
cpuinfo[current_cpu]["cores"] =
|
55
|
+
cpuinfo[current_cpu]["cores"] = number_of_cores
|
39
56
|
cpuinfo[current_cpu]["model_name"] = processor.description
|
40
57
|
cpuinfo[current_cpu]["mhz"] = processor.maxclockspeed.to_s
|
41
58
|
cpuinfo[current_cpu]["cache_size"] = "#{processor.l2cachesize} KB"
|
@@ -43,5 +60,5 @@ WMI::Win32_Processor.find(:all).each do |processor|
|
|
43
60
|
end
|
44
61
|
|
45
62
|
cpu cpuinfo
|
46
|
-
cpu[:total] = cpu_number
|
63
|
+
cpu[:total] = (cpu_number == 0) ? nil : cpu_number
|
47
64
|
cpu[:real] = index
|
@@ -56,22 +56,3 @@ host.properties_.each do |p|
|
|
56
56
|
end
|
57
57
|
|
58
58
|
kernel[:machine] = machine_lookup("#{kernel[:cs_info][:system_type]}")
|
59
|
-
|
60
|
-
kext = Mash.new
|
61
|
-
pnp_drivers = Mash.new
|
62
|
-
|
63
|
-
drivers = WMI::Win32_PnPSignedDriver.find(:all)
|
64
|
-
drivers.each do |driver|
|
65
|
-
pnp_drivers[driver.DeviceID] = Mash.new
|
66
|
-
driver.properties_.each do |p|
|
67
|
-
pnp_drivers[driver.DeviceID][p.name.wmi_underscore.to_sym] = driver.send(p.name)
|
68
|
-
end
|
69
|
-
if driver.DeviceName
|
70
|
-
kext[driver.DeviceName] = pnp_drivers[driver.DeviceID]
|
71
|
-
kext[driver.DeviceName][:version] = pnp_drivers[driver.DeviceID][:driver_version]
|
72
|
-
kext[driver.DeviceName][:date] = pnp_drivers[driver.DeviceID][:driver_date] ? pnp_drivers[driver.DeviceID][:driver_date].to_s[0..7] : nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
kernel[:pnp_drivers] = pnp_drivers
|
77
|
-
kernel[:modules] = kext
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, 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 CONDITIONS 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
|
+
require 'ruby-wmi'
|
19
|
+
|
20
|
+
WIN32OLE.codepage = WIN32OLE::CP_UTF8
|
21
|
+
|
22
|
+
kext = Mash.new
|
23
|
+
pnp_drivers = Mash.new
|
24
|
+
|
25
|
+
drivers = WMI::Win32_PnPSignedDriver.find(:all)
|
26
|
+
drivers.each do |driver|
|
27
|
+
pnp_drivers[driver.DeviceID] = Mash.new
|
28
|
+
driver.properties_.each do |p|
|
29
|
+
pnp_drivers[driver.DeviceID][p.name.wmi_underscore.to_sym] = driver.send(p.name)
|
30
|
+
end
|
31
|
+
if driver.DeviceName
|
32
|
+
kext[driver.DeviceName] = pnp_drivers[driver.DeviceID]
|
33
|
+
kext[driver.DeviceName][:version] = pnp_drivers[driver.DeviceID][:driver_version]
|
34
|
+
kext[driver.DeviceName][:date] = pnp_drivers[driver.DeviceID][:driver_date] ? pnp_drivers[driver.DeviceID][:driver_date].to_s[0..7] : nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
kernel[:pnp_drivers] = pnp_drivers
|
39
|
+
kernel[:modules] = kext
|
data/lib/ohai/system.rb
CHANGED
@@ -21,6 +21,7 @@ require 'ohai/log'
|
|
21
21
|
require 'ohai/mixin/from_file'
|
22
22
|
require 'ohai/mixin/command'
|
23
23
|
require 'ohai/mixin/string'
|
24
|
+
require 'mixlib/shellout'
|
24
25
|
|
25
26
|
require 'yajl'
|
26
27
|
|
@@ -244,8 +245,8 @@ module Ohai
|
|
244
245
|
data = data[part]
|
245
246
|
end
|
246
247
|
raise ArgumentError, "I cannot find an attribute named #{a}!" if data.nil?
|
247
|
-
case
|
248
|
-
when Hash,Mash,Array
|
248
|
+
case data
|
249
|
+
when Hash,Mash,Array,Fixnum
|
249
250
|
json_pretty_print(data)
|
250
251
|
when String
|
251
252
|
if data.respond_to?(:lines)
|
data/lib/ohai/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'rspec'
|
2
|
-
require 'mixlib/config'
|
3
2
|
|
3
|
+
$:.unshift(File.expand_path("../..", __FILE__))
|
4
4
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
require 'spec/support/platform_helpers'
|
5
7
|
require 'ohai'
|
6
8
|
Ohai::Config[:log_level] = :error
|
7
9
|
|
@@ -54,3 +56,14 @@ module SimpleFromFile
|
|
54
56
|
self.instance_eval(IO.read(filename), filename, 1)
|
55
57
|
end
|
56
58
|
end
|
59
|
+
|
60
|
+
RSpec.configure do |config|
|
61
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
62
|
+
|
63
|
+
config.filter_run_excluding :windows_only => true unless windows?
|
64
|
+
config.filter_run_excluding :unix_only => true unless unix?
|
65
|
+
config.filter_run_excluding :ruby_18_only => true unless ruby_18?
|
66
|
+
config.filter_run_excluding :ruby_19_only => true unless ruby_19?
|
67
|
+
config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root'
|
68
|
+
config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
def ruby_19?
|
2
|
+
!!(RUBY_VERSION =~ /^1.9/)
|
3
|
+
end
|
4
|
+
|
5
|
+
def ruby_18?
|
6
|
+
!!(RUBY_VERSION =~ /^1.8/)
|
7
|
+
end
|
8
|
+
|
9
|
+
def windows?
|
10
|
+
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
|
11
|
+
end
|
12
|
+
|
13
|
+
# def jruby?
|
14
|
+
|
15
|
+
def unix?
|
16
|
+
!windows?
|
17
|
+
end
|
18
|
+
|
19
|
+
def os_x?
|
20
|
+
!!(RUBY_PLATFORM =~ /darwin/)
|
21
|
+
end
|
22
|
+
|
23
|
+
def solaris?
|
24
|
+
!!(RUBY_PLATFORM =~ /solaris/)
|
25
|
+
end
|
26
|
+
|
27
|
+
def freebsd?
|
28
|
+
!!(RUBY_PLATFORM =~ /freebsd/)
|
29
|
+
end
|
30
|
+
|
31
|
+
DEV_NULL = windows? ? 'NUL' : '/dev/null'
|