diff options
author | John McCrae <mccrae@progress.com> | 2023-02-15 08:17:33 -0800 |
---|---|---|
committer | John McCrae <mccrae@progress.com> | 2023-02-15 08:17:33 -0800 |
commit | 25fab7f1d3f9a96012eaebc452f5cc847f2bf4a6 (patch) | |
tree | a1e6a444571ba340e87c9ec996cf88863031e7cc | |
parent | 3dc34edb4e17bb8fb0642d31cc4aa0f7f1a66609 (diff) | |
download | ohai-jfm/chef18_ohai_release.tar.gz |
refacatoring to correct foolish mistakesjfm/chef18_ohai_release
Signed-off-by: John McCrae <mccrae@progress.com>
-rw-r--r-- | lib/ohai/plugins/alibaba.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/azure.rb | 11 | ||||
-rw-r--r-- | lib/ohai/plugins/cpu.rb | 30 | ||||
-rw-r--r-- | lib/ohai/plugins/vmware.rb | 6 |
4 files changed, 22 insertions, 27 deletions
diff --git a/lib/ohai/plugins/alibaba.rb b/lib/ohai/plugins/alibaba.rb index 27fcf421..6f6bbc72 100644 --- a/lib/ohai/plugins/alibaba.rb +++ b/lib/ohai/plugins/alibaba.rb @@ -33,7 +33,7 @@ Ohai.plugin(:Alibaba) do # this works even if the system lacks dmidecode use by the Dmi plugin # @return [Boolean] do we have Alibaba DMI data? def has_ali_dmi? - file_val_if_exists("/sys/class/dmi/id/sys_vendor").include?("Alibaba") + if file_val_if_exists("/sys/class/dmi/id/sys_vendor").include?("Alibaba") # if /Alibaba/.match?(file_val_if_exists("/sys/class/dmi/id/sys_vendor")) logger.trace("Plugin Alibaba: has_ali_dmi? == true") true diff --git a/lib/ohai/plugins/azure.rb b/lib/ohai/plugins/azure.rb index 7e4905d0..c460fb33 100644 --- a/lib/ohai/plugins/azure.rb +++ b/lib/ohai/plugins/azure.rb @@ -58,12 +58,11 @@ Ohai.plugin(:Azure) do has_245 = false if file_exist?("/var/lib/dhcp/dhclient.eth0.leases") file_open("/var/lib/dhcp/dhclient.eth0.leases").each do |line| - if line.include?("unknown-245") - # if /unknown-245/.match?(line) - logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.") - has_245 = true - break - end + if line.include?("unknown-245") + # if /unknown-245/.match?(line) + logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.") + has_245 = true + break end end has_245 diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb index 3a5412b1..a25ec240 100644 --- a/lib/ohai/plugins/cpu.rb +++ b/lib/ohai/plugins/cpu.rb @@ -524,23 +524,23 @@ Ohai.plugin(:CPU) do cpu[index] = Mash.new cpu[index][:status] = status cpu[index][:location] = location - if status.include?("Available") - # if /Available/.match?(status) - cpu[:available] += 1 - lsattr = shell_out("lsattr -El #{name}").stdout.lines - lsattr.each do |attribute| - attrib, value = attribute.split - if attrib == "type" - cpu[index][:model_name] = value - elsif attrib == "frequency" - cpu[index][:mhz] = value.to_i / (1000 * 1000) # convert from hz to MHz - else - cpu[index][attrib] = value + if status.include?("Available") + # if /Available/.match?(status) + cpu[:available] += 1 + lsattr = shell_out("lsattr -El #{name}").stdout.lines + lsattr.each do |attribute| + attrib, value = attribute.split + if attrib == "type" + cpu[index][:model_name] = value + elsif attrib == "frequency" + cpu[index][:mhz] = value.to_i / (1000 * 1000) # convert from hz to MHz + else + cpu[index][attrib] = value + end end + # IBM is the only maker of CPUs for AIX systems. + cpu[index][:vendor_id] = "IBM" end - # IBM is the only maker of CPUs for AIX systems. - cpu[index][:vendor_id] = "IBM" - end end end end diff --git a/lib/ohai/plugins/vmware.rb b/lib/ohai/plugins/vmware.rb index 87429675..d652ec2a 100644 --- a/lib/ohai/plugins/vmware.rb +++ b/lib/ohai/plugins/vmware.rb @@ -53,7 +53,6 @@ Ohai.plugin(:VMware) do # to attribute "vmware[:<parameter>]" %w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param| vmware[param] = from_cmd([vmtools_path, "stat", param]) -<<<<<<< HEAD if param == "hosttime" && vmtools_path.include?("Program Files") # popen and %x return stdout encoded as IBM437 in Windows but in a string marked # UTF-8. The string doesn't throw an exception when encoded to "UTF-8" but @@ -69,11 +68,8 @@ Ohai.plugin(:VMware) do # * confirmed that this is broken on Windows Server 2022 vmware[param] = vmware[param].force_encoding(Encoding::IBM437).encode("UTF-8") end - if /UpdateInfo failed/.match?(vmware[param]) -======= if vmware[param].include?("UpdateInfo failed") - # if /UpdateInfo failed/.match?(vmware[param]) ->>>>>>> a8ee7112 (Moving from using Regex matching for simple literals) + # if /UpdateInfo failed/.match?(vmware[param]) vmware[param] = nil end end |