summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-11-30 10:59:42 -0800
committerMatt Robinson <matt@puppetlabs.com>2010-11-30 11:08:26 -0800
commit1985528c9e70095116f84d4f4849c149602fffec (patch)
treec770be95c2851937278013ed0784432fb35289fd
parent739040f234c356133e2cb72318f687e8c0e56b9b (diff)
downloadfacter-1985528c9e70095116f84d4f4849c149602fffec.tar.gz
facter-1985528c9e70095116f84d4f4849c149602fffec.tar.xz
facter-1985528c9e70095116f84d4f4849c149602fffec.zip
(#4754) Change is_virtual logic to not enumerate virtual types
While looking at the patch for adding parallels to the virtual types David Schmitt noticed that it might be easier just to list the types that are NOT virtual since there's fewer of them. Paired-with: Nick Lewis
-rw-r--r--lib/facter/virtual.rb3
-rw-r--r--spec/unit/virtual.rb6
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index a3b7163..8412a0a 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -106,8 +106,7 @@ Facter.add("is_virtual") do
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin}
setcode do
- case Facter.value(:virtual)
- when "xenu", "openvzve", "vmware", "kvm", "vserver", "jail", "zone", "hpvm", "parallels"
+ if Facter.value(:virtual) != "physical" && Facter.value(:virtual) != "xen0"
"true"
else
"false"
diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb
index d607960..9e8e358 100644
--- a/spec/unit/virtual.rb
+++ b/spec/unit/virtual.rb
@@ -135,6 +135,12 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == "false"
end
+ it "should be false when running on physical" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("physical")
+ Facter.fact(:is_virtual).value.should == "false"
+ end
+
it "should be true when running on vmware" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("vmware")