diff options
author | Tim Smith <tsmith@chef.io> | 2016-12-15 19:50:13 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2016-12-15 19:50:13 -0800 |
commit | f46354f528ac5158de7ee817be10b38ee91e37ea (patch) | |
tree | 684ea8e68db195d43b60b77b43b8e9222affb8fe | |
parent | 7f592431092c654c68c0e032c920bca85d8b7389 (diff) | |
download | ohai-f46354f528ac5158de7ee817be10b38ee91e37ea.tar.gz |
Reorder detection of platforms to speed things up
Check the more popular platforms first since those are most likely to match. Parallels have to come before RHEL though since it looks like RHEL.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index 76c9d0a5..4a013868 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -166,12 +166,6 @@ Ohai.plugin(:Platform) do contents = File.read("/etc/system-release").chomp platform get_redhatish_platform(contents) platform_version get_redhatish_version(contents) - elsif File.exist?("/etc/gentoo-release") - platform "gentoo" - # the gentoo release version is the base version used to bootstrap - # a node and doesn't have a lot of meaning in a rolling release distro - # kernel release will be used - ex. 3.18.7-gentoo - platform_version `uname -r`.strip elsif File.exist?("/etc/SuSE-release") suse_release = File.read("/etc/SuSE-release") suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".") @@ -187,22 +181,6 @@ Ohai.plugin(:Platform) do else platform "suse" end - elsif File.exist?("/etc/slackware-version") - platform "slackware" - platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join - elsif File.exist?("/etc/arch-release") - platform "arch" - # no way to determine platform_version in a rolling release distribution - # kernel release will be used - ex. 2.6.32-ARCH - platform_version `uname -r`.strip - elsif File.exist?("/etc/exherbo-release") - platform "exherbo" - # no way to determine platform_version in a rolling release distribution - # kernel release will be used - ex. 3.13 - platform_version `uname -r`.strip - elsif File.exist?("/etc/alpine-release") - platform "alpine" - platform_version File.read("/etc/alpine-release").strip() elsif File.exist?("/etc/Eos-release") platform "arista_eos" platform_version File.read("/etc/Eos-release").strip.split[-1] @@ -222,6 +200,28 @@ Ohai.plugin(:Platform) do platform_family "wrlinux" platform_version os_release_info["VERSION"] + elsif File.exist?("/etc/gentoo-release") + platform "gentoo" + # the gentoo release version is the base version used to bootstrap + # a node and doesn't have a lot of meaning in a rolling release distro + # kernel release will be used - ex. 3.18.7-gentoo + platform_version `uname -r`.strip + elsif File.exist?("/etc/slackware-version") + platform "slackware" + platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join + elsif File.exist?("/etc/arch-release") + platform "arch" + # no way to determine platform_version in a rolling release distribution + # kernel release will be used - ex. 2.6.32-ARCH + platform_version `uname -r`.strip + elsif File.exist?("/etc/exherbo-release") + platform "exherbo" + # no way to determine platform_version in a rolling release distribution + # kernel release will be used - ex. 3.13 + platform_version `uname -r`.strip + elsif File.exist?("/etc/alpine-release") + platform "alpine" + platform_version File.read("/etc/alpine-release").strip() elsif lsb[:id] =~ /RedHat/i platform "redhat" platform_version lsb[:release] |