summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <clairemcquin@seamcquin100loaner.local>2014-01-12 17:17:42 -0800
committerClaire McQuin <clairemcquin@seamcquin100loaner.local>2014-01-12 17:17:42 -0800
commit4d72ab2043300a7b3b1a1e4f0c85dc00453f86af (patch)
tree8630f13723660e24bc4e98cbd126b457fddce327
parentaa0f28737dddcdfea8da8e37775f71deeedf1bc8 (diff)
downloadohai-4d72ab2043300a7b3b1a1e4f0c85dc00453f86af.tar.gz
merge gce plugin
-rw-r--r--lib/ohai/plugins/gce.rb25
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