diff options
author | Theodore Nordsieck <theo@opscode.com> | 2013-09-10 15:29:24 -0700 |
---|---|---|
committer | Theodore Nordsieck <theo@opscode.com> | 2013-09-11 16:13:25 -0700 |
commit | 4debd8ff5476bbca4ef85780ba1874715db631c0 (patch) | |
tree | 7c684ebdfcf61a0bbc4a8c86bb046b940f5a96e1 /lib/ohai | |
parent | 67d0e9e1aa60f79a90dd3e5bbd5d49cf002e67c2 (diff) | |
download | ohai-4debd8ff5476bbca4ef85780ba1874715db631c0.tar.gz |
Converted plugins/linux/virtualization to Mixlib::ShellOut.
Diffstat (limited to 'lib/ohai')
-rw-r--r-- | lib/ohai/plugins/linux/virtualization.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb index 251e6a80..6a88aa5a 100644 --- a/lib/ohai/plugins/linux/virtualization.rb +++ b/lib/ohai/plugins/linux/virtualization.rb @@ -86,29 +86,25 @@ Ohai.plugin do # http://www.dmo.ca/blog/detecting-virtualization-on-linux if File.exists?("/usr/sbin/dmidecode") - popen4("dmidecode") do |pid, stdin, stdout, stderr| - stdin.close - dmi_info = stdout.read - case dmi_info - when /Manufacturer: Microsoft/ - if dmi_info =~ /Product Name: Virtual Machine/ - virtualization[:system] = "virtualpc" - virtualization[:role] = "guest" - end - when /Manufacturer: VMware/ - if dmi_info =~ /Product Name: VMware Virtual Platform/ - virtualization[:system] = "vmware" - virtualization[:role] = "guest" - end - when /Manufacturer: Xen/ - if dmi_info =~ /Product Name: HVM domU/ - virtualization[:system] = "xen" - virtualization[:role] = "guest" - end - else - nil + so = shell_out("dmidecode") + case so.stdout + when /Manufacturer: Microsoft/ + if so.stdout =~ /Product Name: Virtual Machine/ + virtualization[:system] = "virtualpc" + virtualization[:role] = "guest" end - + when /Manufacturer: VMware/ + if so.stdout =~ /Product Name: VMware Virtual Platform/ + virtualization[:system] = "vmware" + virtualization[:role] = "guest" + end + when /Manufacturer: Xen/ + if so.stdout =~ /Product Name: HVM domU/ + virtualization[:system] = "xen" + virtualization[:role] = "guest" + end + else + nil end end |