ohai 8.10.0 → 8.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Rakefile +13 -4
- data/bin/ohai +3 -4
- data/lib/ohai.rb +4 -4
- data/lib/ohai/application.rb +7 -6
- data/lib/ohai/common/dmi.rb +56 -56
- data/lib/ohai/config.rb +12 -8
- data/lib/ohai/dsl.rb +3 -3
- data/lib/ohai/dsl/plugin.rb +5 -5
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +1 -0
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +7 -7
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mash.rb +3 -2
- data/lib/ohai/mixin/command.rb +25 -23
- data/lib/ohai/mixin/dmi_decode.rb +10 -10
- data/lib/ohai/mixin/ec2_metadata.rb +40 -39
- data/lib/ohai/mixin/gce_metadata.rb +9 -9
- data/lib/ohai/mixin/network_constants.rb +1 -1
- data/lib/ohai/mixin/os.rb +3 -3
- data/lib/ohai/mixin/seconds_to_human.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +10 -10
- data/lib/ohai/mixin/string.rb +2 -2
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/cpu.rb +2 -2
- data/lib/ohai/plugins/aix/filesystem.rb +2 -2
- data/lib/ohai/plugins/aix/memory.rb +2 -2
- data/lib/ohai/plugins/aix/network.rb +9 -10
- data/lib/ohai/plugins/aix/os.rb +2 -2
- data/lib/ohai/plugins/aix/uptime.rb +3 -3
- data/lib/ohai/plugins/aix/virtualization.rb +23 -23
- data/lib/ohai/plugins/azure.rb +32 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +22 -22
- data/lib/ohai/plugins/c.rb +3 -3
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +59 -60
- data/lib/ohai/plugins/cloud_v2.rb +37 -39
- data/lib/ohai/plugins/darwin/cpu.rb +1 -1
- data/lib/ohai/plugins/darwin/filesystem2.rb +5 -5
- data/lib/ohai/plugins/darwin/memory.rb +5 -6
- data/lib/ohai/plugins/darwin/network.rb +7 -7
- data/lib/ohai/plugins/darwin/system_profiler.rb +32 -33
- data/lib/ohai/plugins/darwin/virtualization.rb +9 -9
- data/lib/ohai/plugins/digital_ocean.rb +16 -16
- data/lib/ohai/plugins/dmi.rb +6 -6
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +2 -2
- data/lib/ohai/plugins/dragonflybsd/memory.rb +0 -1
- data/lib/ohai/plugins/dragonflybsd/network.rb +4 -4
- data/lib/ohai/plugins/dragonflybsd/os.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +39 -15
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +3 -3
- data/lib/ohai/plugins/eucalyptus.rb +16 -12
- data/lib/ohai/plugins/freebsd/cpu.rb +2 -2
- data/lib/ohai/plugins/freebsd/memory.rb +0 -1
- data/lib/ohai/plugins/freebsd/network.rb +4 -4
- data/lib/ohai/plugins/freebsd/os.rb +1 -1
- data/lib/ohai/plugins/gce.rb +6 -6
- data/lib/ohai/plugins/hostname.rb +7 -7
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/ip_scopes.rb +9 -9
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/joyent.rb +7 -7
- data/lib/ohai/plugins/kernel.rb +8 -8
- data/lib/ohai/plugins/linode.rb +7 -4
- data/lib/ohai/plugins/linux/cpu.rb +5 -5
- data/lib/ohai/plugins/linux/filesystem.rb +16 -16
- data/lib/ohai/plugins/linux/filesystem2.rb +15 -15
- data/lib/ohai/plugins/linux/mdadm.rb +3 -3
- data/lib/ohai/plugins/linux/network.rb +85 -51
- data/lib/ohai/plugins/linux/platform.rb +24 -24
- data/lib/ohai/plugins/linux/virtualization.rb +8 -8
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/cpu.rb +1 -1
- data/lib/ohai/plugins/netbsd/network.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/network_listeners.rb +30 -26
- data/lib/ohai/plugins/ohai.rb +3 -3
- data/lib/ohai/plugins/openbsd/cpu.rb +4 -4
- data/lib/ohai/plugins/openbsd/memory.rb +4 -4
- data/lib/ohai/plugins/openbsd/network.rb +3 -3
- data/lib/ohai/plugins/openstack.rb +12 -12
- data/lib/ohai/plugins/os.rb +2 -2
- data/lib/ohai/plugins/packages.rb +22 -22
- data/lib/ohai/plugins/passwd.rb +4 -4
- data/lib/ohai/plugins/powershell.rb +9 -9
- data/lib/ohai/plugins/ps.rb +2 -2
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +13 -13
- data/lib/ohai/plugins/root_group.rb +4 -4
- data/lib/ohai/plugins/ruby.rb +6 -6
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/sigar/cpu.rb +1 -1
- data/lib/ohai/plugins/sigar/filesystem.rb +1 -1
- data/lib/ohai/plugins/sigar/network.rb +13 -13
- data/lib/ohai/plugins/sigar/network_route.rb +34 -29
- data/lib/ohai/plugins/softlayer.rb +8 -7
- data/lib/ohai/plugins/solaris2/cpu.rb +19 -19
- data/lib/ohai/plugins/solaris2/dmi.rb +63 -63
- data/lib/ohai/plugins/solaris2/filesystem.rb +13 -13
- data/lib/ohai/plugins/solaris2/memory.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +5 -5
- data/lib/ohai/plugins/solaris2/virtualization.rb +18 -18
- data/lib/ohai/plugins/solaris2/zpools.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +2 -2
- data/lib/ohai/plugins/uptime.rb +4 -5
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/virtualization.rb +17 -17
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +14 -14
- data/lib/ohai/plugins/windows/drivers.rb +8 -8
- data/lib/ohai/plugins/windows/filesystem.rb +4 -4
- data/lib/ohai/plugins/windows/memory.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +10 -10
- data/lib/ohai/plugins/windows/platform.rb +1 -2
- data/lib/ohai/plugins/windows/virtualization.rb +17 -17
- data/lib/ohai/provides_map.rb +7 -7
- data/lib/ohai/runner.rb +3 -3
- data/lib/ohai/system.rb +21 -20
- data/lib/ohai/util/file_helper.rb +1 -2
- data/lib/ohai/util/ip_helper.rb +4 -4
- data/lib/ohai/util/win32.rb +5 -5
- data/lib/ohai/util/win32/group_helper.rb +4 -5
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +7 -5
- data/spec/functional/application_spec.rb +23 -23
- data/spec/functional/loader_spec.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +13 -13
- data/spec/functional/plugins/root_group_spec.rb +5 -5
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -9
- data/spec/support/integration_helper.rb +7 -7
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/unit/application_spec.rb +17 -17
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/dsl/plugin_spec.rb +28 -28
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +9 -9
- data/spec/unit/mixin/command_spec.rb +5 -5
- data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
- data/spec/unit/mixin/softlayer_metadata_spec.rb +19 -23
- data/spec/unit/plugin_config_spec.rb +5 -5
- data/spec/unit/plugins/abort_spec.rb +3 -3
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +25 -25
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -2
- data/spec/unit/plugins/aix/kernel_spec.rb +3 -3
- data/spec/unit/plugins/aix/memory_spec.rb +8 -8
- data/spec/unit/plugins/aix/network_spec.rb +38 -38
- data/spec/unit/plugins/aix/os_spec.rb +1 -2
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +11 -11
- data/spec/unit/plugins/azure_spec.rb +118 -20
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +4 -4
- data/spec/unit/plugins/c_spec.rb +12 -12
- data/spec/unit/plugins/chef_spec.rb +2 -2
- data/spec/unit/plugins/cloud_spec.rb +37 -37
- data/spec/unit/plugins/cloud_v2_spec.rb +64 -65
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -2
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -4
- data/spec/unit/plugins/darwin/kernel_spec.rb +6 -10
- data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
- data/spec/unit/plugins/darwin/network_spec.rb +352 -353
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -2
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +3 -3
- data/spec/unit/plugins/darwin/virtualization_spec.rb +6 -6
- data/spec/unit/plugins/digital_ocean_spec.rb +38 -37
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +97 -88
- data/spec/unit/plugins/elixir_spec.rb +1 -2
- data/spec/unit/plugins/erlang_spec.rb +2 -2
- data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
- data/spec/unit/plugins/fail_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/cpu_spec.rb +14 -14
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -3
- data/spec/unit/plugins/freebsd/os_spec.rb +4 -5
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/gce_spec.rb +9 -9
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -2
- data/spec/unit/plugins/hostname_spec.rb +1 -2
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +38 -38
- data/spec/unit/plugins/java_spec.rb +52 -1
- data/spec/unit/plugins/joyent_spec.rb +9 -11
- data/spec/unit/plugins/kernel_spec.rb +11 -12
- data/spec/unit/plugins/linode_spec.rb +29 -29
- data/spec/unit/plugins/linux/block_device_spec.rb +21 -21
- data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
- data/spec/unit/plugins/linux/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/linux/filesystem_spec.rb +85 -86
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -3
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -2
- data/spec/unit/plugins/linux/mdadm_spec.rb +4 -4
- data/spec/unit/plugins/linux/memory_spec.rb +29 -33
- data/spec/unit/plugins/linux/network_spec.rb +463 -245
- data/spec/unit/plugins/linux/platform_spec.rb +64 -65
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -2
- data/spec/unit/plugins/linux/virtualization_spec.rb +42 -42
- data/spec/unit/plugins/lua_spec.rb +1 -2
- data/spec/unit/plugins/mono_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +118 -118
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/openstack_spec.rb +35 -37
- data/spec/unit/plugins/os_spec.rb +7 -8
- data/spec/unit/plugins/packages_spec.rb +118 -118
- data/spec/unit/plugins/passwd_spec.rb +18 -18
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +4 -4
- data/spec/unit/plugins/platform_spec.rb +8 -9
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +66 -68
- data/spec/unit/plugins/root_group_spec.rb +26 -26
- data/spec/unit/plugins/ruby_spec.rb +14 -15
- data/spec/unit/plugins/rust_spec.rb +2 -2
- data/spec/unit/plugins/sigar/network_route_spec.rb +36 -36
- data/spec/unit/plugins/softlayer_spec.rb +10 -10
- data/spec/unit/plugins/solaris2/cpu_spec.rb +20 -21
- data/spec/unit/plugins/solaris2/dmi_spec.rb +5 -6
- data/spec/unit/plugins/solaris2/filesystem.rb +5 -5
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/memory_spec.rb +5 -5
- data/spec/unit/plugins/solaris2/network_spec.rb +7 -8
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +3 -5
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +19 -19
- data/spec/unit/plugins/vmware_spec.rb +28 -28
- data/spec/unit/plugins/windows/cpu_spec.rb +46 -48
- data/spec/unit/plugins/windows/memory_spec.rb +5 -5
- data/spec/unit/plugins/windows/virtualization_spec.rb +163 -163
- data/spec/unit/provides_map_spec.rb +10 -10
- data/spec/unit/runner_spec.rb +10 -10
- data/spec/unit/system_spec.rb +19 -19
- data/spec/unit/util/file_helper_spec.rb +5 -6
- data/spec/unit/util/ip_helper_spec.rb +39 -39
- metadata +31 -4
data/lib/ohai/provides_map.rb
CHANGED
@@ -17,10 +17,10 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
20
|
+
require "ohai/mash"
|
21
|
+
require "ohai/exception"
|
22
|
+
require "ohai/mixin/os"
|
23
|
+
require "ohai/dsl"
|
24
24
|
|
25
25
|
module Ohai
|
26
26
|
class ProvidesMap
|
@@ -102,7 +102,7 @@ module Ohai
|
|
102
102
|
plugins.uniq
|
103
103
|
end
|
104
104
|
|
105
|
-
def all_plugins(attribute_filter=nil)
|
105
|
+
def all_plugins(attribute_filter = nil)
|
106
106
|
if attribute_filter.nil?
|
107
107
|
collected = []
|
108
108
|
collect_plugins_in(map, collected).uniq
|
@@ -117,7 +117,7 @@ module Ohai
|
|
117
117
|
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if attribute.match(/\/\/+/)
|
118
118
|
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if attribute.match(/\/$/)
|
119
119
|
|
120
|
-
parts = attribute.split(
|
120
|
+
parts = attribute.split("/")
|
121
121
|
parts.shift if parts.length != 0 && parts[0].length == 0 # attribute begins with a '/'
|
122
122
|
parts
|
123
123
|
end
|
@@ -144,7 +144,7 @@ module Ohai
|
|
144
144
|
# attribute under attr (if attribute = attr/sub1/sub2 then we
|
145
145
|
# search provides_map[attr] for sub1/sub2)
|
146
146
|
unless rest.empty?
|
147
|
-
subtree = select_closest_subtree(provides_map[attr], rest.join(
|
147
|
+
subtree = select_closest_subtree(provides_map[attr], rest.join("/"))
|
148
148
|
end
|
149
149
|
|
150
150
|
if subtree.nil?
|
data/lib/ohai/runner.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "ohai/dsl"
|
21
21
|
|
22
22
|
module Ohai
|
23
23
|
class Runner
|
@@ -50,7 +50,7 @@ module Ohai
|
|
50
50
|
raise
|
51
51
|
rescue SystemExit # abort or exit from plug-in should exit Ohai with failure code
|
52
52
|
raise
|
53
|
-
rescue Exception,Errno::ENOENT => e
|
53
|
+
rescue Exception, Errno::ENOENT => e
|
54
54
|
Ohai::Log.debug("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}")
|
55
55
|
end
|
56
56
|
end
|
@@ -63,7 +63,7 @@ module Ohai
|
|
63
63
|
|
64
64
|
def run_v7_plugin(plugin)
|
65
65
|
visited = [ plugin ]
|
66
|
-
|
66
|
+
until visited.empty?
|
67
67
|
next_plugin = visited.pop
|
68
68
|
|
69
69
|
next if next_plugin.has_run?
|
data/lib/ohai/system.rb
CHANGED
@@ -16,18 +16,18 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
19
|
+
require "ohai/loader"
|
20
|
+
require "ohai/log"
|
21
|
+
require "ohai/mash"
|
22
|
+
require "ohai/runner"
|
23
|
+
require "ohai/dsl"
|
24
|
+
require "ohai/mixin/command"
|
25
|
+
require "ohai/mixin/os"
|
26
|
+
require "ohai/mixin/string"
|
27
|
+
require "ohai/mixin/constant_helper"
|
28
|
+
require "ohai/provides_map"
|
29
|
+
require "ohai/hints"
|
30
|
+
require "mixlib/shellout"
|
31
31
|
|
32
32
|
module Ohai
|
33
33
|
class System
|
@@ -65,7 +65,7 @@ module Ohai
|
|
65
65
|
@data[key]
|
66
66
|
end
|
67
67
|
|
68
|
-
def all_plugins(attribute_filter=nil)
|
68
|
+
def all_plugins(attribute_filter = nil)
|
69
69
|
# Reset the system when all_plugins is called since this function
|
70
70
|
# can be run multiple times in order to pick up any changes in the
|
71
71
|
# config or plugins with Chef.
|
@@ -88,7 +88,7 @@ module Ohai
|
|
88
88
|
# Users who are migrating from ohai 6 may give one or more Ohai 6 plugin
|
89
89
|
# names as the +attribute_filter+. In this case we return early because
|
90
90
|
# the v7 plugin provides map will not have an entry for this plugin.
|
91
|
-
if attribute_filter and Array(attribute_filter).all? {|filter_item| have_v6_plugin?(filter_item) }
|
91
|
+
if attribute_filter and Array(attribute_filter).all? { |filter_item| have_v6_plugin?(filter_item) }
|
92
92
|
return true
|
93
93
|
end
|
94
94
|
|
@@ -104,7 +104,7 @@ module Ohai
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def have_v6_plugin?(name)
|
107
|
-
@v6_dependency_solver.values.any? {|v6plugin| v6plugin.name == name }
|
107
|
+
@v6_dependency_solver.values.any? { |v6plugin| v6plugin.name == name }
|
108
108
|
end
|
109
109
|
|
110
110
|
def pathify_v6_plugin(plugin_name)
|
@@ -117,7 +117,7 @@ module Ohai
|
|
117
117
|
# Make sure that you are not breaking backwards compatibility
|
118
118
|
# if you are changing any of the APIs below.
|
119
119
|
#
|
120
|
-
def require_plugin(plugin_ref, force=false)
|
120
|
+
def require_plugin(plugin_ref, force = false)
|
121
121
|
plugins = [ ]
|
122
122
|
# This method is only callable by version 6 plugins.
|
123
123
|
# First we check if there exists a v6 plugin that fulfills the dependency.
|
@@ -147,7 +147,7 @@ module Ohai
|
|
147
147
|
rescue Ohai::Exceptions::DependencyCycle, Ohai::Exceptions::AttributeNotFound => e
|
148
148
|
Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
|
149
149
|
raise
|
150
|
-
rescue Exception,Errno::ENOENT => e
|
150
|
+
rescue Exception, Errno::ENOENT => e
|
151
151
|
Ohai::Log.debug("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}")
|
152
152
|
end
|
153
153
|
end
|
@@ -163,7 +163,7 @@ module Ohai
|
|
163
163
|
#
|
164
164
|
# This method takes a naive approach to v6 plugins: it simply re-runs all
|
165
165
|
# of them whenever called.
|
166
|
-
def refresh_plugins(attribute_filter=nil)
|
166
|
+
def refresh_plugins(attribute_filter = nil)
|
167
167
|
Ohai::Hints.refresh_hints()
|
168
168
|
@provides_map.all_plugins(attribute_filter).each do |plugin|
|
169
169
|
plugin.reset!
|
@@ -181,7 +181,7 @@ module Ohai
|
|
181
181
|
#
|
182
182
|
# Pretty Print this object as JSON
|
183
183
|
#
|
184
|
-
def json_pretty_print(item=nil)
|
184
|
+
def json_pretty_print(item = nil)
|
185
185
|
FFI_Yajl::Encoder.new(pretty: true, validate_utf8: false).encode(item || @data)
|
186
186
|
end
|
187
187
|
|
@@ -192,7 +192,7 @@ module Ohai
|
|
192
192
|
end
|
193
193
|
raise ArgumentError, "I cannot find an attribute named #{a}!" if data.nil?
|
194
194
|
case data
|
195
|
-
when Hash,Mash,Array,Fixnum
|
195
|
+
when Hash, Mash, Array, Fixnum
|
196
196
|
json_pretty_print(data)
|
197
197
|
when String
|
198
198
|
if data.respond_to?(:lines)
|
@@ -206,6 +206,7 @@ module Ohai
|
|
206
206
|
end
|
207
207
|
|
208
208
|
private
|
209
|
+
|
209
210
|
def configure_ohai
|
210
211
|
Ohai::Config.merge_deprecated_config
|
211
212
|
Ohai.config.merge!(@config)
|
@@ -22,7 +22,7 @@ module Ohai
|
|
22
22
|
module Util
|
23
23
|
module FileHelper
|
24
24
|
def which(cmd)
|
25
|
-
paths = ENV[
|
25
|
+
paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
|
26
26
|
paths.each do |path|
|
27
27
|
filename = File.join(path, cmd)
|
28
28
|
return filename if File.executable?(filename)
|
@@ -32,4 +32,3 @@ module Ohai
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
data/lib/ohai/util/ip_helper.rb
CHANGED
@@ -14,14 +14,14 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
require
|
17
|
+
require "ipaddress"
|
18
18
|
|
19
19
|
module Ohai
|
20
20
|
module Util
|
21
21
|
module IpHelper
|
22
22
|
# Corresponding to RFC 4192 + RFC 4193
|
23
|
-
IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress(
|
24
|
-
IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress(
|
23
|
+
IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10")
|
24
|
+
IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7")
|
25
25
|
|
26
26
|
def private_address?(addr)
|
27
27
|
ip = IPAddress(addr)
|
@@ -47,7 +47,7 @@ module Ohai
|
|
47
47
|
if ip.respond_to? :loopback?
|
48
48
|
ip.loopback?
|
49
49
|
else
|
50
|
-
IPAddress(
|
50
|
+
IPAddress("127.0.0.0/8").include? ip
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/ohai/util/win32.rb
CHANGED
@@ -21,19 +21,19 @@ module Ohai
|
|
21
21
|
module Win32
|
22
22
|
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
23
23
|
|
24
|
-
require
|
24
|
+
require "ffi"
|
25
25
|
|
26
26
|
extend FFI::Library
|
27
27
|
|
28
|
-
ffi_lib
|
28
|
+
ffi_lib "advapi32"
|
29
29
|
|
30
30
|
attach_function :lookup_account_sid,
|
31
|
-
:LookupAccountSidA,[ :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :long
|
31
|
+
:LookupAccountSidA, [ :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :long
|
32
32
|
|
33
33
|
attach_function :convert_string_sid_to_sid,
|
34
|
-
:ConvertStringSidToSidA,[ :pointer, :pointer ], :long
|
34
|
+
:ConvertStringSidToSidA, [ :pointer, :pointer ], :long
|
35
35
|
|
36
|
-
ffi_lib
|
36
|
+
ffi_lib "kernel32"
|
37
37
|
|
38
38
|
attach_function :local_free,
|
39
39
|
:LocalFree, [ :pointer ], :long
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require
|
19
|
+
require "ohai/util/win32"
|
20
20
|
|
21
21
|
module Ohai
|
22
22
|
module Util
|
@@ -26,7 +26,7 @@ module Ohai
|
|
26
26
|
# internal name for the Administrators group, which lets us work
|
27
27
|
# properly in environments with a renamed or localized name for the
|
28
28
|
# Administrators group
|
29
|
-
BUILTIN_ADMINISTRATORS_SID =
|
29
|
+
BUILTIN_ADMINISTRATORS_SID = "S-1-5-32-544"
|
30
30
|
|
31
31
|
def self.windows_root_group_name
|
32
32
|
administrators_group_name_result = nil
|
@@ -40,8 +40,8 @@ module Ohai
|
|
40
40
|
end
|
41
41
|
|
42
42
|
administrators_group_name_buffer = 0.chr * 260
|
43
|
-
administrators_group_name_length = [administrators_group_name_buffer.length].pack(
|
44
|
-
domain_name_length_buffer = [260].pack(
|
43
|
+
administrators_group_name_length = [administrators_group_name_buffer.length].pack("L")
|
44
|
+
domain_name_length_buffer = [260].pack("L")
|
45
45
|
sid_use_result = 0.chr * 4
|
46
46
|
|
47
47
|
# Use LookupAccountSid rather than WMI's Win32_Group class because WMI will attempt
|
@@ -73,4 +73,3 @@ module Ohai
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
$:.unshift File.expand_path(
|
3
|
-
require
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require "ohai/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "ohai"
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency "mixlib-config", "~> 2.0"
|
22
22
|
s.add_dependency "mixlib-log"
|
23
23
|
s.add_dependency "mixlib-shellout", "~> 2.0"
|
24
|
+
s.add_dependency "plist"
|
24
25
|
s.add_dependency "ipaddress"
|
25
26
|
s.add_dependency "wmi-lite", "~> 1.0"
|
26
27
|
s.add_dependency "ffi", "~> 1.9"
|
@@ -40,10 +41,11 @@ Gem::Specification.new do |s|
|
|
40
41
|
s.add_development_dependency "rspec-mocks", "~> 3.0"
|
41
42
|
s.add_development_dependency "rspec-collection_matchers", "~> 1.0"
|
42
43
|
s.add_development_dependency "rspec_junit_formatter"
|
44
|
+
s.add_development_dependency "github_changelog_generator", "1.11.3"
|
43
45
|
|
44
46
|
s.bindir = "bin"
|
45
|
-
s.executables = %w
|
47
|
+
s.executables = %w{ohai}
|
46
48
|
|
47
|
-
s.require_path =
|
48
|
-
s.files = %w
|
49
|
+
s.require_path = "lib"
|
50
|
+
s.files = %w{LICENSE README.md Gemfile Rakefile} + Dir.glob("*.gemspec") + Dir.glob("{docs,lib,spec}/**/*")
|
49
51
|
end
|
@@ -16,11 +16,11 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../spec_helper"
|
20
20
|
|
21
|
-
require
|
21
|
+
require "ohai/application"
|
22
22
|
|
23
|
-
RSpec.describe
|
23
|
+
RSpec.describe "Ohai::Application" do
|
24
24
|
|
25
25
|
let(:app) { Ohai::Application.new }
|
26
26
|
let(:argv) { [] }
|
@@ -37,12 +37,12 @@ RSpec.describe 'Ohai::Application' do
|
|
37
37
|
|
38
38
|
describe '#configure_ohai' do
|
39
39
|
|
40
|
-
let(:config_content) {
|
41
|
-
let(:config_dir) { Dir.mktmpdir(
|
42
|
-
let(:config_location) { File.join(config_dir,
|
40
|
+
let(:config_content) { "" }
|
41
|
+
let(:config_dir) { Dir.mktmpdir(".chef") }
|
42
|
+
let(:config_location) { File.join(config_dir, "config.rb") }
|
43
43
|
|
44
44
|
before(:each) do
|
45
|
-
File.open(config_location,
|
45
|
+
File.open(config_location, "w+") do |f|
|
46
46
|
f.write(config_content)
|
47
47
|
end
|
48
48
|
end
|
@@ -51,13 +51,13 @@ RSpec.describe 'Ohai::Application' do
|
|
51
51
|
FileUtils.rm_rf(config_dir)
|
52
52
|
end
|
53
53
|
|
54
|
-
context
|
54
|
+
context "when a configuration file is provided as a command line option" do
|
55
55
|
|
56
|
-
let(:argv) { [
|
56
|
+
let(:argv) { [ "-c", config_location + ".oops" ] }
|
57
57
|
|
58
|
-
context
|
58
|
+
context "and the configuration file does not exist" do
|
59
59
|
|
60
|
-
it
|
60
|
+
it "logs an error and terminates the application" do
|
61
61
|
expect(STDERR).to receive(:puts).with(/FATAL:/)
|
62
62
|
expect(Ohai::Log).to receive(:fatal).
|
63
63
|
with(/Specified config file #{argv[1]} does not exist/)
|
@@ -66,33 +66,33 @@ RSpec.describe 'Ohai::Application' do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
context
|
69
|
+
context "when a workstation configuration file exists" do
|
70
70
|
|
71
|
-
let(:config_content) {
|
71
|
+
let(:config_content) { "ohai.disabled_plugins = [ :Foo, :Baz ]" }
|
72
72
|
|
73
73
|
# env['KNIFE_HOME']/config.rb is the first config file the workstation
|
74
74
|
# config loader looks for:
|
75
75
|
# https://github.com/chef/chef/blob/master/chef-config/lib/chef-config/workstation_config_loader.rb#L102
|
76
|
-
let(:env) { {
|
76
|
+
let(:env) { { "KNIFE_HOME" => config_dir } }
|
77
77
|
|
78
78
|
before(:each) do
|
79
79
|
allow_any_instance_of(ChefConfig::WorkstationConfigLoader).
|
80
80
|
to receive(:env).and_return(env)
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
83
|
+
it "loads the workstation configuration file" do
|
84
84
|
app.configure_ohai
|
85
85
|
expect(Ohai.config[:disabled_plugins]).to eq([ :Foo, :Baz ])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
context
|
89
|
+
context "when the configuration file contains deprecated config options" do
|
90
90
|
# For the purpose of these tests it doesn't matter if the configuration
|
91
91
|
# file was specified via command line or discovered on the local
|
92
92
|
# workstation. It's easier if we pass the configuration file as a cli
|
93
93
|
# argument (there's less to stub).
|
94
94
|
|
95
|
-
let(:argv) { [
|
95
|
+
let(:argv) { [ "-c", config_location ] }
|
96
96
|
|
97
97
|
let(:config_content) do
|
98
98
|
<<-CONFIG
|
@@ -108,11 +108,11 @@ CONFIG
|
|
108
108
|
|
109
109
|
let(:log_level) { :debug }
|
110
110
|
|
111
|
-
let(:log_location) {
|
111
|
+
let(:log_location) { "path/to/log" }
|
112
112
|
|
113
|
-
let(:plugin_path) {
|
113
|
+
let(:plugin_path) { "/path/to/plugins" }
|
114
114
|
|
115
|
-
it
|
115
|
+
it "logs warnings for deprecated top-level options" do
|
116
116
|
# deprecation warnings for options need to be stubbed in the order
|
117
117
|
# they are received, in this case it's the order they appear in the
|
118
118
|
# configuration file.
|
@@ -125,17 +125,17 @@ CONFIG
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
context
|
128
|
+
context "when the configuration file has a syntax error" do
|
129
129
|
# For the purpose of these tests it doesn't matter if the configuration
|
130
130
|
# file was specified via command line or discovered on the local
|
131
131
|
# workstation. It's easier if we pass the configuration file as a cli
|
132
132
|
# argument (there's less to stub).
|
133
133
|
|
134
|
-
let(:argv) { [
|
134
|
+
let(:argv) { [ "-c", config_location ] }
|
135
135
|
|
136
136
|
let(:config_content) { 'config_location "blaaaaa' }
|
137
137
|
|
138
|
-
it
|
138
|
+
it "logs an error and terminates the application" do
|
139
139
|
expect(STDERR).to receive(:puts).with(/FATAL:/)
|
140
140
|
expect(Ohai::Log).to receive(:fatal).
|
141
141
|
with(/You have invalid ruby syntax in your config file/)
|
@@ -16,16 +16,16 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require File.expand_path(File.dirname(__FILE__) +
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
|
20
20
|
|
21
|
-
describe Ohai::System,
|
21
|
+
describe Ohai::System, "languages plugin" do
|
22
22
|
VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/
|
23
|
-
describe
|
23
|
+
describe "powershell plugin", :windows_only do
|
24
24
|
RSpec.shared_examples "a version looking thing" do
|
25
|
-
it
|
25
|
+
it "should be present" do
|
26
26
|
expect(subject).not_to be_nil
|
27
27
|
end
|
28
|
-
it
|
28
|
+
it "should look like a version" do
|
29
29
|
expect(subject).to match(VERSION_MATCHING_REGEX)
|
30
30
|
end
|
31
31
|
end
|
@@ -37,42 +37,42 @@ describe Ohai::System, 'languages plugin' do
|
|
37
37
|
|
38
38
|
subject { @plugin[:languages][:powershell] }
|
39
39
|
|
40
|
-
it
|
40
|
+
it "should have information about powershell" do
|
41
41
|
expect(subject).not_to be_nil
|
42
42
|
end
|
43
43
|
|
44
44
|
describe :version do
|
45
45
|
subject { @plugin.languages[:powershell][described_class] }
|
46
|
-
it_behaves_like
|
46
|
+
it_behaves_like "a version looking thing"
|
47
47
|
end
|
48
48
|
|
49
49
|
describe :ws_man_stack_version do
|
50
50
|
subject { @plugin.languages[:powershell][described_class] }
|
51
|
-
it_behaves_like
|
51
|
+
it_behaves_like "a version looking thing"
|
52
52
|
end
|
53
53
|
|
54
54
|
describe :serialization_version do
|
55
55
|
subject { @plugin.languages[:powershell][described_class] }
|
56
|
-
it_behaves_like
|
56
|
+
it_behaves_like "a version looking thing"
|
57
57
|
end
|
58
58
|
|
59
59
|
describe :clr_version do
|
60
60
|
subject { @plugin.languages[:powershell][described_class] }
|
61
|
-
it_behaves_like
|
61
|
+
it_behaves_like "a version looking thing"
|
62
62
|
end
|
63
63
|
|
64
64
|
describe :build_version do
|
65
65
|
subject { @plugin.languages[:powershell][described_class] }
|
66
|
-
it_behaves_like
|
66
|
+
it_behaves_like "a version looking thing"
|
67
67
|
end
|
68
68
|
|
69
69
|
describe :remoting_protocol_version do
|
70
70
|
subject { @plugin.languages[:powershell][described_class] }
|
71
|
-
it_behaves_like
|
71
|
+
it_behaves_like "a version looking thing"
|
72
72
|
end
|
73
73
|
|
74
74
|
describe :compatible_versions do
|
75
|
-
it
|
75
|
+
it "has compatible_versions that look like versions" do
|
76
76
|
@plugin.languages[:powershell][described_class].each do |version|
|
77
77
|
expect(version).to match(VERSION_MATCHING_REGEX)
|
78
78
|
end
|