From a70184a1bd94a045c5e62b2e6a355da34ddf697f Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Mon, 22 Dec 2008 19:42:03 +1100 Subject: Fixed #1791 - support for virtual fact on Solaris 10 --- CHANGELOG | 2 ++ lib/facter/virtual.rb | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5d0cd04..a714e81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 1.5.3: + Fixed #1791 - support for virtual fact on Solaris 10 + Fixed #1793 - Added more Solaris 10 facts Fixed errors on unrecognised option in binary diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index 17d6538..db8dc33 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -1,5 +1,5 @@ Facter.add("virtual") do - confine :kernel => %w{Linux FreeBSD OpenBSD} + confine :kernel => %w{Linux FreeBSD OpenBSD SunOS} result = "physical" @@ -27,22 +27,30 @@ Facter.add("virtual") do end if result == "physical" - lspciexists = system "which lspci > /dev/null 2>&1" - if $?.exitstatus == 0 - output = %x{lspci} + path = %x{which lspci 2> /dev/null}.chomp + if path !~ /no lspci/ + output = %x{#{path}} output.each {|p| # --- look for the vmware video card to determine if it is virtual => vmware. # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter result = "vmware" if p =~ /VM[wW]are/ } else - dmidecodeexists = system "which dmidecode > /dev/null 2>&1" - if $?.exitstatus == 0 - outputd = %x{dmidecode} - outputd.each {|pd| + path = %x{which dmidecode 2> /dev/null}.chomp + if path !~ /no dmidecode/ + output = %x{#{path}} + output.each {|pd| result = "vmware" if pd =~ /VMware|Parallels/ } - end + else + path = %x{which prtdiag 2> /dev/null}.chomp + if path !~ /no prtdiag/ + output = %x{#{path}} + output.each {|pd| + result = "vmware" if pd =~ /VMware|Parallels/ + } + end + end end end -- cgit