summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-16 17:24:32 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-03-16 17:24:32 -0700
commite37ba05100330fa7d492f267ffae57aa93ad53d2 (patch)
tree9557a98551ebfc1b39bc074ca63f5fe4859e0922
parent469d2a26a467c50af9f9732d7f98e8a01ecc369f (diff)
parent458a22d472334e4239397f3077e6366a9d7e9973 (diff)
Merge branch 'next'
* next: Incremented release to 1.5.9 Fixed #6719 Typo (#5011) Adds swap statistics for OSX (#6719) Restricts virtualization types for zones Fixed #6616 - Stubbing in VMware tests on Linux Remove Solaris from the list of confined systems. It won't get the original lsb facts, and it's nonsensical too. Fix #6679 - Added Scientific Linux to operatingsystem fact Further fix to #5485 - SELinux facts (#2721) Merged patch from Brane GraAnar (#5485) Made selinux_mode fact work Fixed #5485 - Updated selinux_mode fact Fix for #6495 - Updated interface detection Fixed #5699 - Added processorcount support for S390x Fixed #5699 - Added virtual support for s390x/Zlinux
-rw-r--r--lib/facter.rb2
-rw-r--r--lib/facter/lsbmajdistrelease.rb2
-rw-r--r--lib/facter/memory.rb30
-rw-r--r--lib/facter/operatingsystem.rb10
-rw-r--r--lib/facter/operatingsystemrelease.rb26
-rw-r--r--lib/facter/processor.rb7
-rw-r--r--lib/facter/selinux.rb41
-rw-r--r--lib/facter/util/ip.rb18
-rw-r--r--lib/facter/util/virtual.rb3
-rw-r--r--lib/facter/virtual.rb10
-rw-r--r--spec/unit/data/hpux_netstat_all_interfaces9
-rw-r--r--spec/unit/data/selinux_sestatus6
-rw-r--r--spec/unit/memory_spec.rb45
-rwxr-xr-xspec/unit/operatingsystem_spec.rb12
-rwxr-xr-xspec/unit/selinux_spec.rb45
-rwxr-xr-xspec/unit/util/ip_spec.rb20
-rw-r--r--spec/unit/virtual_spec.rb20
17 files changed, 258 insertions, 48 deletions
diff --git a/lib/facter.rb b/lib/facter.rb
index f48138a..63eea37 100644
--- a/lib/facter.rb
+++ b/lib/facter.rb
@@ -27,7 +27,7 @@ module Facter
include Comparable
include Enumerable
- FACTERVERSION = '1.5.8'
+ FACTERVERSION = '1.5.9'
# = Facter
# Functions as a hash of 'facts' you might care about about your
# system, such as mac address, IP address, Video card, etc.
diff --git a/lib/facter/lsbmajdistrelease.rb b/lib/facter/lsbmajdistrelease.rb
index 997e7ef..34a2f1e 100644
--- a/lib/facter/lsbmajdistrelease.rb
+++ b/lib/facter/lsbmajdistrelease.rb
@@ -3,7 +3,7 @@
require 'facter'
Facter.add("lsbmajdistrelease") do
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo OEL OVS GNU/kFreeBSD}
+ confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo OEL OVS GNU/kFreeBSD}
setcode do
if /(\d*)\./i =~ Facter.value(:lsbdistrelease)
result=$1
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 86adc7f..aa67702 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -20,6 +20,36 @@ require 'facter/util/memory'
end
end
+Facter.add("SwapSize") do
+ confine :kernel => :Darwin
+ setcode do
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ swaptotal = 0
+ if swap =~ /total = (\S+)/ then swaptotal = $1; end
+ swaptotal
+ end
+end
+
+Facter.add("SwapFree") do
+ confine :kernel => :Darwin
+ setcode do
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ swapfree = 0
+ if swap =~ /free = (\S+)/ then swapfree = $1; end
+ swapfree
+ end
+end
+
+Facter.add("SwapEncrypted") do
+ confine :kernel => :Darwin
+ setcode do
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ encrypted = false
+ if swap =~ /\(encrypted\)/ then encrypted = true; end
+ encrypted
+ end
+end
+
if Facter.value(:kernel) == "AIX" and Facter.value(:id) == "root"
swap = Facter::Util::Resolution.exec('swap -l')
swapfree, swaptotal = 0, 0
diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb
index c5a3dc1..1675909 100644
--- a/lib/facter/operatingsystem.rb
+++ b/lib/facter/operatingsystem.rb
@@ -36,6 +36,8 @@ Facter.add(:operatingsystem) do
txt = File.read("/etc/redhat-release")
if txt =~ /centos/i
"CentOS"
+ elsif txt =~ /scientific/i
+ "Scientific"
else
"RedHat"
end
@@ -50,8 +52,12 @@ Facter.add(:operatingsystem) do
else
"SuSE"
end
- elsif FileTest.exists?("/etc/slackware-version")
- "Slackware"
+ elsif FileTest.exists?("/etc/bluewhite64-version")
+ "Bluewhite64"
+ elsif FileTest.exists?("/etc/slamd64-version")
+ "Slamd64"
+ elsif FileTest.exists?("/etc/slackware-version")
+ "Slackware"
end
end
end
diff --git a/lib/facter/operatingsystemrelease.rb b/lib/facter/operatingsystemrelease.rb
index 280208b..ac9be65 100644
--- a/lib/facter/operatingsystemrelease.rb
+++ b/lib/facter/operatingsystemrelease.rb
@@ -72,5 +72,29 @@ Facter.add(:operatingsystemrelease) do
end
Facter.add(:operatingsystemrelease) do
- setcode do Facter[:kernelrelease].value end
+ confine :operatingsystem => %w{Bluewhite64}
+ setcode do
+ releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version')
+ if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
+ $1 + "." + $2
+ else
+ "unknown"
+ end
+ end
+end
+
+Facter.add(:operatingsystemrelease) do
+ confine :operatingsystem => %w{Slamd64}
+ setcode do
+ releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version')
+ if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
+ $1 + "." + $2
+ else
+ "unknown"
+ end
+ end
+end
+
+Facter.add(:operatingsystemrelease) do
+ setcode do Facter[:kernelrelease].value end
end
diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb
index ac75867..c71bad4 100644
--- a/lib/facter/processor.rb
+++ b/lib/facter/processor.rb
@@ -17,6 +17,9 @@ if ["Linux", "GNU/kFreeBSD"].include? Facter.value(:kernel)
elsif l =~ /model name\s+:\s+(.*)\s*$/
processor_list[processor_num] = $1 unless processor_num == -1
processor_num = -1
+ elsif l =~ /processor\s+(\d+):\s+(.*)/
+ processor_num = $1.to_i
+ processor_list[processor_num] = $2 unless processor_num == -1
end
end
end
@@ -80,9 +83,9 @@ if Facter.value(:kernel) == "OpenBSD"
Facter::Util::Resolution.exec("uname -p")
end
end
-
+
Facter.add("ProcessorCount") do
- confine :kernel => :openbsd
+ confine :kernel => :openbsd
setcode do
Facter::Util::Resolution.exec("sysctl hw.ncpu | cut -d'=' -f2")
end
diff --git a/lib/facter/selinux.rb b/lib/facter/selinux.rb
index 0e9637d..9fab427 100644
--- a/lib/facter/selinux.rb
+++ b/lib/facter/selinux.rb
@@ -4,7 +4,7 @@
Facter.add("selinux") do
confine :kernel => :linux
- setcode do
+ setcode do
result = "false"
if FileTest.exists?("/selinux/enforce")
if FileTest.exists?("/proc/self/attr/current")
@@ -31,15 +31,48 @@ end
Facter.add("selinux_policyversion") do
confine :selinux => :true
- setcode do
+ setcode do
File.read("/selinux/policyvers")
end
end
-Facter.add("selinux_mode") do
+Facter.add("selinux_current_mode") do
+ confine :selinux => :true
+ setcode do
+ result = 'unknown'
+ mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus')
+ mode.each_line { |l| result = $1 if l =~ /^Current mode\:\s+(\w+)$/i }
+ result.chomp
+ end
+end
+
+Facter.add("selinux_config_mode") do
confine :selinux => :true
setcode do
- %x{/usr/sbin/sestatus | /bin/grep "Policy from config file:" | awk '{print $5}'}
+ result = 'unknown'
+ mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus')
+ mode.each_line { |l| result = $1 if l =~ /^Mode from config file\:\s+(\w+)$/i }
+ result.chomp
end
end
+Facter.add("selinux_config_policy") do
+ confine :selinux => :true
+ setcode do
+ result = 'unknown'
+ mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus')
+ mode.each_line { |l| result = $1 if l =~ /^Policy from config file\:\s+(\w+)$/i }
+ result.chomp
+ end
+end
+
+# This is a legacy fact which returns the old selinux_mode fact value to prevent
+# breakages of existing manifests. It should be removed at the next major release.
+# See ticket #6677.
+
+Facter.add("selinux_mode") do
+ confine :selinux => :true
+ setcode do
+ Facter.value(:selinux_config_policy)
+ end
+end
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 23eeb9c..e4370dc 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -59,7 +59,7 @@ module Facter::Util::IP
# at the end of interfaces. So, we have to trim those trailing
# characters. I tried making the regex better but supporting all
# platforms with a single regex is probably a bit too much.
- output.scan(/^[-\w]+[.:]?\d+[.:]?\d*[.:]?\w*/).collect { |i| i.sub(/:$/, '') }.uniq
+ output.scan(/^\S+/).collect { |i| i.sub(/:$/, '') }.uniq
end
def self.get_all_interface_output
@@ -69,7 +69,7 @@ module Facter::Util::IP
when 'SunOS'
output = %x{/usr/sbin/ifconfig -a}
when 'HP-UX'
- output = %x{/bin/netstat -i}
+ output = %x{/bin/netstat -in | sed -e 1d}
end
output
end
@@ -141,15 +141,13 @@ module Facter::Util::IP
else
output_int = get_single_interface_output(interface)
- if interface != /^lo[0:]?\d?/
- output_int.each_line do |s|
- if s =~ regex
- value = $1
+ output_int.each_line do |s|
+ if s =~ regex
+ value = $1
if label == 'netmask' && convert_from_hex?(kernel)
value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.')
end
- tmp1.push(value)
- end
+ tmp1.push(value)
end
end
@@ -158,13 +156,13 @@ module Facter::Util::IP
end
end
end
-
+
def self.get_network_value(interface)
require 'ipaddr'
ipaddress = get_interface_value(interface, "ipaddress")
netmask = get_interface_value(interface, "netmask")
-
+
if ipaddress && netmask
ip = IPAddr.new(ipaddress, Socket::AF_INET)
subnet = IPAddr.new(netmask, Socket::AF_INET)
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb
index 06b1b6d..4355451 100644
--- a/lib/facter/util/virtual.rb
+++ b/lib/facter/util/virtual.rb
@@ -70,4 +70,7 @@ module Facter::Util::Virtual
Facter::Util::Resolution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/
end
+ def self.zlinux?
+ "zlinux"
+ end
end
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index 47c9504..468ab77 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -25,12 +25,18 @@ Facter.add("virtual") do
setcode do
- result = "zone" if Facter::Util::Virtual.zone?
+ if Facter::Util::Virtual.zone? and Facter.value(:operatingsystem) == "Solaris"
+ result = "zone"
+ end
if Facter.value(:kernel)=="HP-UX"
result = "hpvm" if Facter::Util::Virtual.hpvm?
end
+ if Facter.value(:architecture)=="s390x"
+ result = "zlinux" if Facter::Util::Virtual.zlinux?
+ end
+
if Facter::Util::Virtual.openvz?
result = Facter::Util::Virtual.openvz_type()
end
@@ -92,7 +98,7 @@ Facter.add("virtual") do
end
end
end
- # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not.
+
if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx")
result = "vmware_server"
end
diff --git a/spec/unit/data/hpux_netstat_all_interfaces b/spec/unit/data/hpux_netstat_all_interfaces
index 7745fa8..0e8f9dc 100644
--- a/spec/unit/data/hpux_netstat_all_interfaces
+++ b/spec/unit/data/hpux_netstat_all_interfaces
@@ -1,6 +1,3 @@
-Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
-lan1 1500 15.12.0.0 host1.default.com
- 572527659 0 1129421249 0 0
-lan0 1500 172.54.85.0 host2.default.com
- 519222647 0 329127145 0 0
-lo0 4136 loopback localhost 14281117 0 14281125 0 0
+lan1 1500 192.168.100.0 192.168.100.182 12964 0 900 0 0
+lan0 1500 192.168.100.0 192.168.100.181 12964 0 715 0 0
+lo0 4136 127.0.0.0 127.0.0.1 98 0 98 0 0
diff --git a/spec/unit/data/selinux_sestatus b/spec/unit/data/selinux_sestatus
new file mode 100644
index 0000000..50cea13
--- /dev/null
+++ b/spec/unit/data/selinux_sestatus
@@ -0,0 +1,6 @@
+SELinux status: enabled
+SELinuxfs mount: /selinux
+Current Mode: permissive
+Mode from config file: permissive
+Policy version: 16
+Policy from config file: targeted
diff --git a/spec/unit/memory_spec.rb b/spec/unit/memory_spec.rb
new file mode 100644
index 0000000..5cae8cb
--- /dev/null
+++ b/spec/unit/memory_spec.rb
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+require 'facter'
+
+describe "Memory facts" do
+ before do
+ Facter.loadfacts
+ end
+
+ after do
+ Facter.clear
+ end
+
+ it "should return the current swap size" do
+
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
+ Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
+ swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
+
+ if swapusage =~ /total = (\S+).*/
+ Facter.fact(:swapfree).value.should == $1
+ end
+ end
+
+ it "should return the current swap free" do
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
+ Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
+ swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
+
+ if swapusage =~ /free = (\S+).*/
+ Facter.fact(:swapfree).value.should == $1
+ end
+ end
+
+ it "should return whether swap is encrypted" do
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
+ Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
+ swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
+
+ swapusage =~ /\(encrypted\)/
+ Facter.fact(:swapencrypted).value.should == true
+ end
+end
diff --git a/spec/unit/operatingsystem_spec.rb b/spec/unit/operatingsystem_spec.rb
index be83916..73b3649 100755
--- a/spec/unit/operatingsystem_spec.rb
+++ b/spec/unit/operatingsystem_spec.rb
@@ -9,23 +9,23 @@ describe "Operating System fact" do
before do
Facter.clear
end
-
+
after do
Facter.clear
end
-
+
it "should default to the kernel name" do
Facter.fact(:kernel).stubs(:value).returns("Nutmeg")
Facter.fact(:operatingsystem).value.should == "Nutmeg"
end
-
+
it "should be Solaris for SunOS" do
Facter.fact(:kernel).stubs(:value).returns("SunOS")
-
+
Facter.fact(:operatingsystem).value.should == "Solaris"
end
-
+
it "should identify Oracle VM as OVS" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
@@ -33,7 +33,7 @@ describe "Operating System fact" do
FileTest.expects(:exists?).with("/etc/ovs-release").returns true
FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
-
+
Facter.fact(:operatingsystem).value.should == "OVS"
end
end
diff --git a/spec/unit/selinux_spec.rb b/spec/unit/selinux_spec.rb
index 43fd5bf..d820958 100755
--- a/spec/unit/selinux_spec.rb
+++ b/spec/unit/selinux_spec.rb
@@ -31,11 +31,11 @@ describe "SELinux facts" do
File.stubs(:read).with("/selinux/enforce").returns("0")
FileTest.expects(:exists?).with("/selinux/enforce").returns true
- File.expects(:read).with("/selinux/enforce").returns("1")
+ File.expects(:read).with("/selinux/enforce").returns("1")
Facter.fact(:selinux_enforced).value.should == "true"
end
-
+
it "should return an SELinux policy version" do
Facter.fact(:selinux).stubs(:value).returns("true")
@@ -45,4 +45,45 @@ describe "SELinux facts" do
Facter.fact(:selinux_policyversion).value.should == "1"
end
+
+ it "should return the SELinux current mode" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
+ selinux_sestatus = File.read(sample_output_file)
+
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
+
+ Facter.fact(:selinux_current_mode).value.should == "permissive"
+ end
+
+ it "should return the SELinux mode from the configuration file" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
+ selinux_sestatus = File.read(sample_output_file)
+
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
+
+ Facter.fact(:selinux_config_mode).value.should == "permissive"
+ end
+
+ it "should return the SELinux configuration file policy" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
+ selinux_sestatus = File.read(sample_output_file)
+
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
+
+ Facter.fact(:selinux_config_policy).value.should == "targeted"
+ end
+
+ it "should ensure legacy selinux_mode facts returns same value as selinux_config_policy fact" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ Facter.fact(:selinux_config_policy).stubs(:value).returns("targeted")
+
+ Facter.fact(:selinux_mode).value.should == "targeted"
+ end
end
diff --git a/spec/unit/util/ip_spec.rb b/spec/unit/util/ip_spec.rb
index ceceb3f..1a545b8 100755
--- a/spec/unit/util/ip_spec.rb
+++ b/spec/unit/util/ip_spec.rb
@@ -20,11 +20,11 @@ describe Facter::Util::IP do
Facter::Util::IP.get_interfaces().should == []
end
- it "should return a list with a single interface on Linux with a single interface" do
+ it "should return a list with a single interface and the loopback interface on Linux with a single interface" do
sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface'
linux_ifconfig = File.new(sample_output_file).read()
Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
- Facter::Util::IP.get_interfaces().should == ["eth0"]
+ Facter::Util::IP.get_interfaces().should == ["eth0", "lo"]
end
it "should return a list two interfaces on Darwin with two interfaces" do
@@ -46,7 +46,7 @@ describe Facter::Util::IP do
hpux_netstat = File.new(sample_output_file).read()
Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat)
Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
- end
+ end
it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do
sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig'
@@ -102,7 +102,7 @@ describe Facter::Util::IP do
Facter.stubs(:value).with(:kernel).returns("HP-UX")
Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71"
- end
+ end
it "should return macaddress information for HP-UX" do
sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
@@ -112,7 +112,7 @@ describe Facter::Util::IP do
Facter.stubs(:value).with(:kernel).returns("HP-UX")
Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7"
- end
+ end
it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do
sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
@@ -132,7 +132,7 @@ describe Facter::Util::IP do
Facter.stubs(:value).with(:kernel).returns("HP-UX")
Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
- end
+ end
it "should return calculated network information for HP-UX" do
sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
@@ -142,7 +142,7 @@ describe Facter::Util::IP do
Facter.stubs(:value).with(:kernel).returns("HP-UX")
Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0"
- end
+ end
it "should return interface information for FreeBSD supported via an alias" do
sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
@@ -192,7 +192,7 @@ describe Facter::Util::IP do
Facter.stubs(:value).with(:kernel).returns("HP-UX")
Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
- end
+ end
it "should return a human readable netmask on Darwin" do
sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface"
@@ -204,7 +204,7 @@ describe Facter::Util::IP do
Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0"
end
-
+
it "should return a human readable netmask on GNU/kFreeBSD" do
sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
@@ -218,7 +218,7 @@ describe Facter::Util::IP do
it "should not get bonding master on interface aliases" do
Facter.stubs(:value).with(:kernel).returns("Linux")
-
+
Facter::Util::IP.get_bonding_master("eth0:1").should be_nil
end
diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb
index 5f63dab..7e50847 100644
--- a/spec/unit/virtual_spec.rb
+++ b/spec/unit/virtual_spec.rb
@@ -5,7 +5,6 @@ require 'facter/util/virtual'
require 'facter/util/macosx'
describe "Virtual fact" do
-
before do
Facter::Util::Virtual.stubs(:zone?).returns(false)
Facter::Util::Virtual.stubs(:openvz?).returns(false)
@@ -13,6 +12,7 @@ describe "Virtual fact" do
Facter::Util::Virtual.stubs(:xen?).returns(false)
Facter::Util::Virtual.stubs(:kvm?).returns(false)
Facter::Util::Virtual.stubs(:hpvm?).returns(false)
+ Facter::Util::Virtual.stubs(:zlinux?).returns(false)
end
it "should be zone on Solaris when a zone" do
@@ -36,6 +36,13 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "hpvm"
end
+ it "should be zlinux on s390x" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:architecture).stubs(:value).returns("s390x")
+ Facter::Util::Virtual.stubs(:zlinux?).returns(true)
+ Facter.fact(:virtual).value.should == "zlinux"
+ end
+
describe "on Darwin" do
it "should be parallels with Parallels vendor id" do
Facter.fact(:kernel).stubs(:value).returns("Darwin")
@@ -64,6 +71,11 @@ describe "Virtual fact" do
describe "on Linux" do
+ before do
+ FileTest.expects(:exists?).with("/usr/lib/vmware/bin/vmware-vmx").returns false
+ Facter.fact(:architecture).stubs(:value).returns(true)
+ end
+
it "should be parallels with Parallels vendor id from lspci" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005")
@@ -170,6 +182,12 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == "true"
end
+ it "should be true when running on S390" do
+ Facter.fact(:architecture).stubs(:value).returns("s390x")
+ Facter.fact(:virtual).stubs(:value).returns("zlinux")
+ Facter.fact(:is_virtual).value.should == "true"
+ end
+
it "should be true when running on parallels" do
Facter.fact(:kernel).stubs(:value).returns("Darwin")
Facter.fact(:virtual).stubs(:value).returns("parallels")