lib/ohai/plugins/ec2.rb in ohai-16.2.3 vs lib/ohai/plugins/ec2.rb in ohai-16.3.0
- old
+ new
@@ -39,11 +39,11 @@
# this works even if the system lacks dmidecode use by the Dmi plugin
# this gets us detection of new Xen-less HVM instances that are within a VPC
# @return [Boolean] do we have Amazon DMI data?
def has_ec2_amazon_dmi?
# detect a version of '4.2.amazon'
- if file_val_if_exists("/sys/class/dmi/id/bios_vendor") =~ /Amazon/
+ if /Amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_vendor"))
logger.trace("Plugin EC2: has_ec2_amazon_dmi? == true")
true
else
logger.trace("Plugin EC2: has_ec2_amazon_dmi? == false")
false
@@ -54,11 +54,11 @@
# this works even if the system lacks dmidecode use by the Dmi plugin
# this gets us detection of HVM instances that are within a VPC
# @return [Boolean] do we have Amazon DMI data?
def has_ec2_xen_dmi?
# detect a version of '4.2.amazon'
- if file_val_if_exists("/sys/class/dmi/id/bios_version") =~ /amazon/
+ if /amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_version"))
logger.trace("Plugin EC2: has_ec2_xen_dmi? == true")
true
else
logger.trace("Plugin EC2: has_ec2_xen_dmi? == false")
false
@@ -66,11 +66,11 @@
end
# looks for a xen UUID that starts with ec2 from within the Linux sys tree
# @return [Boolean] do we have a Xen UUID or not?
def has_ec2_xen_uuid?
- if file_val_if_exists("/sys/hypervisor/uuid") =~ /^ec2/
+ if /^ec2/.match?(file_val_if_exists("/sys/hypervisor/uuid"))
logger.trace("Plugin EC2: has_ec2_xen_uuid? == true")
return true
end
logger.trace("Plugin EC2: has_ec2_xen_uuid? == false")
false
@@ -79,13 +79,13 @@
# looks at the identifying number WMI value to see if it starts with ec2.
# this is actually the same value we're looking at in has_ec2_xen_uuid? on
# linux hosts
# @return [Boolean] do we have a Xen Identifying Number or not?
def has_ec2_identifying_number?
- if RUBY_PLATFORM =~ /mswin|mingw32|windows/
+ if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
require "wmi-lite/wmi"
wmi = WmiLite::Wmi.new
- if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"] =~ /^ec2/
+ if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
logger.trace("Plugin EC2: has_ec2_identifying_number? == true")
true
end
else
logger.trace("Plugin EC2: has_ec2_identifying_number? == false")