diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-04-07 18:36:40 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2016-04-07 18:36:40 -0700 |
commit | 13387c2b0e331b37ce32a6a126ad9a4eec6b67bf (patch) | |
tree | f524c2d7255290ce91bb2921f21850c03a43ba01 | |
parent | 8dc538c9e065d6a71be9f27ce30e85c32f1a520c (diff) | |
download | ohai-13387c2b0e331b37ce32a6a126ad9a4eec6b67bf.tar.gz |
Reduce duplicate code
-rw-r--r-- | lib/ohai/plugins/ec2.rb | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 252eb425..4623ad2d 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -42,15 +42,13 @@ Ohai.plugin(:EC2) do # detect a version of '4.2.amazon' if dmi[:bios][:all_records][0][:Version] =~ /amazon/ Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == true") - true - else - Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == false") - false + return true end rescue NoMethodError - Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == false") - false + # dmi[:bios][:all_records][0][:Version] may not exist end + Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == false") + return false end # looks for a xen UUID that starts with ec2 @@ -61,10 +59,9 @@ Ohai.plugin(:EC2) do Ohai::Log.debug("ec2 plugin: has_ec2_xen_uuid? == true") return true end - else - Ohai::Log.debug("ec2 plugin: has_ec2_xen_uuid? == false") - return false end + Ohai::Log.debug("ec2 plugin: has_ec2_xen_uuid? == false") + return false end # looks for the Amazon.com Organization in Windows Kernel data @@ -74,15 +71,13 @@ Ohai.plugin(:EC2) do # detect an Organization of 'Amazon.com' if kernel[:os_info][:organization] =~ /Amazon/ Ohai::Log.debug("ec2 plugin: has_amazon_org? == true") - true - else - Ohai::Log.debug("ec2 plugin: has_amazon_org? == false") - false + return true end rescue NoMethodError - Ohai::Log.debug("ec2 plugin: has_amazon_org? == false") - false + # kernel[:os_info][:organization] may not exist end + Ohai::Log.debug("ec2 plugin: has_amazon_org? == false") + return false end def looks_like_ec2? |