summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-01-29 15:14:10 -0800
committerTim Smith <tsmith@chef.io>2018-02-15 11:04:39 -0800
commitb756590d05722d0ca66b684a2822256d98fece6b (patch)
treed38730cf56259269e37ab034a26eb30493c7e6d4
parentf2b345a4314a19929fe7271bd3eaee1f590a695f (diff)
downloadohai-b756590d05722d0ca66b684a2822256d98fece6b.tar.gz
Detect docker hosts in the Virtualization plugin
Useful information to have and lets us write a docker plugin to collect more information. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/darwin/virtualization.rb10
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb25
2 files changed, 27 insertions, 8 deletions
diff --git a/lib/ohai/plugins/darwin/virtualization.rb b/lib/ohai/plugins/darwin/virtualization.rb
index 61102cf1..318886a6 100644
--- a/lib/ohai/plugins/darwin/virtualization.rb
+++ b/lib/ohai/plugins/darwin/virtualization.rb
@@ -37,10 +37,20 @@ Ohai.plugin(:Virtualization) do
::File.exist?("/Applications/VMware\ Fusion.app/")
end
+ def docker_exists?
+ which("docker")
+ end
+
collect_data(:darwin) do
virtualization Mash.new unless virtualization
virtualization[:systems] = Mash.new unless virtualization[:systems]
+ if docker_exists?
+ virtualization[:system] = "docker"
+ virtualization[:role] = "host"
+ virtualization[:systems][:docker] = "host"
+ end
+
if vboxmanage_exists?
virtualization[:system] = "vbox"
virtualization[:role] = "host"
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index 797ea4e5..1b492207 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -29,12 +29,27 @@ Ohai.plugin(:Virtualization) do
which("nova")
end
+ def docker_exists?
+ which("docker")
+ end
+
collect_data(:linux) do
virtualization Mash.new unless virtualization
virtualization[:systems] = Mash.new unless virtualization[:systems]
- ## Xen
- # /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
+ # Docker hosts
+ if docker_exists?
+ virtualization[:system] = "docker"
+ virtualization[:role] = "host"
+ virtualization[:systems][:docker] = "host"
+ end
+
+ # Xen Notes:
+ # - /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
+ # - cpuid of guests, if we could get it, would also be a clue
+ # - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
+ # - Additional edge cases likely should not change the above assumptions
+ # but rather be additive - btm
if File.exist?("/proc/xen")
virtualization[:system] = "xen"
# Assume guest
@@ -51,12 +66,6 @@ Ohai.plugin(:Virtualization) do
end
end
- # Xen Notes:
- # - cpuid of guests, if we could get it, would also be a clue
- # - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
- # - Additional edge cases likely should not change the above assumptions
- # but rather be additive - btm
-
# Detect Virtualbox from kernel module
if File.exist?("/proc/modules")
modules = File.read("/proc/modules")