Skip to content

Commit

Permalink
verify gce only by metadata.google.internal, remove dmi check
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Rossman authored and adamedx committed Oct 10, 2013
1 parent 498ada5 commit b0a0fc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/ohai/mixin/gce_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module GCEMetadata

extend self

GCE_METADATA_ADDR = "metadata" unless defined?(GCE_METADATA_ADDR)
GCE_METADATA_ADDR = "metadata.google.internal" unless defined?(GCE_METADATA_ADDR)
GCE_METADATA_URL = "/computeMetadata/v1beta1/?recursive=true" unless defined?(GCE_METADATA_URL)

def can_metadata_connect?(addr, port, timeout=2)
Expand Down
10 changes: 1 addition & 9 deletions lib/ohai/plugins/gce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@

require 'ohai/mixin/gce_metadata'


GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw'

#https://developers.google.com/compute/docs/instances#dmi
def has_google_dmi?
::File.read(GOOGLE_SYSFS_DMI).include?('Google')
end

def looks_like_gce?
hint?('gce') || (has_google_dmi? && Ohai::Mixin::GCEMetadata.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80))
hint?('gce') || Ohai::Mixin::GCEMetadata.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)
end

if looks_like_gce?
Expand Down

0 comments on commit b0a0fc5

Please sign in to comment.