summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-15 16:05:51 -0800
committerGitHub <noreply@github.com>2018-11-15 16:05:51 -0800
commit9448a8698ae26356e35c0456b88cf169841d00c1 (patch)
treef4b351c94f06d4a6f043f83e3d844996238704cc
parent084c21c6b7e36025b4e5bbbc993e8876dff6a187 (diff)
parent1d7c86f15d027c4ba79e74dac5569e6ef2e00b2d (diff)
downloadohai-9448a8698ae26356e35c0456b88cf169841d00c1.tar.gz
Merge pull request #1291 from nathenharvey/gce/user-agent
Set User-Agent in HTTP header for GCE plugin
-rw-r--r--RELEASE_NOTES.md4
-rw-r--r--lib/ohai/mixin/gce_metadata.rb6
2 files changed, 9 insertions, 1 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index c6feab65..bfd31e51 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -2,6 +2,10 @@
This will be updated as the development of Ohai 15 progresses.
+## Cloud Plugin Improvements
+
+The Google Compute Engine (GCE) plugin now identifies `chef-ohai` as the User-Agent making requests to the Google Cloud metadata server (metadata.google.internal).
+
# Ohai Release Notes 14.6
## Filesystem Plugin on AIX and Solaris
diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb
index f0f0ec22..929928c7 100644
--- a/lib/ohai/mixin/gce_metadata.rb
+++ b/lib/ohai/mixin/gce_metadata.rb
@@ -28,7 +28,11 @@ module Ohai
def http_get(uri)
conn = Net::HTTP.start(GCE_METADATA_ADDR)
conn.read_timeout = 6
- conn.get(uri, { "Metadata-Flavor" => "Google" })
+ conn.get(uri, {
+ "Metadata-Flavor" => "Google",
+ "User-Agent" => "chef-ohai/#{Ohai::VERSION}",
+ }
+ )
end
def fetch_metadata(id = "")