Signed-off-by: Michael Kincaid <[email protected]>
---
Local-branch: ticket/next/4508
lib/facter/virtual.rb | 5 +++++
spec/unit/virtual_spec.rb | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index a583995..739d346 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -110,6 +110,9 @@ Facter.add("virtual") do
# --- 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/
+ # --- look for pci vendor id used by Xen HVM device
+ # --- 00:03.0 Unassigned class [ff80]: XenSource, Inc.
Xen Platform Device (rev 01)
+ result = "xenhvm" if p =~ /XenSource/
end
else
output = Facter::Util::Resolution.exec('dmidecode')
@@ -118,6 +121,7 @@ Facter.add("virtual") do
result = "parallels" if pd =~ /Parallels/
result = "vmware" if pd =~ /VMware/
result = "virtualbox" if pd =~ /VirtualBox/
+ result = "xenhvm" if pd =~ /HVM domU/
end
elsif Facter.value(:kernel) == 'SunOS'
res = Facter::Util::Resolution.new('prtdiag')
@@ -129,6 +133,7 @@ Facter.add("virtual") do
result = "parallels" if pd =~ /Parallels/
result = "vmware" if pd =~ /VMware/
result = "virtualbox"
if pd =~ /VirtualBox/
+ result = "xenhvm" if pd =~ /HVM domU/
end
end
end
diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb
index f69c898..942ccf1 100644
--- a/spec/unit/virtual_spec.rb
+++ b/spec/unit/virtual_spec.rb
@@ -108,6 +108,19 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "vmware"
end
+ it "should be xenhvm with Xen HVM vendor name from lspci" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0
Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
+ Facter.fact(:virtual).value.should == "xenhvm"
+ end
+
+ it "should be xenhvm with Xen HVM 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("System
Information\nManufacturer: Xen\nProduct Name: HVM domU")
+ Facter.fact(:virtual).value.should == "xenhvm"
+ end
+
it "should be parallels with Parallels vendor name from dmidecode" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
@@ -164,6 +177,12 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == "false"
end
+ it "should be true when running on xenhvm" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("xenhvm")
+ Facter.fact(:is_virtual).value.should == "true"
+ end
+
it "should be false when running on physical" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("physical")
--
1.7.4.1
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.