ohai 18.2.7 → 18.2.8
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/lib/ohai/mixin/oci_metadata.rb +34 -1
- data/lib/ohai/plugins/oci.rb +15 -15
- data/lib/ohai/plugins/windows/network.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2515a27290598e44011ae442133a18dc222aeaaccd9367348f4a67bd8637bfb6
|
|
4
|
+
data.tar.gz: 1e0840e13deb1a03933b63af3f1a88656105066471716ee16524bce0250c5f68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3472f06319f20ebf31efff7206ad669e57d62fb9f005c0b53ec7fdf6767b3c5973cf20f7c17e2e6b7426238ebb63bd859774a676b76c6b03b24a2f761e39befd
|
|
7
|
+
data.tar.gz: 96dcec05db20accc6f05ba7404b7eb4c85da0454b597b44ee8630a6b763554353c8fb1e37cdc357f069f889ae6c9a521e14e3067b250436be0250511af186efb
|
|
@@ -28,6 +28,39 @@ module Ohai
|
|
|
28
28
|
OCI_METADATA_URL = "/opc/v2"
|
|
29
29
|
CHASSIS_ASSET_TAG_FILE = "/sys/devices/virtual/dmi/id/chassis_asset_tag"
|
|
30
30
|
|
|
31
|
+
# Get the chassis asset tag from DMI information
|
|
32
|
+
# On Linux: reads from sysfs
|
|
33
|
+
# On Windows: queries WMI Win32_SystemEnclosure
|
|
34
|
+
def chassis_asset_tag
|
|
35
|
+
if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
|
36
|
+
get_chassis_asset_tag_windows
|
|
37
|
+
else
|
|
38
|
+
get_chassis_asset_tag_linux
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Read chassis asset tag from Linux sysfs
|
|
43
|
+
def get_chassis_asset_tag_linux
|
|
44
|
+
return unless ::File.exist?(CHASSIS_ASSET_TAG_FILE)
|
|
45
|
+
|
|
46
|
+
::File.read(CHASSIS_ASSET_TAG_FILE).strip
|
|
47
|
+
rescue => e
|
|
48
|
+
logger.debug("Mixin OciMetadata: Failed to read chassis asset tag from #{CHASSIS_ASSET_TAG_FILE}: #{e}")
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Read chassis asset tag from Windows WMI
|
|
53
|
+
def get_chassis_asset_tag_windows
|
|
54
|
+
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
|
55
|
+
|
|
56
|
+
wmi = WmiLite::Wmi.new
|
|
57
|
+
enclosure = wmi.first_of("Win32_SystemEnclosure")
|
|
58
|
+
enclosure&.[]("SMBIOSAssetTag")
|
|
59
|
+
rescue => e
|
|
60
|
+
logger.debug("Mixin OciMetadata: Failed to read chassis asset tag from WMI: #{e}")
|
|
61
|
+
nil
|
|
62
|
+
end
|
|
63
|
+
|
|
31
64
|
# fetch the meta content with a timeout and the required header
|
|
32
65
|
def http_get(uri)
|
|
33
66
|
conn = Net::HTTP.start(OCI_METADATA_ADDR)
|
|
@@ -51,7 +84,7 @@ module Ohai
|
|
|
51
84
|
end
|
|
52
85
|
json_data
|
|
53
86
|
else
|
|
54
|
-
logger.
|
|
87
|
+
logger.debug("Mixin OciMetadata: Received response code #{response.code} requesting #{metadata}")
|
|
55
88
|
nil
|
|
56
89
|
end
|
|
57
90
|
end
|
data/lib/ohai/plugins/oci.rb
CHANGED
|
@@ -44,24 +44,22 @@ Ohai.plugin(:Oci) do
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def oci_chassis_asset_tag?
|
|
47
|
-
|
|
48
|
-
if
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
47
|
+
asset_tag = chassis_asset_tag
|
|
48
|
+
return false if asset_tag.nil? || asset_tag.empty?
|
|
49
|
+
|
|
50
|
+
if /OracleCloud.com/.match?(asset_tag)
|
|
51
|
+
logger.trace("Plugin oci: Found OracleCloud.com chassis_asset_tag used by oci.")
|
|
52
|
+
true
|
|
53
|
+
else
|
|
54
|
+
false
|
|
56
55
|
end
|
|
57
|
-
has_oci_chassis_asset_tag
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def parse_metadata
|
|
61
|
-
return
|
|
59
|
+
return unless can_socket_connect?(Ohai::Mixin::OCIMetadata::OCI_METADATA_ADDR, 80)
|
|
62
60
|
|
|
63
61
|
instance_data = fetch_metadata("instance")
|
|
64
|
-
return
|
|
62
|
+
return if instance_data.nil?
|
|
65
63
|
|
|
66
64
|
metadata = Mash.new
|
|
67
65
|
metadata["compute"] = Mash.new
|
|
@@ -80,12 +78,14 @@ Ohai.plugin(:Oci) do
|
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
|
|
83
|
-
volume_attachments_data = fetch_metadata("
|
|
81
|
+
volume_attachments_data = fetch_metadata("allVolumeAttachments")
|
|
84
82
|
|
|
85
83
|
unless volume_attachments_data.nil?
|
|
86
84
|
metadata["volumes"] = Mash.new
|
|
87
|
-
volume_attachments_data.each do |
|
|
88
|
-
|
|
85
|
+
volume_attachments_data.each do |v|
|
|
86
|
+
if v.is_a?(Hash) && v["id"]
|
|
87
|
+
metadata["volumes"][v["id"]] = v
|
|
88
|
+
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -41,7 +41,7 @@ Ohai.plugin(:Network) do
|
|
|
41
41
|
# If we are running on windows nano or another operating system from the future
|
|
42
42
|
# that does not populate the deprecated win32_* WMI classes, then we should
|
|
43
43
|
# grab data from the newer MSFT_* classes
|
|
44
|
-
return msft_adapter_data if data[:addresses].
|
|
44
|
+
return msft_adapter_data if data[:addresses].none?
|
|
45
45
|
|
|
46
46
|
data[:adapters] = wmi.instances_of("Win32_NetworkAdapter")
|
|
47
47
|
data
|
data/lib/ohai/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ohai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 18.2.
|
|
4
|
+
version: 18.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chef-config
|