ohai 16.5.6 → 16.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/lib/ohai/application.rb +39 -0
- data/lib/ohai/common/dmi.rb +7 -3
- data/lib/ohai/dsl/plugin.rb +7 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +27 -15
- data/lib/ohai/mixin/chef_utils_wiring.rb +13 -1
- data/lib/ohai/mixin/os.rb +66 -1
- data/lib/ohai/mixin/train_helpers.rb +35 -0
- data/lib/ohai/plugins/azure.rb +24 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/cpu.rb +4 -4
- data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
- data/lib/ohai/plugins/dmi.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +13 -7
- data/lib/ohai/plugins/filesystem.rb +3 -3
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/joyent.rb +2 -2
- data/lib/ohai/plugins/kernel.rb +7 -3
- data/lib/ohai/plugins/linux/block_device.rb +8 -8
- data/lib/ohai/plugins/linux/interrupts.rb +3 -3
- data/lib/ohai/plugins/linux/lsb.rb +3 -3
- data/lib/ohai/plugins/linux/machineid.rb +4 -4
- data/lib/ohai/plugins/linux/mdadm.rb +2 -2
- data/lib/ohai/plugins/linux/memory.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +3 -3
- data/lib/ohai/plugins/linux/platform.rb +29 -29
- data/lib/ohai/plugins/linux/virtualization.rb +23 -23
- data/lib/ohai/plugins/ohai_time.rb +1 -1
- data/lib/ohai/plugins/os.rb +4 -0
- data/lib/ohai/plugins/passwd.rb +57 -1
- data/lib/ohai/plugins/scaleway.rb +1 -1
- data/lib/ohai/plugins/shells.rb +2 -2
- data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
- data/lib/ohai/plugins/solaris2/platform.rb +2 -2
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +12 -12
- data/lib/ohai/plugins/train.rb +35 -0
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +1 -1
- data/lib/ohai/runner.rb +4 -0
- data/lib/ohai/system.rb +32 -4
- data/lib/ohai/train_transport.rb +28 -0
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -1
- metadata +20 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86cf0dbd863325b1c5104d78cb1b848d924bfc1c67375df2f42d4cc855cccf1a
|
|
4
|
+
data.tar.gz: 20131622886b909b75708612f8340e59366f9d74b109f4f4176e34b6578f750c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 142be9e566d266d83e0561a662e5170c5d4b497d044279b51360393c9956004a4217ef5a3151d93f139fcd30fd9c6c07c35c9dde5d4e8b53c6b91532d3b884ce
|
|
7
|
+
data.tar.gz: 30d6872cb01724ae5bc88f1f65aa7b5693a47502be8f94492c28367c8408cd1fe82278efd1dc3e70ff9cbb83ea9ba9bd74ff4be2a850c9bf764b33c17d19297a
|
data/Gemfile
CHANGED
|
@@ -2,6 +2,10 @@ source "https://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
+
# pull these gems from master of chef/chef so that we're testing against what we will release
|
|
6
|
+
gem "chef-config", git: "https://github.com/chef/chef", glob: "chef-config/chef-config.gemspec"
|
|
7
|
+
gem "chef-utils", git: "https://github.com/chef/chef", glob: "chef-utils/chef-utils.gemspec"
|
|
8
|
+
|
|
5
9
|
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
|
|
6
10
|
group :development do
|
|
7
11
|
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
data/lib/ohai/application.rb
CHANGED
|
@@ -56,6 +56,15 @@ class Ohai::Application
|
|
|
56
56
|
description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
|
|
57
57
|
proc: nil
|
|
58
58
|
|
|
59
|
+
option :target,
|
|
60
|
+
short: "-t TARGET",
|
|
61
|
+
long: "--target TARGET",
|
|
62
|
+
description: "Target Ohai against a remote system or device",
|
|
63
|
+
proc: lambda { |target|
|
|
64
|
+
Ohai::Log.warn "-- EXPERIMENTAL -- Target mode activated -- EXPERIMENTAL --"
|
|
65
|
+
target
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
option :help,
|
|
60
69
|
short: "-h",
|
|
61
70
|
long: "--help",
|
|
@@ -93,9 +102,39 @@ class Ohai::Application
|
|
|
93
102
|
|
|
94
103
|
load_workstation_config
|
|
95
104
|
|
|
105
|
+
merge_configs
|
|
106
|
+
|
|
107
|
+
if config[:target]
|
|
108
|
+
Ohai::Config.target_mode.host = config[:target]
|
|
109
|
+
if URI.parse(Ohai::Config.target_mode.host).scheme
|
|
110
|
+
train_config = Train.unpack_target_from_uri(Ohai::Config.target_mode.host)
|
|
111
|
+
Ohai::Config.target_mode = train_config
|
|
112
|
+
end
|
|
113
|
+
Ohai::Config.target_mode.enabled = true
|
|
114
|
+
Ohai::Config.node_name = Ohai::Config.target_mode.host unless Ohai::Config.node_name
|
|
115
|
+
end
|
|
116
|
+
|
|
96
117
|
Ohai::Log.init(Ohai.config[:log_location])
|
|
97
118
|
end
|
|
98
119
|
|
|
120
|
+
# @api private
|
|
121
|
+
def config_file_defaults
|
|
122
|
+
Ohai::Config.save(true)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @api private
|
|
126
|
+
def config_file_settings
|
|
127
|
+
Ohai::Config.save(false)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# See lib/chef/knife.rb in the chef/chef github repo
|
|
131
|
+
#
|
|
132
|
+
# @api private
|
|
133
|
+
def merge_configs
|
|
134
|
+
config.replace(config_file_defaults.merge(default_config).merge(config_file_settings).merge(config))
|
|
135
|
+
Ohai::Config.merge!(config) # make them both the same
|
|
136
|
+
end
|
|
137
|
+
|
|
99
138
|
# Passes config and attributes arguments to Ohai::System then prints the results.
|
|
100
139
|
# Called by the run method after config / logging have been initialized
|
|
101
140
|
#
|
data/lib/ohai/common/dmi.rb
CHANGED
|
@@ -76,11 +76,11 @@ module Ohai
|
|
|
76
76
|
# away some of the less useful IDs
|
|
77
77
|
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze
|
|
78
78
|
|
|
79
|
-
# the
|
|
79
|
+
# the allowlisted DMI IDs. This is combination of the defaults + any additional
|
|
80
80
|
# IDs defined in the :additional_dmi_ids config
|
|
81
81
|
#
|
|
82
82
|
# @return [Array] the list of DMI IDs to capture
|
|
83
|
-
def
|
|
83
|
+
def allowlisted_ids
|
|
84
84
|
if Ohai.config[:additional_dmi_ids]
|
|
85
85
|
if [ Integer, Array ].include?(Ohai.config[:additional_dmi_ids].class)
|
|
86
86
|
return ID_TO_CAPTURE + Array(Ohai.config[:additional_dmi_ids])
|
|
@@ -91,6 +91,10 @@ module Ohai
|
|
|
91
91
|
ID_TO_CAPTURE
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
##
|
|
95
|
+
# @deprecated Use the `allowlisted_ids` method instead.
|
|
96
|
+
alias whitelisted_ids allowlisted_ids
|
|
97
|
+
|
|
94
98
|
# the human readable description from a DMI ID
|
|
95
99
|
#
|
|
96
100
|
# @param id [String, Integer] the ID to lookup
|
|
@@ -152,7 +156,7 @@ module Ohai
|
|
|
152
156
|
end
|
|
153
157
|
end
|
|
154
158
|
|
|
155
|
-
module_function :id_lookup, :convenience_keys, :whitelisted_ids
|
|
159
|
+
module_function :id_lookup, :convenience_keys, :allowlisted_ids, :whitelisted_ids
|
|
156
160
|
end
|
|
157
161
|
end
|
|
158
162
|
end
|
data/lib/ohai/dsl/plugin.rb
CHANGED
|
@@ -22,6 +22,7 @@ require_relative "../mixin/os"
|
|
|
22
22
|
require_relative "../mixin/shell_out"
|
|
23
23
|
require_relative "../mixin/seconds_to_human"
|
|
24
24
|
require_relative "../mixin/which"
|
|
25
|
+
require_relative "../mixin/train_helpers"
|
|
25
26
|
require_relative "../hints"
|
|
26
27
|
|
|
27
28
|
module Ohai
|
|
@@ -86,10 +87,12 @@ module Ohai
|
|
|
86
87
|
include Ohai::Mixin::ShellOut
|
|
87
88
|
include Ohai::Mixin::SecondsToHuman
|
|
88
89
|
include Ohai::Mixin::Which
|
|
90
|
+
include Ohai::Mixin::TrainHelpers
|
|
89
91
|
|
|
90
92
|
attr_reader :data
|
|
91
93
|
attr_reader :failed
|
|
92
94
|
attr_reader :logger
|
|
95
|
+
attr_accessor :transport_connection
|
|
93
96
|
|
|
94
97
|
def initialize(data, logger)
|
|
95
98
|
@data = data
|
|
@@ -98,6 +101,10 @@ module Ohai
|
|
|
98
101
|
@failed = false
|
|
99
102
|
end
|
|
100
103
|
|
|
104
|
+
def target_mode?
|
|
105
|
+
!!@transport_connection
|
|
106
|
+
end
|
|
107
|
+
|
|
101
108
|
def run
|
|
102
109
|
@has_run = true
|
|
103
110
|
|
|
@@ -46,7 +46,8 @@ module Ohai
|
|
|
46
46
|
:version7
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
#
|
|
49
|
+
# The source of the plugin on disk. This is an array since a plugin may exist for multiple
|
|
50
|
+
# oses and this would include each of those os specific file paths
|
|
50
51
|
#
|
|
51
52
|
# @return [Array]
|
|
52
53
|
def self.sources
|
|
@@ -61,7 +62,7 @@ module Ohai
|
|
|
61
62
|
@depends_attrs ||= []
|
|
62
63
|
end
|
|
63
64
|
|
|
64
|
-
# A block per
|
|
65
|
+
# A block per os for actually performing data collection constructed
|
|
65
66
|
# by the collect_data method
|
|
66
67
|
#
|
|
67
68
|
# @return [Mash]
|
|
@@ -101,15 +102,16 @@ module Ohai
|
|
|
101
102
|
!!@optional
|
|
102
103
|
end
|
|
103
104
|
|
|
104
|
-
# define data collection methodology per
|
|
105
|
+
# define data collection methodology per os
|
|
105
106
|
#
|
|
106
|
-
# @param
|
|
107
|
-
# @param
|
|
108
|
-
#
|
|
109
|
-
def self.collect_data(
|
|
110
|
-
[
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
# @param os [Array<Symbol>] the list of oses to collect data for
|
|
108
|
+
# @param block [block] the actual code to collect data for the specified os
|
|
109
|
+
#
|
|
110
|
+
def self.collect_data(*os_list, &block)
|
|
111
|
+
os_list = [ :default ] if os_list.empty?
|
|
112
|
+
os_list.flatten.each do |os|
|
|
113
|
+
Ohai::Log.warn("collect_data already defined on os '#{os}' for #{self}, last plugin seen will be used") if data_collector.key?(os)
|
|
114
|
+
data_collector[os] = block
|
|
113
115
|
end
|
|
114
116
|
end
|
|
115
117
|
|
|
@@ -120,12 +122,22 @@ module Ohai
|
|
|
120
122
|
|
|
121
123
|
def run_plugin
|
|
122
124
|
collector = self.class.data_collector
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
os = collect_os
|
|
126
|
+
|
|
127
|
+
# :default - means any remote or local unix or windows host
|
|
128
|
+
# :target - means any remote API which is not unix/windows or otherwise rubyable (cisco switches, IPMI console, HTTP API, etc)
|
|
129
|
+
#
|
|
130
|
+
# Do not be confused by the fact that collectors tagged :target do not run against e.g. target-mode ubuntu boxes, that is not
|
|
131
|
+
# what :target is intended for. Also, do not be confused by the fact that collectors tagged :default do not run by default against
|
|
132
|
+
# pure-target mode targets like switches. That is all intended behavior, the names are problematic. The :default nomenclature was
|
|
133
|
+
# invented 10 years before target mode and we are stuck with it.
|
|
134
|
+
#
|
|
135
|
+
if collector.key?(os)
|
|
136
|
+
instance_eval(&collector[os])
|
|
137
|
+
elsif collector.key?(:default) && !nonruby_target?
|
|
128
138
|
instance_eval(&collector[:default])
|
|
139
|
+
elsif collector.key?(:target) && nonruby_target?
|
|
140
|
+
instance_eval(&collector[:target])
|
|
129
141
|
else
|
|
130
142
|
logger.trace("Plugin #{name}: No data to collect. Skipping...")
|
|
131
143
|
end
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
require_relative "../config"
|
|
19
|
+
require "singleton" unless defined?(Singleton)
|
|
19
20
|
|
|
20
21
|
module Ohai
|
|
21
22
|
module Mixin
|
|
@@ -32,7 +33,18 @@ module Ohai
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def __transport_connection
|
|
35
|
-
|
|
36
|
+
transport_connection
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# because of target mode we cache the PATH to avoid massive amounts of `echo $PATH` remote queries
|
|
40
|
+
#
|
|
41
|
+
def __env_path
|
|
42
|
+
PathCache.instance.path_cache ||= super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class PathCache
|
|
46
|
+
include Singleton
|
|
47
|
+
attr_accessor :path_cache
|
|
36
48
|
end
|
|
37
49
|
end
|
|
38
50
|
end
|
data/lib/ohai/mixin/os.rb
CHANGED
|
@@ -27,6 +27,71 @@ module Ohai
|
|
|
27
27
|
#
|
|
28
28
|
# @return [String] the OS
|
|
29
29
|
def collect_os
|
|
30
|
+
if target_mode?
|
|
31
|
+
collect_os_target
|
|
32
|
+
else
|
|
33
|
+
collect_os_local
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# This should exactly preserve the semantics of collect_os_local below, which is authoritative
|
|
38
|
+
# for the API and must adhere to pre-existing ohai semantics and not follow inspec's notion of
|
|
39
|
+
# os/family/hierarchy.
|
|
40
|
+
#
|
|
41
|
+
# Right or wrong the ohai `os` variable has matched the ruby `host_os` definition for the past
|
|
42
|
+
# 10+ years, preceding inspec/train's definitions and this is the documented correct API of
|
|
43
|
+
# these methods. Mismatches between the ruby notion and the train version will be fixed as
|
|
44
|
+
# bugfixes in these methods and may not be considered semver violating even though they make
|
|
45
|
+
# break downstream consumers. Please ensure that both methods produce the same results if
|
|
46
|
+
# you are on a platform which supports running ruby (train is considered authoritative for
|
|
47
|
+
# any "OS" which cannot run ruby -- server consoles, REST APIs, etc...)
|
|
48
|
+
#
|
|
49
|
+
# @api private
|
|
50
|
+
def collect_os_target
|
|
51
|
+
case
|
|
52
|
+
when transport_connection.os.aix?
|
|
53
|
+
"aix"
|
|
54
|
+
when transport_connection.os.darwin?
|
|
55
|
+
"darwin"
|
|
56
|
+
when transport_connection.os.linux?
|
|
57
|
+
"linux"
|
|
58
|
+
when transport_connection.os.family == "freebsd"
|
|
59
|
+
"freebsd"
|
|
60
|
+
when transport_connection.os.family == "openbsd"
|
|
61
|
+
"openbsd"
|
|
62
|
+
when transport_connection.os.family == "netbsd"
|
|
63
|
+
"netbsd"
|
|
64
|
+
when transport_connection.os.family == "dragonflybsd"
|
|
65
|
+
"dragonflybsd"
|
|
66
|
+
when transport_connection.os.solaris?
|
|
67
|
+
"solaris2"
|
|
68
|
+
when transport_connection.os.windows?
|
|
69
|
+
"windows"
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# The purpose of the next two lines is that anything which runs Unix is presumed to be able to run ruby, and
|
|
73
|
+
# if it was not caught above, we MUST translate whatever train uses as the 'os' into the proper ruby host_os
|
|
74
|
+
# string. If it is not unix and not caught above we assume it is something like a REST API which cannot run
|
|
75
|
+
# ruby. If these assumptions are incorrect then it is a bug, which should be submitted to fix it, and the
|
|
76
|
+
# values should not be relied upon until that bug is fixed. The train os is NEVER considered authoritative
|
|
77
|
+
# for any target which can run ruby.
|
|
78
|
+
#
|
|
79
|
+
when transport_connection.os.unix?
|
|
80
|
+
raise "Target mode unsupported on this Unix-like host, please update the collect_os_target case statement with the correct ruby host_os value."
|
|
81
|
+
else
|
|
82
|
+
# now we have something like an IPMI console that isn't Unix-like or Windows, presumably cannot run ruby, and
|
|
83
|
+
# so we just trust the train O/S information.
|
|
84
|
+
transport_connection.os
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @api private
|
|
89
|
+
def nonruby_target?
|
|
90
|
+
transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @api private
|
|
94
|
+
def collect_os_local
|
|
30
95
|
case ::RbConfig::CONFIG["host_os"]
|
|
31
96
|
when /aix(.+)$/
|
|
32
97
|
"aix"
|
|
@@ -56,7 +121,7 @@ module Ohai
|
|
|
56
121
|
end
|
|
57
122
|
end
|
|
58
123
|
|
|
59
|
-
|
|
124
|
+
extend self
|
|
60
125
|
end
|
|
61
126
|
end
|
|
62
127
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require "chef-utils/dsl/train_helpers" unless defined?(ChefUtils::DSL::TrainHelpers)
|
|
18
|
+
require_relative "chef_utils_wiring" unless defined?(Ohai::Mixin::ChefUtilsWiring)
|
|
19
|
+
|
|
20
|
+
module Ohai
|
|
21
|
+
module Mixin
|
|
22
|
+
module TrainHelpers
|
|
23
|
+
include ChefUtils::DSL::TrainHelpers
|
|
24
|
+
include ChefUtilsWiring
|
|
25
|
+
|
|
26
|
+
# anything added to this file temporarily should be pushed back up
|
|
27
|
+
# into ChefUtils::DSL::TrainHelpers
|
|
28
|
+
|
|
29
|
+
# XXX: this needs better support directly in train
|
|
30
|
+
def dir_glob(path)
|
|
31
|
+
shell_out!("ls -d #{path}").stdout.split
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/ohai/plugins/azure.rb
CHANGED
|
@@ -34,7 +34,7 @@ Ohai.plugin(:Azure) do
|
|
|
34
34
|
azure Mash.new
|
|
35
35
|
azure_metadata_from_hints.each { |k, v| azure[k] = v }
|
|
36
36
|
azure["metadata"] = parse_metadata
|
|
37
|
-
elsif has_waagent? || has_dhcp_option_245?
|
|
37
|
+
elsif has_waagent? || has_dhcp_option_245? || has_reddog_dhcp_domain?
|
|
38
38
|
logger.trace("Plugin Azure: No hints present, but system appears to be on Azure.")
|
|
39
39
|
azure Mash.new
|
|
40
40
|
azure["metadata"] = parse_metadata
|
|
@@ -47,7 +47,7 @@ Ohai.plugin(:Azure) do
|
|
|
47
47
|
# check for either the waagent or the unknown-245 DHCP option that Azure uses
|
|
48
48
|
# http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/
|
|
49
49
|
def has_waagent?
|
|
50
|
-
if
|
|
50
|
+
if file_exist?("/usr/sbin/waagent") || dir_exist?('C:\WindowsAzure')
|
|
51
51
|
logger.trace("Plugin Azure: Found waagent used by Azure.")
|
|
52
52
|
true
|
|
53
53
|
end
|
|
@@ -55,8 +55,8 @@ Ohai.plugin(:Azure) do
|
|
|
55
55
|
|
|
56
56
|
def has_dhcp_option_245?
|
|
57
57
|
has_245 = false
|
|
58
|
-
if
|
|
59
|
-
|
|
58
|
+
if file_exist?("/var/lib/dhcp/dhclient.eth0.leases")
|
|
59
|
+
file_open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
|
|
60
60
|
if /unknown-245/.match?(line)
|
|
61
61
|
logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
|
|
62
62
|
has_245 = true
|
|
@@ -67,6 +67,26 @@ Ohai.plugin(:Azure) do
|
|
|
67
67
|
has_245
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
def has_reddog_dhcp_domain?
|
|
71
|
+
tcp_ip_dhcp_domain == "reddog.microsoft.com"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def tcp_ip_dhcp_domain
|
|
75
|
+
return unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
|
76
|
+
|
|
77
|
+
require "win32/registry" unless defined?(Win32::Registry)
|
|
78
|
+
|
|
79
|
+
begin
|
|
80
|
+
key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters")
|
|
81
|
+
dhcp_domain = key["DhcpDomain"]
|
|
82
|
+
Ohai::Log.trace("Plugin Azure: DhcpDomain registry value is #{dhcp_domain}")
|
|
83
|
+
rescue Win32::Registry::Error
|
|
84
|
+
Ohai::Log.trace("Plugin Azure: DhcpDomain registry value cannot be found")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
dhcp_domain
|
|
88
|
+
end
|
|
89
|
+
|
|
70
90
|
# create the basic structure we'll store our data in
|
|
71
91
|
def initialize_metadata_mash_compute
|
|
72
92
|
metadata = Mash.new
|
data/lib/ohai/plugins/chef.rb
CHANGED
data/lib/ohai/plugins/cpu.rb
CHANGED
|
@@ -30,7 +30,7 @@ Ohai.plugin(:CPU) do
|
|
|
30
30
|
def parse_bsd_dmesg(&block)
|
|
31
31
|
cpuinfo = Mash.new
|
|
32
32
|
cpuinfo["flags"] = []
|
|
33
|
-
|
|
33
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
|
34
34
|
case line
|
|
35
35
|
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
|
36
36
|
cpuinfo["model_name"] = $1
|
|
@@ -53,7 +53,7 @@ Ohai.plugin(:CPU) do
|
|
|
53
53
|
cpu_number = 0
|
|
54
54
|
current_cpu = nil
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
file_open("/proc/cpuinfo").each do |line|
|
|
57
57
|
case line
|
|
58
58
|
when /processor\s+:\s(.+)/
|
|
59
59
|
cpuinfo[$1] = Mash.new
|
|
@@ -212,7 +212,7 @@ Ohai.plugin(:CPU) do
|
|
|
212
212
|
# to scrape from dmesg.boot is the cpu feature list.
|
|
213
213
|
# cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
|
216
216
|
case line
|
|
217
217
|
when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
|
|
218
218
|
cpuinfo["flags"] = $1.downcase.split(",")
|
|
@@ -235,7 +235,7 @@ Ohai.plugin(:CPU) do
|
|
|
235
235
|
# available instruction set
|
|
236
236
|
# cpu0 at mainbus0 apid 0: Intel 686-class, 2134MHz, id 0x6f6
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
|
239
239
|
case line
|
|
240
240
|
when /cpu[\d\w\s]+:\s([\w\s\-]+),\s+(\w+),/
|
|
241
241
|
cpuinfo[:model_name] = $1
|