summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Rossman <paul@factory9.com>2013-10-08 17:21:07 -0500
committeradamedx <adamed@opscode.com>2013-10-10 10:45:10 -0700
commit31be96b5888f5f75c475bcb4f1a026d1ce1e84ab (patch)
treecee3d0eafb9f188f05e4699b310fdfe3c7865267
parent66ea7fc2527f307824db50943dffcdaf89375100 (diff)
downloadohai-31be96b5888f5f75c475bcb4f1a026d1ce1e84ab.tar.gz
Merge branch '6-stable-gce-metadata-update' into 6-stable
Conflicts: lib/ohai/plugins/gce.rb
-rw-r--r--lib/ohai/plugins/gce.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb
index d8a4c313..1439d3c5 100644
--- a/lib/ohai/plugins/gce.rb
+++ b/lib/ohai/plugins/gce.rb
@@ -18,10 +18,36 @@ provides "gce"
require 'ohai/mixin/gce_metadata'
+# 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') || Ohai::Mixin::GCEMetadata.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)
+ hint?('gce') || has_google_dmi? || has_gce_metadata?
end
+# Adds the gce Mash
if looks_like_gce?
Ohai::Log.debug("looks_like_gce? == true")
gce Mash.new