[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, experimental_upstream, updated. 1.5.9-54-g5a4eeed
Adrien Thebo
adrien.thebo at gmail.com
Wed Jun 22 08:51:47 UTC 2011
The following commit has been merged in the experimental_upstream branch:
commit 3efa9d717572d7a9a2136c50cd863ff9d4c27372
Author: Michael Kincaid <michael at puppetlabs.com>
Date: Thu Mar 31 16:04:57 2011 -0700
(#3856) Add virtualbox detection via lspci (graphics card), dmidecode, and prtdiag for Solaris and corresponding tests. Darwin case is not handled yet.
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index 02802e6..7c649ba 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -104,6 +104,9 @@ Facter.add("virtual") do
# --- 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/
+ # --- look for virtualbox video card to determine if it is virtual => virtualbox.
+ # --- 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
+ result = "virtualbox" if p =~ /VirtualBox/
# --- look for pci vendor id used by Parallels video card
# --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
result = "parallels" if p =~ /1ab8:|[Pp]arallels/
@@ -114,6 +117,7 @@ Facter.add("virtual") do
output.each_line do |pd|
result = "parallels" if pd =~ /Parallels/
result = "vmware" if pd =~ /VMware/
+ result = "virtualbox" if pd =~ /VirtualBox/
end
else
output = Facter::Util::Resolution.exec('prtdiag')
@@ -121,6 +125,7 @@ Facter.add("virtual") do
output.each_line do |pd|
result = "parallels" if pd =~ /Parallels/
result = "vmware" if pd =~ /VMware/
+ result = "virtualbox" if pd =~ /VirtualBox/
end
end
end
diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb
index 7e50847..ac0a9bb 100644
--- a/spec/unit/virtual_spec.rb
+++ b/spec/unit/virtual_spec.rb
@@ -94,6 +94,12 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "vmware"
end
+ it "should be virtualbox with VirtualBox vendor name from lspci" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
+ Facter.fact(:virtual).value.should == "virtualbox"
+ end
+
it "should be vmware with VMWare vendor name from dmidecode" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
@@ -108,6 +114,13 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "parallels"
end
+ it "should be virtualbox with VirtualBox vendor name from dmidecode" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
+ Facter.fact(:virtual).value.should == "virtualbox"
+ end
+
it "should be vmware with VMWare vendor name from prtdiag" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
@@ -123,6 +136,14 @@ describe "Virtual fact" do
Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
Facter.fact(:virtual).value.should == "parallels"
end
+
+ it "should be virtualbox with VirtualBox vendor name from prtdiag" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
+ Facter.fact(:virtual).value.should == "virtualbox"
+ end
end
end
@@ -152,6 +173,12 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == "true"
end
+ it "should be true when running on virtualbox" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("virtualbox")
+ Facter.fact(:is_virtual).value.should == "true"
+ end
+
it "should be true when running on openvz" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("openvzve")
--
Packaging of Facter for debian
More information about the Pkg-puppet-devel
mailing list