diff options
author | Claire McQuin <clairemcquin@seamcquin100loaner.local> | 2014-01-12 17:17:42 -0800 |
---|---|---|
committer | Claire McQuin <clairemcquin@seamcquin100loaner.local> | 2014-01-12 17:17:42 -0800 |
commit | 4d72ab2043300a7b3b1a1e4f0c85dc00453f86af (patch) | |
tree | 8630f13723660e24bc4e98cbd126b457fddce327 | |
parent | aa0f28737dddcdfea8da8e37775f71deeedf1bc8 (diff) | |
download | ohai-4d72ab2043300a7b3b1a1e4f0c85dc00453f86af.tar.gz |
merge gce plugin
-rw-r--r-- | lib/ohai/plugins/gce.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index af412110..8b6fa581 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -18,17 +18,36 @@ require 'ohai/mixin/gce_metadata' Ohai.plugin(:GCE) do include Ohai::Mixin::GCEMetadata - GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw' provides "gce" - #https://developers.google.com/compute/docs/instances#dmi + # Checks for matching gce dmi + # https://developers.google.com/compute/docs/instances#dmi + # + # === Return + # true:: If gce dmi matches + # false:: Otherwise + GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw' def has_google_dmi? ::File.read(GOOGLE_SYSFS_DMI).include?('Google') end + # Checks for gce metadata server + # + # === Return + # true:: If gce metadata server found + # false:: Otherwise + def has_gce_metadata? + Ohai::Mixin::GCEMetadata.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80) + end + + # Identifies gce + # + # === Return + # true:: If gce can be identified + # false:: Otherwise def looks_like_gce? - hint?('gce') || has_google_dmi? && can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80) + hint?('gce') || has_google_dmi? || has_gce_metadata? end collect_data do |