summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRessl Robert <r.ressl@safematix.com>2018-11-25 03:42:27 +0100
committerRessl Robert <r.ressl@safematix.com>2018-11-25 03:42:27 +0100
commit030a2c6f62b0839ece4e55856ca15c0f7094c789 (patch)
tree75da6790d8dc440ba09d8d1925adc347b7fcdd9b
parent726899b3d95755de4ab557c79e1347b4ee22d8d7 (diff)
downloadohai-030a2c6f62b0839ece4e55856ca15c0f7094c789.tar.gz
:sparkles: :pencil: add function to load hyper_v hostname from guest
Signed-off-by: Ressl Robert <r.ressl@safematix.com>
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index ad9a4689..f4abc93a 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -150,6 +150,17 @@ Ohai.plugin(:Virtualization) do
end
end
+ # Detect Hyper-V gest and host hostname
+ if File.exist?("/var/lib/hyperv/.kvp_pool_3")
+ logger.trace('Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest')
+ data = File.read("/var/lib/hyperv/.kvp_pool_3")
+ hyperv_host = data[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join.downcase
+ virtualization[:system] = 'hyperv'
+ virtualization[:role] = 'guest'
+ virtualization[:systems][:hyperv] = 'guest'
+ virtualization[:host] = hyperv_host
+ end
+
# Detect Linux-VServer
if File.exist?("/proc/self/status")
proc_self_status = File.read("/proc/self/status")