summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorStefan Schulte <stefan.schulte@taunusstein.net>2010-11-03 21:55:58 +0100
committerStefan Schulte <stefan.schulte@taunusstein.net>2010-11-03 23:50:10 +0100
commit43e203c688399ac86d337514aecb6fa0c9def683 (patch)
treeb8e45f29cfc15264ac2a2d50a38575cdabb9dea8 /spec
parent889e1504c101b36741141ef95cf5cbdfedd95e56 (diff)
downloadfacter-43e203c688399ac86d337514aecb6fa0c9def683.tar.gz
facter-43e203c688399ac86d337514aecb6fa0c9def683.tar.xz
facter-43e203c688399ac86d337514aecb6fa0c9def683.zip
(#5040) fact virtual should detect hpvm
With HP-UX you can build virtual machines that are often refered to as HP-VMs. This patch detecs HP-VMs by introducing a new function hpvm? that will check the output of /usr/bin/getconf MACHINE_MODEL. This should not depend on any tools that might be not installed. If inside a HP-VM the command will say something like ia64 hp server Integrity Virtual Machine while on real hardware the output could be ia64 hp server rx660 so searching for "Virtual Machine" should work. Currently it only works if the guest is also running HP-UX. (I guess this is the most common usecase).
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/util/virtual.rb11
-rw-r--r--spec/unit/virtual.rb11
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb
index 1e31a2f..57ef440 100644
--- a/spec/unit/util/virtual.rb
+++ b/spec/unit/util/virtual.rb
@@ -116,4 +116,15 @@ describe Facter::Util::Virtual do
Facter::Util::Virtual.should_not be_jail
end
+ it "should detect hpvm on HP-UX" do
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
+ Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine')
+ Facter::Util::Virtual.should be_hpvm
+ end
+
+ it "should not detect hpvm on HP-UX when not in hpvm" do
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
+ Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
+ Facter::Util::Virtual.should_not be_hpvm
+ end
end
diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb
index 8ee843b..ee673be 100644
--- a/spec/unit/virtual.rb
+++ b/spec/unit/virtual.rb
@@ -24,6 +24,11 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "jail"
end
+ it "should be hpvm on HP-UX when in HP-VM" do
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
+ Facter::Util::Virtual.stubs(:hpvm?).returns(true)
+ Facter.fact(:virtual).value.should == "hpvm"
+ end
end
describe "is_virtual fact" do
@@ -68,4 +73,10 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == true
end
+ it "should be true when running on hp-vm" do
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
+ Facter.fact(:virtual).stubs(:value).returns("hpvm")
+ Facter.fact(:is_virtual).value.should == true
+ end
+
end