ohai 18.2.6 → 19.0.3
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 +28 -28
- data/LICENSE +201 -201
- data/bin/ohai +25 -25
- data/lib/ohai/application.rb +189 -189
- data/lib/ohai/common/dmi.rb +167 -167
- data/lib/ohai/config.rb +51 -51
- data/lib/ohai/dsl/plugin/versionvii.rb +203 -203
- data/lib/ohai/dsl/plugin.rb +232 -232
- data/lib/ohai/dsl.rb +22 -22
- data/lib/ohai/exception.rb +36 -36
- data/lib/ohai/hints.rb +68 -68
- data/lib/ohai/loader.rb +178 -178
- data/lib/ohai/log.rb +34 -34
- data/lib/ohai/mash.rb +22 -22
- data/lib/ohai/mixin/alibaba_metadata.rb +83 -83
- data/lib/ohai/mixin/azure_metadata.rb +105 -105
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -52
- data/lib/ohai/mixin/command.rb +4 -4
- data/lib/ohai/mixin/constant_helper.rb +55 -55
- data/lib/ohai/mixin/dmi_decode.rb +54 -54
- data/lib/ohai/mixin/do_metadata.rb +48 -48
- data/lib/ohai/mixin/ec2_metadata.rb +264 -270
- data/lib/ohai/mixin/gce_metadata.rb +79 -79
- data/lib/ohai/mixin/http_helper.rb +64 -64
- data/lib/ohai/mixin/json_helper.rb +36 -36
- data/lib/ohai/mixin/network_helper.rb +92 -92
- data/lib/ohai/mixin/oci_metadata.rb +60 -60
- data/lib/ohai/mixin/os.rb +128 -128
- data/lib/ohai/mixin/scaleway_metadata.rb +51 -51
- data/lib/ohai/mixin/seconds_to_human.rb +52 -52
- data/lib/ohai/mixin/shell_out.rb +51 -51
- data/lib/ohai/mixin/softlayer_metadata.rb +74 -74
- data/lib/ohai/mixin/string.rb +31 -31
- data/lib/ohai/mixin/train_helpers.rb +36 -36
- data/lib/ohai/mixin/which.rb +39 -39
- data/lib/ohai/plugin_config.rb +47 -47
- data/lib/ohai/plugins/aix/kernel.rb +50 -50
- data/lib/ohai/plugins/aix/memory.rb +37 -37
- data/lib/ohai/plugins/aix/network.rb +142 -142
- data/lib/ohai/plugins/aix/platform.rb +30 -30
- data/lib/ohai/plugins/aix/uptime.rb +54 -54
- data/lib/ohai/plugins/aix/virtualization.rb +154 -154
- data/lib/ohai/plugins/alibaba.rb +72 -72
- data/lib/ohai/plugins/azure.rb +154 -154
- data/lib/ohai/plugins/bsd/virtualization.rb +121 -121
- data/lib/ohai/plugins/c.rb +178 -178
- data/lib/ohai/plugins/chef.rb +50 -50
- data/lib/ohai/plugins/cloud.rb +379 -379
- data/lib/ohai/plugins/command.rb +26 -26
- data/lib/ohai/plugins/cpu.rb +642 -642
- data/lib/ohai/plugins/darwin/hardware.rb +99 -99
- data/lib/ohai/plugins/darwin/memory.rb +62 -62
- data/lib/ohai/plugins/darwin/network.rb +207 -207
- data/lib/ohai/plugins/darwin/platform.rb +40 -40
- data/lib/ohai/plugins/darwin/virtualization.rb +104 -104
- data/lib/ohai/plugins/digital_ocean.rb +67 -67
- data/lib/ohai/plugins/dmi.rb +134 -134
- data/lib/ohai/plugins/docker.rb +58 -58
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -60
- data/lib/ohai/plugins/dragonflybsd/network.rb +128 -128
- data/lib/ohai/plugins/dragonflybsd/platform.rb +28 -28
- data/lib/ohai/plugins/ec2.rb +148 -148
- data/lib/ohai/plugins/elixir.rb +36 -36
- data/lib/ohai/plugins/erlang.rb +60 -60
- data/lib/ohai/plugins/eucalyptus.rb +86 -86
- data/lib/ohai/plugins/filesystem.rb +753 -753
- data/lib/ohai/plugins/fips.rb +36 -36
- data/lib/ohai/plugins/freebsd/memory.rb +60 -60
- data/lib/ohai/plugins/freebsd/network.rb +128 -128
- data/lib/ohai/plugins/freebsd/platform.rb +28 -28
- data/lib/ohai/plugins/gce.rb +89 -89
- data/lib/ohai/plugins/go.rb +34 -34
- data/lib/ohai/plugins/groovy.rb +38 -38
- data/lib/ohai/plugins/grub2.rb +40 -40
- data/lib/ohai/plugins/habitat.rb +73 -73
- data/lib/ohai/plugins/haskell.rb +96 -96
- data/lib/ohai/plugins/hostname.rb +133 -133
- data/lib/ohai/plugins/init_package.rb +26 -26
- data/lib/ohai/plugins/java.rb +78 -78
- data/lib/ohai/plugins/kernel.rb +292 -292
- data/lib/ohai/plugins/keys.rb +27 -27
- data/lib/ohai/plugins/languages.rb +26 -26
- data/lib/ohai/plugins/libvirt.rb +114 -114
- data/lib/ohai/plugins/linode.rb +73 -73
- data/lib/ohai/plugins/linux/block_device.rb +48 -48
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -34
- data/lib/ohai/plugins/linux/interrupts.rb +84 -83
- data/lib/ohai/plugins/linux/ipc.rb +52 -52
- data/lib/ohai/plugins/linux/livepatch.rb +38 -38
- data/lib/ohai/plugins/linux/lsb.rb +46 -46
- data/lib/ohai/plugins/linux/lspci.rb +80 -80
- data/lib/ohai/plugins/linux/machineid.rb +36 -36
- data/lib/ohai/plugins/linux/mdadm.rb +120 -120
- data/lib/ohai/plugins/linux/memory.rb +106 -106
- data/lib/ohai/plugins/linux/network.rb +879 -879
- data/lib/ohai/plugins/linux/os_release.rb +38 -38
- data/lib/ohai/plugins/linux/platform.rb +314 -314
- data/lib/ohai/plugins/linux/selinux.rb +69 -69
- data/lib/ohai/plugins/linux/sessions.rb +54 -54
- data/lib/ohai/plugins/linux/sysctl.rb +39 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +36 -36
- data/lib/ohai/plugins/linux/tc.rb +61 -61
- data/lib/ohai/plugins/linux/virtualization.rb +300 -300
- data/lib/ohai/plugins/lua.rb +39 -39
- data/lib/ohai/plugins/mono.rb +50 -50
- data/lib/ohai/plugins/netbsd/memory.rb +99 -99
- data/lib/ohai/plugins/netbsd/network.rb +122 -122
- data/lib/ohai/plugins/netbsd/platform.rb +28 -28
- data/lib/ohai/plugins/network.rb +186 -186
- data/lib/ohai/plugins/nodejs.rb +40 -40
- data/lib/ohai/plugins/oci.rb +94 -94
- data/lib/ohai/plugins/ohai.rb +29 -29
- data/lib/ohai/plugins/ohai_time.rb +26 -26
- data/lib/ohai/plugins/openbsd/memory.rb +99 -99
- data/lib/ohai/plugins/openbsd/network.rb +122 -122
- data/lib/ohai/plugins/openbsd/platform.rb +28 -28
- data/lib/ohai/plugins/openstack.rb +84 -84
- data/lib/ohai/plugins/os.rb +55 -55
- data/lib/ohai/plugins/packages.rb +234 -234
- data/lib/ohai/plugins/passwd.rb +104 -104
- data/lib/ohai/plugins/perl.rb +45 -45
- data/lib/ohai/plugins/php.rb +52 -52
- data/lib/ohai/plugins/platform.rb +41 -41
- data/lib/ohai/plugins/powershell.rb +82 -82
- data/lib/ohai/plugins/ps.rb +35 -35
- data/lib/ohai/plugins/python.rb +43 -43
- data/lib/ohai/plugins/rackspace.rb +177 -177
- data/lib/ohai/plugins/root_group.rb +41 -41
- data/lib/ohai/plugins/rpm.rb +121 -121
- data/lib/ohai/plugins/ruby.rb +66 -66
- data/lib/ohai/plugins/rust.rb +34 -34
- data/lib/ohai/plugins/scala.rb +38 -38
- data/lib/ohai/plugins/scaleway.rb +58 -58
- data/lib/ohai/plugins/scsi.rb +52 -52
- data/lib/ohai/plugins/shard.rb +142 -142
- data/lib/ohai/plugins/shells.rb +32 -32
- data/lib/ohai/plugins/softlayer.rb +48 -48
- data/lib/ohai/plugins/solaris2/dmi.rb +191 -191
- data/lib/ohai/plugins/solaris2/memory.rb +32 -32
- data/lib/ohai/plugins/solaris2/network.rb +192 -192
- data/lib/ohai/plugins/solaris2/platform.rb +58 -58
- data/lib/ohai/plugins/solaris2/virtualization.rb +90 -90
- data/lib/ohai/plugins/ssh_host_key.rb +84 -84
- data/lib/ohai/plugins/sysconf.rb +46 -46
- data/lib/ohai/plugins/timezone.rb +45 -45
- data/lib/ohai/plugins/train.rb +35 -35
- data/lib/ohai/plugins/uptime.rb +95 -95
- data/lib/ohai/plugins/virtualbox.rb +197 -197
- data/lib/ohai/plugins/vmware.rb +109 -109
- data/lib/ohai/plugins/windows/dmi.rb +95 -95
- data/lib/ohai/plugins/windows/drivers.rb +52 -52
- data/lib/ohai/plugins/windows/memory.rb +39 -39
- data/lib/ohai/plugins/windows/network.rb +222 -222
- data/lib/ohai/plugins/windows/platform.rb +34 -34
- data/lib/ohai/plugins/windows/system_enclosure.rb +29 -29
- data/lib/ohai/plugins/windows/virtualization.rb +45 -45
- data/lib/ohai/plugins/zpools.rb +94 -94
- data/lib/ohai/provides_map.rb +208 -208
- data/lib/ohai/runner.rb +128 -126
- data/lib/ohai/system.rb +258 -258
- data/lib/ohai/train_transport.rb +29 -29
- data/lib/ohai/util/file_helper.rb +6 -6
- data/lib/ohai/util/ip_helper.rb +56 -56
- data/lib/ohai/util/win32.rb +47 -47
- data/lib/ohai/version.rb +23 -23
- data/lib/ohai.rb +23 -23
- data/ohai.gemspec +35 -35
- metadata +9 -15
data/lib/ohai/plugins/scsi.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Phil Dibowitz <phil@ipom.com>
|
4
|
-
# Copyright:: Copyright (c) 2018 Facebook, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:Lsscsi) do
|
21
|
-
provides "scsi"
|
22
|
-
optional true
|
23
|
-
|
24
|
-
require "mixlib/shellout" unless defined?(Mixlib::ShellOut::DEFAULT_READ_TIMEOUT)
|
25
|
-
|
26
|
-
collect_data(:linux) do
|
27
|
-
devices = Mash.new
|
28
|
-
lsscsi = shell_out("lsscsi")
|
29
|
-
|
30
|
-
lsscsi.stdout.each_line do |line|
|
31
|
-
line_bits = line.split
|
32
|
-
info = {}
|
33
|
-
|
34
|
-
# The first three fields are consistent...
|
35
|
-
info["scsi_addr"] = line_bits.shift[1..-2]
|
36
|
-
info["type"] = line_bits.shift
|
37
|
-
info["transport"] = line_bits.shift
|
38
|
-
|
39
|
-
# After that the last two are consistent...
|
40
|
-
info["device"] = line_bits.pop
|
41
|
-
info["revision"] = line_bits.pop
|
42
|
-
|
43
|
-
# What"s in the middle is the make and model...
|
44
|
-
# which could have arbitrary spaces
|
45
|
-
info["name"] = line_bits.join(" ")
|
46
|
-
|
47
|
-
devices[info["scsi_addr"]] = info
|
48
|
-
end
|
49
|
-
|
50
|
-
scsi devices
|
51
|
-
end
|
52
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Phil Dibowitz <phil@ipom.com>
|
4
|
+
# Copyright:: Copyright (c) 2018 Facebook, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Lsscsi) do
|
21
|
+
provides "scsi"
|
22
|
+
optional true
|
23
|
+
|
24
|
+
require "mixlib/shellout" unless defined?(Mixlib::ShellOut::DEFAULT_READ_TIMEOUT)
|
25
|
+
|
26
|
+
collect_data(:linux) do
|
27
|
+
devices = Mash.new
|
28
|
+
lsscsi = shell_out("lsscsi")
|
29
|
+
|
30
|
+
lsscsi.stdout.each_line do |line|
|
31
|
+
line_bits = line.split
|
32
|
+
info = {}
|
33
|
+
|
34
|
+
# The first three fields are consistent...
|
35
|
+
info["scsi_addr"] = line_bits.shift[1..-2]
|
36
|
+
info["type"] = line_bits.shift
|
37
|
+
info["transport"] = line_bits.shift
|
38
|
+
|
39
|
+
# After that the last two are consistent...
|
40
|
+
info["device"] = line_bits.pop
|
41
|
+
info["revision"] = line_bits.pop
|
42
|
+
|
43
|
+
# What"s in the middle is the make and model...
|
44
|
+
# which could have arbitrary spaces
|
45
|
+
info["name"] = line_bits.join(" ")
|
46
|
+
|
47
|
+
devices[info["scsi_addr"]] = info
|
48
|
+
end
|
49
|
+
|
50
|
+
scsi devices
|
51
|
+
end
|
52
|
+
end
|
data/lib/ohai/plugins/shard.rb
CHANGED
@@ -1,142 +1,142 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Phil Dibowitz <phil@ipom.com>
|
3
|
-
# Copyright:: Copyright (c) 2016 Facebook, 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
|
-
Ohai.plugin(:ShardSeed) do
|
20
|
-
depends "hostname", "dmi", "machine_id", "machinename", "fips", "hardware", "kernel"
|
21
|
-
provides "shard_seed".freeze
|
22
|
-
|
23
|
-
def get_dmi_property(dmi, thing)
|
24
|
-
%w{system base_board chassis}.each do |section|
|
25
|
-
if dmi[section] && dmi[section][thing] && !dmi[section][thing].strip.empty?
|
26
|
-
return dmi[section][thing]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
Ohai::Log.error("shard_seed: Failed to get dmi property #{thing}: is dmidecode installed?")
|
30
|
-
raise "Failed to generate shard_seed"
|
31
|
-
end
|
32
|
-
|
33
|
-
def default_sources
|
34
|
-
case collect_os
|
35
|
-
when "linux", "darwin", "windows"
|
36
|
-
%i{machinename serial uuid}
|
37
|
-
else
|
38
|
-
[:machinename]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def default_digest_algorithm
|
43
|
-
if fips && fips["kernel"]["enabled"]
|
44
|
-
# Even though it is being used safely, FIPS-mode will still blow up on
|
45
|
-
# any use of MD5 so default to SHA2 instead.
|
46
|
-
"sha256"
|
47
|
-
else
|
48
|
-
"md5"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def digest_algorithm
|
53
|
-
case Ohai.config[:plugin][:shard_seed][:digest_algorithm] || default_digest_algorithm
|
54
|
-
when "md5"
|
55
|
-
require "digest/md5" unless defined?(Digest::MD5)
|
56
|
-
Digest::MD5
|
57
|
-
when "sha256"
|
58
|
-
require "openssl/digest"
|
59
|
-
OpenSSL::Digest::SHA256
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# Common sources go here. Put sources that need to be different per-platform
|
64
|
-
# under their collect_data block.
|
65
|
-
def create_seed(&block)
|
66
|
-
sources = Ohai.config[:plugin][:shard_seed][:sources] || default_sources
|
67
|
-
data = ""
|
68
|
-
sources.each do |src|
|
69
|
-
data << case src
|
70
|
-
when :fqdn
|
71
|
-
fqdn
|
72
|
-
when :hostname
|
73
|
-
hostname
|
74
|
-
when :machine_id
|
75
|
-
machine_id
|
76
|
-
when :machinename
|
77
|
-
machinename
|
78
|
-
else
|
79
|
-
yield(src)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
if data.empty?
|
83
|
-
Ohai::Log.error("shard_seed: Unable to generate seed! Either ensure 'dmidecode' is installed, or use 'Ohai.config[:plugin][:shard_seed][:sources]' to set different sources.")
|
84
|
-
raise "Failed to generate shard_seed"
|
85
|
-
end
|
86
|
-
shard_seed digest_algorithm.hexdigest(data)[0...7].to_i(16)
|
87
|
-
end
|
88
|
-
|
89
|
-
collect_data do
|
90
|
-
create_seed do |src|
|
91
|
-
Ohai::Log.error("shard_seed: No such source #{src}")
|
92
|
-
raise "No such shard_seed source: #{src}"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
collect_data(:windows) do
|
97
|
-
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
98
|
-
wmi = WmiLite::Wmi.new
|
99
|
-
|
100
|
-
create_seed do |src|
|
101
|
-
case src
|
102
|
-
when :serial
|
103
|
-
wmi.first_of("Win32_BIOS")["SerialNumber"]
|
104
|
-
when :os_serial
|
105
|
-
kernel["os_info"]["serial_number"]
|
106
|
-
when :uuid
|
107
|
-
wmi.first_of("Win32_ComputerSystemProduct")["UUID"]
|
108
|
-
else
|
109
|
-
Ohai::Log.error("shard_seed: No such source #{src}")
|
110
|
-
raise "No such shard_seed source: #{src}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
collect_data(:darwin) do
|
116
|
-
create_seed do |src|
|
117
|
-
case src
|
118
|
-
when :serial
|
119
|
-
hardware["serial_number"]
|
120
|
-
when :uuid
|
121
|
-
hardware["platform_UUID"]
|
122
|
-
else
|
123
|
-
Ohai::Log.error("shard_seed: No such source #{src}")
|
124
|
-
raise "No such shard_seed source: #{src}"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
collect_data(:linux) do
|
130
|
-
create_seed do |src|
|
131
|
-
case src
|
132
|
-
when :serial
|
133
|
-
get_dmi_property(dmi, :serial_number)
|
134
|
-
when :uuid
|
135
|
-
get_dmi_property(dmi, :uuid)
|
136
|
-
else
|
137
|
-
Ohai::Log.error("shard_seed: No such source #{src}")
|
138
|
-
raise "No such shard_seed source: #{src}"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Phil Dibowitz <phil@ipom.com>
|
3
|
+
# Copyright:: Copyright (c) 2016 Facebook, 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
|
+
Ohai.plugin(:ShardSeed) do
|
20
|
+
depends "hostname", "dmi", "machine_id", "machinename", "fips", "hardware", "kernel"
|
21
|
+
provides "shard_seed".freeze
|
22
|
+
|
23
|
+
def get_dmi_property(dmi, thing)
|
24
|
+
%w{system base_board chassis}.each do |section|
|
25
|
+
if dmi[section] && dmi[section][thing] && !dmi[section][thing].strip.empty?
|
26
|
+
return dmi[section][thing]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
Ohai::Log.error("shard_seed: Failed to get dmi property #{thing}: is dmidecode installed?")
|
30
|
+
raise "Failed to generate shard_seed"
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_sources
|
34
|
+
case collect_os
|
35
|
+
when "linux", "darwin", "windows"
|
36
|
+
%i{machinename serial uuid}
|
37
|
+
else
|
38
|
+
[:machinename]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_digest_algorithm
|
43
|
+
if fips && fips["kernel"]["enabled"]
|
44
|
+
# Even though it is being used safely, FIPS-mode will still blow up on
|
45
|
+
# any use of MD5 so default to SHA2 instead.
|
46
|
+
"sha256"
|
47
|
+
else
|
48
|
+
"md5"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def digest_algorithm
|
53
|
+
case Ohai.config[:plugin][:shard_seed][:digest_algorithm] || default_digest_algorithm
|
54
|
+
when "md5"
|
55
|
+
require "digest/md5" unless defined?(Digest::MD5)
|
56
|
+
Digest::MD5
|
57
|
+
when "sha256"
|
58
|
+
require "openssl/digest"
|
59
|
+
OpenSSL::Digest::SHA256
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Common sources go here. Put sources that need to be different per-platform
|
64
|
+
# under their collect_data block.
|
65
|
+
def create_seed(&block)
|
66
|
+
sources = Ohai.config[:plugin][:shard_seed][:sources] || default_sources
|
67
|
+
data = ""
|
68
|
+
sources.each do |src|
|
69
|
+
data << case src
|
70
|
+
when :fqdn
|
71
|
+
fqdn
|
72
|
+
when :hostname
|
73
|
+
hostname
|
74
|
+
when :machine_id
|
75
|
+
machine_id
|
76
|
+
when :machinename
|
77
|
+
machinename
|
78
|
+
else
|
79
|
+
yield(src)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if data.empty?
|
83
|
+
Ohai::Log.error("shard_seed: Unable to generate seed! Either ensure 'dmidecode' is installed, or use 'Ohai.config[:plugin][:shard_seed][:sources]' to set different sources.")
|
84
|
+
raise "Failed to generate shard_seed"
|
85
|
+
end
|
86
|
+
shard_seed digest_algorithm.hexdigest(data)[0...7].to_i(16)
|
87
|
+
end
|
88
|
+
|
89
|
+
collect_data do
|
90
|
+
create_seed do |src|
|
91
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
92
|
+
raise "No such shard_seed source: #{src}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
collect_data(:windows) do
|
97
|
+
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
98
|
+
wmi = WmiLite::Wmi.new
|
99
|
+
|
100
|
+
create_seed do |src|
|
101
|
+
case src
|
102
|
+
when :serial
|
103
|
+
wmi.first_of("Win32_BIOS")["SerialNumber"]
|
104
|
+
when :os_serial
|
105
|
+
kernel["os_info"]["serial_number"]
|
106
|
+
when :uuid
|
107
|
+
wmi.first_of("Win32_ComputerSystemProduct")["UUID"]
|
108
|
+
else
|
109
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
110
|
+
raise "No such shard_seed source: #{src}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
collect_data(:darwin) do
|
116
|
+
create_seed do |src|
|
117
|
+
case src
|
118
|
+
when :serial
|
119
|
+
hardware["serial_number"]
|
120
|
+
when :uuid
|
121
|
+
hardware["platform_UUID"]
|
122
|
+
else
|
123
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
124
|
+
raise "No such shard_seed source: #{src}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
collect_data(:linux) do
|
130
|
+
create_seed do |src|
|
131
|
+
case src
|
132
|
+
when :serial
|
133
|
+
get_dmi_property(dmi, :serial_number)
|
134
|
+
when :uuid
|
135
|
+
get_dmi_property(dmi, :uuid)
|
136
|
+
else
|
137
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
138
|
+
raise "No such shard_seed source: #{src}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
data/lib/ohai/plugins/shells.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:Shells) do
|
21
|
-
provides "shells"
|
22
|
-
|
23
|
-
collect_data do
|
24
|
-
if file_exist?("/etc/shells")
|
25
|
-
shells []
|
26
|
-
file_open("/etc/shells").readlines.each do |line|
|
27
|
-
# remove carriage returns and skip over comments / empty lines
|
28
|
-
shells << line.chomp if line[0] == "/"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Shells) do
|
21
|
+
provides "shells"
|
22
|
+
|
23
|
+
collect_data do
|
24
|
+
if file_exist?("/etc/shells")
|
25
|
+
shells []
|
26
|
+
file_open("/etc/shells").readlines.each do |line|
|
27
|
+
# remove carriage returns and skip over comments / empty lines
|
28
|
+
shells << line.chomp if line[0] == "/"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Alexey Karpik <alexey.karpik@rightscale.com>
|
4
|
-
# Author:: Peter Schroeter <peter.schroeter@rightscale.com>
|
5
|
-
# Author:: Stas Turlo <stanislav.turlo@rightscale.com>
|
6
|
-
# Copyright:: Copyright (c) 2010-2014 RightScale Inc
|
7
|
-
# License:: Apache License, Version 2.0
|
8
|
-
#
|
9
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
-
# you may not use this file except in compliance with the License.
|
11
|
-
# You may obtain a copy of the License at
|
12
|
-
#
|
13
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
-
#
|
15
|
-
# Unless required by applicable law or agreed to in writing, software
|
16
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
18
|
-
# implied.
|
19
|
-
# See the License for the specific language governing permissions and
|
20
|
-
# limitations under the License.
|
21
|
-
|
22
|
-
Ohai.plugin(:Softlayer) do
|
23
|
-
require_relative "../mixin/softlayer_metadata"
|
24
|
-
include ::Ohai::Mixin::SoftlayerMetadata
|
25
|
-
|
26
|
-
provides "softlayer"
|
27
|
-
|
28
|
-
# Identifies the softlayer cloud
|
29
|
-
#
|
30
|
-
# === Return
|
31
|
-
# true:: If the softlayer cloud can be identified
|
32
|
-
# false:: Otherwise
|
33
|
-
def looks_like_softlayer?
|
34
|
-
hint?("softlayer")
|
35
|
-
end
|
36
|
-
|
37
|
-
collect_data do
|
38
|
-
# Adds softlayer Mash
|
39
|
-
if looks_like_softlayer?
|
40
|
-
logger.trace("Plugin Softlayer: looks_like_softlayer? == true")
|
41
|
-
metadata = fetch_metadata
|
42
|
-
softlayer Mash.new
|
43
|
-
metadata&.each { |k, v| softlayer[k] = v }
|
44
|
-
else
|
45
|
-
logger.trace("Plugin Softlayer: looks_like_softlayer? == false")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Alexey Karpik <alexey.karpik@rightscale.com>
|
4
|
+
# Author:: Peter Schroeter <peter.schroeter@rightscale.com>
|
5
|
+
# Author:: Stas Turlo <stanislav.turlo@rightscale.com>
|
6
|
+
# Copyright:: Copyright (c) 2010-2014 RightScale Inc
|
7
|
+
# License:: Apache License, Version 2.0
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
18
|
+
# implied.
|
19
|
+
# See the License for the specific language governing permissions and
|
20
|
+
# limitations under the License.
|
21
|
+
|
22
|
+
Ohai.plugin(:Softlayer) do
|
23
|
+
require_relative "../mixin/softlayer_metadata"
|
24
|
+
include ::Ohai::Mixin::SoftlayerMetadata
|
25
|
+
|
26
|
+
provides "softlayer"
|
27
|
+
|
28
|
+
# Identifies the softlayer cloud
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# true:: If the softlayer cloud can be identified
|
32
|
+
# false:: Otherwise
|
33
|
+
def looks_like_softlayer?
|
34
|
+
hint?("softlayer")
|
35
|
+
end
|
36
|
+
|
37
|
+
collect_data do
|
38
|
+
# Adds softlayer Mash
|
39
|
+
if looks_like_softlayer?
|
40
|
+
logger.trace("Plugin Softlayer: looks_like_softlayer? == true")
|
41
|
+
metadata = fetch_metadata
|
42
|
+
softlayer Mash.new
|
43
|
+
metadata&.each { |k, v| softlayer[k] = v }
|
44
|
+
else
|
45
|
+
logger.trace("Plugin Softlayer: looks_like_softlayer? == false")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|