facter 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +33 -1
- data/conf/redhat/facter.spec +2 -1
- data/install.rb +25 -23
- data/lib/facter.rb +2 -1
- data/lib/facter/domain.rb +4 -4
- data/lib/facter/ec2.rb +6 -28
- data/lib/facter/hardwareisa.rb +0 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/memory.rb +15 -4
- data/lib/facter/operatingsystem.rb +8 -4
- data/lib/facter/osfamily.rb +1 -1
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/util/collection.rb +2 -3
- data/lib/facter/util/config.rb +3 -3
- data/lib/facter/util/ec2.rb +49 -0
- data/lib/facter/util/fact.rb +12 -7
- data/lib/facter/util/monkey_patches.rb +7 -0
- data/lib/facter/util/uptime.rb +2 -2
- data/lib/facter/util/virtual.rb +1 -1
- data/lib/facter/virtual.rb +11 -1
- data/spec/{unit/data → fixtures/unit/selinux}/selinux_sestatus +0 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-ec2.out +1 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out +5 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out +6 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +10 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/6.0-STABLE_FreeBSD_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/Mac_OS_X_10.5.5_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/debian_kfreebsd_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_netstat_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/linux_ifconfig_all_with_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface6 +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/freebsd_dmidecode +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/linux_dmidecode_with_spaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/opensolaris_smbios +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/kstat_boot_time +0 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin +1 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd +1 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/ubuntu_proc_uptime +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/who_b_boottime +0 -0
- data/spec/{unit/data → fixtures/unit/util/vlans}/linux_vlan_config +0 -0
- data/spec/{unit/data → fixtures/unit/util/xendomains}/xendomains +0 -0
- data/spec/integration/facter_spec.rb +2 -2
- data/spec/puppetlabs_spec/files.rb +57 -0
- data/spec/puppetlabs_spec/fixtures.rb +49 -0
- data/spec/puppetlabs_spec/matchers.rb +87 -0
- data/spec/puppetlabs_spec_helper.rb +25 -0
- data/spec/spec_helper.rb +9 -12
- data/spec/unit/architecture_spec.rb +2 -4
- data/spec/unit/domain_spec.rb +3 -1
- data/spec/unit/ec2_spec.rb +140 -0
- data/spec/unit/facter_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +34 -0
- data/spec/unit/hostname_spec.rb +3 -1
- data/spec/unit/id_spec.rb +2 -2
- data/spec/unit/interfaces_spec.rb +2 -4
- data/spec/unit/ipaddress6_spec.rb +4 -7
- data/spec/unit/lsbmajdistrelease_spec.rb +13 -0
- data/spec/unit/macaddress_spec.rb +4 -7
- data/spec/unit/memory_spec.rb +11 -6
- data/spec/unit/operatingsystem_spec.rb +101 -69
- data/spec/unit/operatingsystemrelease_spec.rb +2 -4
- data/spec/unit/physicalprocessorcount_spec.rb +1 -1
- data/spec/unit/processor_spec.rb +32 -35
- data/spec/unit/selinux_spec.rb +5 -10
- data/spec/unit/uniqueid_spec.rb +27 -0
- data/spec/unit/uptime_spec.rb +2 -4
- data/spec/unit/util/collection_spec.rb +12 -3
- data/spec/unit/util/config_spec.rb +24 -0
- data/spec/unit/util/confine_spec.rb +2 -3
- data/spec/unit/util/ec2_spec.rb +112 -0
- data/spec/unit/util/fact_spec.rb +2 -3
- data/spec/unit/util/ip_spec.rb +27 -55
- data/spec/unit/util/loader_spec.rb +2 -4
- data/spec/unit/util/macaddress_spec.rb +4 -5
- data/spec/unit/util/macosx_spec.rb +2 -3
- data/spec/unit/util/manufacturer_spec.rb +8 -9
- data/spec/unit/util/processor_spec.rb +8 -10
- data/spec/unit/util/resolution_spec.rb +2 -3
- data/spec/unit/util/uptime_spec.rb +15 -14
- data/spec/unit/util/virtual_spec.rb +10 -2
- data/spec/unit/util/vlans_spec.rb +3 -5
- data/spec/unit/util/wmi_spec.rb +2 -3
- data/spec/unit/util/xendomains_spec.rb +3 -5
- data/spec/unit/virtual_spec.rb +48 -18
- metadata +44 -28
- data/spec/fixtures/uptime/sysctl_kern_boottime_big_endian +0 -0
- data/spec/fixtures/uptime/sysctl_kern_boottime_little_endian +0 -0
data/spec/unit/domain_spec.rb
CHANGED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter/util/ec2'
|
5
|
+
|
6
|
+
describe "ec2 facts" do
|
7
|
+
# This is the standard prefix for making an API call in EC2 (or fake)
|
8
|
+
# environments.
|
9
|
+
let(:api_prefix) { "http://169.254.169.254" }
|
10
|
+
|
11
|
+
describe "when running on ec2" do
|
12
|
+
before :each do
|
13
|
+
# This is an ec2 instance, not a eucalyptus instance
|
14
|
+
Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(false)
|
15
|
+
Facter::Util::EC2.expects(:has_ec2_arp?).at_least_once.returns(true)
|
16
|
+
|
17
|
+
# Assume we can connect
|
18
|
+
Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should create flat meta-data facts" do
|
22
|
+
Object.any_instance.expects(:open).
|
23
|
+
with("#{api_prefix}/2008-02-01/meta-data/").
|
24
|
+
at_least_once.returns(StringIO.new("foo"))
|
25
|
+
|
26
|
+
Object.any_instance.expects(:open).
|
27
|
+
with("#{api_prefix}/2008-02-01/meta-data/foo").
|
28
|
+
at_least_once.returns(StringIO.new("bar"))
|
29
|
+
|
30
|
+
# No user-data
|
31
|
+
Object.any_instance.expects(:open).
|
32
|
+
with("#{api_prefix}/2008-02-01/user-data/").
|
33
|
+
at_least_once.returns(StringIO.new(""))
|
34
|
+
|
35
|
+
Facter.collection.loader.load(:ec2)
|
36
|
+
Facter.fact(:ec2_foo).value.should == "bar"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should create flat meta-data facts with comma seperation" do
|
40
|
+
Object.any_instance.expects(:open).
|
41
|
+
with("#{api_prefix}/2008-02-01/meta-data/").
|
42
|
+
at_least_once.returns(StringIO.new("foo"))
|
43
|
+
|
44
|
+
Object.any_instance.expects(:open).
|
45
|
+
with("#{api_prefix}/2008-02-01/meta-data/foo").
|
46
|
+
at_least_once.returns(StringIO.new("bar\nbaz"))
|
47
|
+
|
48
|
+
# No user-data
|
49
|
+
Object.any_instance.expects(:open).
|
50
|
+
with("#{api_prefix}/2008-02-01/user-data/").
|
51
|
+
at_least_once.returns(StringIO.new(""))
|
52
|
+
|
53
|
+
Facter.collection.loader.load(:ec2)
|
54
|
+
Facter.fact(:ec2_foo).value.should == "bar,baz"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should create structured meta-data facts" do
|
58
|
+
Object.any_instance.expects(:open).
|
59
|
+
with("#{api_prefix}/2008-02-01/meta-data/").
|
60
|
+
at_least_once.returns(StringIO.new("foo/"))
|
61
|
+
|
62
|
+
Object.any_instance.expects(:open).
|
63
|
+
with("#{api_prefix}/2008-02-01/meta-data/foo/").
|
64
|
+
at_least_once.returns(StringIO.new("bar"))
|
65
|
+
|
66
|
+
Object.any_instance.expects(:open).
|
67
|
+
with("#{api_prefix}/2008-02-01/meta-data/foo/bar").
|
68
|
+
at_least_once.returns(StringIO.new("baz"))
|
69
|
+
|
70
|
+
# No user-data
|
71
|
+
Object.any_instance.expects(:open).
|
72
|
+
with("#{api_prefix}/2008-02-01/user-data/").
|
73
|
+
at_least_once.returns(StringIO.new(""))
|
74
|
+
|
75
|
+
Facter.collection.loader.load(:ec2)
|
76
|
+
Facter.fact(:ec2_foo_bar).value.should == "baz"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should create ec2_user_data fact" do
|
80
|
+
# No meta-data
|
81
|
+
Object.any_instance.expects(:open).
|
82
|
+
with("#{api_prefix}/2008-02-01/meta-data/").
|
83
|
+
at_least_once.returns(StringIO.new(""))
|
84
|
+
|
85
|
+
Object.any_instance.expects(:open).
|
86
|
+
with("#{api_prefix}/2008-02-01/user-data/").
|
87
|
+
at_least_once.returns(StringIO.new("test"))
|
88
|
+
|
89
|
+
Facter.collection.loader.load(:ec2)
|
90
|
+
Facter.fact(:ec2_userdata).value.should == ["test"]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "when running on eucalyptus" do
|
95
|
+
before :each do
|
96
|
+
# Return false for ec2, true for eucalyptus
|
97
|
+
Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true)
|
98
|
+
Facter::Util::EC2.expects(:has_ec2_arp?).never
|
99
|
+
|
100
|
+
# Assume we can connect
|
101
|
+
Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should create ec2_user_data fact" do
|
105
|
+
# No meta-data
|
106
|
+
Object.any_instance.expects(:open).\
|
107
|
+
with("#{api_prefix}/2008-02-01/meta-data/").\
|
108
|
+
at_least_once.returns(StringIO.new(""))
|
109
|
+
|
110
|
+
Object.any_instance.expects(:open).\
|
111
|
+
with("#{api_prefix}/2008-02-01/user-data/").\
|
112
|
+
at_least_once.returns(StringIO.new("test"))
|
113
|
+
|
114
|
+
# Force a fact load
|
115
|
+
Facter.collection.loader.load(:ec2)
|
116
|
+
|
117
|
+
Facter.fact(:ec2_userdata).value.should == ["test"]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "when api connect test fails" do
|
122
|
+
it "should not populate ec2_userdata" do
|
123
|
+
# Emulate ec2 for now as it matters little to this test
|
124
|
+
Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true)
|
125
|
+
Facter::Util::EC2.expects(:has_ec2_arp?).never
|
126
|
+
Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(false)
|
127
|
+
|
128
|
+
# The API should never be called at this point
|
129
|
+
Object.any_instance.expects(:open).
|
130
|
+
with("#{api_prefix}/2008-02-01/meta-data/").never
|
131
|
+
Object.any_instance.expects(:open).
|
132
|
+
with("#{api_prefix}/2008-02-01/user-data/").never
|
133
|
+
|
134
|
+
# Force a fact load
|
135
|
+
Facter.collection.loader.load(:ec2)
|
136
|
+
|
137
|
+
Facter.fact(:ec2_userdata).should == nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/spec/unit/facter_spec.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter'
|
5
|
+
|
6
|
+
describe "Hardwareisa fact" do
|
7
|
+
it "should match uname -p on Linux" do
|
8
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
9
|
+
Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Inky")
|
10
|
+
|
11
|
+
Facter.fact(:hardwareisa).value.should == "Inky"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should match uname -p on Darwin" do
|
15
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
16
|
+
Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Blinky")
|
17
|
+
|
18
|
+
Facter.fact(:hardwareisa).value.should == "Blinky"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should match uname -p on SunOS" do
|
22
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
23
|
+
Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Pinky")
|
24
|
+
|
25
|
+
Facter.fact(:hardwareisa).value.should == "Pinky"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should match uname -p on FreeBSD" do
|
29
|
+
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
30
|
+
Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Clyde")
|
31
|
+
|
32
|
+
Facter.fact(:hardwareisa).value.should == "Clyde"
|
33
|
+
end
|
34
|
+
end
|
data/spec/unit/hostname_spec.rb
CHANGED
data/spec/unit/id_spec.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
|
-
|
4
|
-
require File.join($basedir, 'spec_helper')
|
5
|
-
|
6
|
-
require 'facter'
|
3
|
+
require 'spec_helper'
|
7
4
|
|
8
5
|
def ifconfig_fixture(filename)
|
9
|
-
|
6
|
+
File.read(fixtures('ifconfig', filename))
|
10
7
|
end
|
11
8
|
|
12
9
|
def netsh_fixture(filename)
|
13
|
-
|
10
|
+
File.read(fixtures('netsh', filename))
|
14
11
|
end
|
15
12
|
|
16
13
|
describe "IPv6 address fact" do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter'
|
5
|
+
|
6
|
+
describe "LSB distribution major release fact" do
|
7
|
+
it "should be derived from lsb_release" do
|
8
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
9
|
+
Facter.stubs(:value).with(:lsbdistrelease).returns("10.10")
|
10
|
+
|
11
|
+
Facter.fact(:lsbmajdistrelease).value.should == "10"
|
12
|
+
end
|
13
|
+
end
|
@@ -1,16 +1,13 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
|
-
|
4
|
-
require File.join($basedir, 'spec_helper')
|
5
|
-
|
6
|
-
require 'facter'
|
3
|
+
require 'spec_helper'
|
7
4
|
|
8
5
|
def ifconfig_fixture(filename)
|
9
|
-
|
6
|
+
File.read(fixtures('ifconfig', filename))
|
10
7
|
end
|
11
8
|
|
12
9
|
def netsh_fixture(filename)
|
13
|
-
|
10
|
+
File.read(fixtures('netsh', filename))
|
14
11
|
end
|
15
12
|
|
16
13
|
describe "macaddress fact" do
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require 'facter'
|
3
|
+
require 'spec_helper'
|
6
4
|
|
7
5
|
describe "Memory facts" do
|
8
6
|
before do
|
@@ -78,7 +76,7 @@ EOS
|
|
78
76
|
end
|
79
77
|
|
80
78
|
it "should return the current memorysize" do
|
81
|
-
Facter.fact(:
|
79
|
+
Facter.fact(:memorysize).value.should == "254.94 MB"
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -118,7 +116,7 @@ EOS
|
|
118
116
|
end
|
119
117
|
|
120
118
|
it "should return the current memorysize" do
|
121
|
-
Facter.fact(:
|
119
|
+
Facter.fact(:memorysize).value.should == "237.00 MB"
|
122
120
|
end
|
123
121
|
end
|
124
122
|
|
@@ -147,4 +145,11 @@ EOS
|
|
147
145
|
Facter.fact(:MemoryTotal).value.should == '3.91 GB'
|
148
146
|
end
|
149
147
|
end
|
148
|
+
|
149
|
+
it "should use the memorysize fact for the memorytotal fact" do
|
150
|
+
Facter.fact("memorysize").expects(:value).once.returns "yay"
|
151
|
+
Facter::Util::Resolution.expects(:exec).never
|
152
|
+
Facter::Memory.expects(:meminfo_number).never
|
153
|
+
Facter.fact("memorytotal").value.should == "yay"
|
154
|
+
end
|
150
155
|
end
|
@@ -1,17 +1,11 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require 'facter'
|
3
|
+
require 'spec_helper'
|
6
4
|
|
7
5
|
describe "Operating System fact" do
|
8
6
|
|
9
|
-
before do
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
Facter.clear
|
7
|
+
before :each do
|
8
|
+
FileTest.stubs(:exists?).returns false
|
15
9
|
end
|
16
10
|
|
17
11
|
it "should default to the kernel name" do
|
@@ -19,74 +13,112 @@ describe "Operating System fact" do
|
|
19
13
|
|
20
14
|
Facter.fact(:operatingsystem).value.should == "Nutmeg"
|
21
15
|
end
|
22
|
-
|
23
|
-
it "should be Solaris for SunOS" do
|
24
|
-
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
25
|
-
|
26
|
-
Facter.fact(:operatingsystem).value.should == "Solaris"
|
27
|
-
end
|
28
|
-
|
29
16
|
it "should be ESXi for VMkernel" do
|
30
17
|
Facter.fact(:kernel).stubs(:value).returns("VMkernel")
|
31
18
|
|
32
19
|
Facter.fact(:operatingsystem).value.should == "ESXi"
|
33
20
|
end
|
34
21
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
describe "on Solaris variants" do
|
23
|
+
before :each do
|
24
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
25
|
+
end
|
39
26
|
|
40
|
-
|
41
|
-
|
27
|
+
it "should be Nexenta if /etc/debian_version is present" do
|
28
|
+
FileTest.expects(:exists?).with("/etc/debian_version").returns true
|
29
|
+
Facter.fact(:operatingsystem).value.should == "Nexenta"
|
30
|
+
end
|
42
31
|
|
43
|
-
|
32
|
+
it "should be Solaris for SunOS if no other variants match" do
|
33
|
+
Facter.fact(:operatingsystem).value.should == "Solaris"
|
34
|
+
end
|
44
35
|
end
|
45
|
-
|
46
|
-
it "should identify VMWare ESX" do
|
47
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
48
|
-
Facter.stubs(:value).with(:lsbdistid).returns(nil)
|
49
|
-
FileTest.stubs(:exists?).returns false
|
50
|
-
|
51
|
-
FileTest.expects(:exists?).with("/etc/vmware-release").returns true
|
52
|
-
|
53
|
-
Facter.fact(:operatingsystem).value.should == "VMWareESX"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should identify Alpine Linux" do
|
57
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
58
|
-
|
59
|
-
FileTest.stubs(:exists?).returns false
|
60
|
-
|
61
|
-
FileTest.expects(:exists?).with("/etc/alpine-release").returns true
|
62
|
-
|
63
|
-
Facter.fact(:operatingsystem).value.should == "Alpine"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should identify Scientific Linux" do
|
67
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
68
|
-
FileTest.stubs(:exists?).returns false
|
69
|
-
|
70
|
-
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
71
|
-
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux SLC 5.7 (Boron)")
|
72
|
-
Facter.fact(:operatingsystem).value.should == "Scientific"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should differentiate between Scientific Linux CERN and Scientific Linux" do
|
76
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
77
|
-
FileTest.stubs(:exists?).returns false
|
78
|
-
|
79
|
-
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
80
|
-
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)")
|
81
|
-
Facter.fact(:operatingsystem).value.should == "SLC"
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should identify Ascendos Linux" do
|
85
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
86
|
-
FileTest.stubs(:exists?).returns false
|
87
36
|
|
88
|
-
|
89
|
-
|
90
|
-
|
37
|
+
describe "on Linux" do
|
38
|
+
before :each do
|
39
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
40
|
+
end
|
41
|
+
|
42
|
+
{
|
43
|
+
"Debian" => "/etc/debian_version",
|
44
|
+
"Gentoo" => "/etc/gentoo-release",
|
45
|
+
"Fedora" => "/etc/fedora-release",
|
46
|
+
"Mandriva" => "/etc/mandriva-release",
|
47
|
+
"Mandrake" => "/etc/mandrake-release",
|
48
|
+
"MeeGo" => "/etc/meego-release",
|
49
|
+
"Archlinux" => "/etc/arch-release",
|
50
|
+
"OracleLinux" => "/etc/oracle-release",
|
51
|
+
"Alpine" => "/etc/alpine-release",
|
52
|
+
"VMWareESX" => "/etc/vmware-release",
|
53
|
+
"Bluewhite64" => "/etc/bluewhite64-version",
|
54
|
+
"Slamd64" => "/etc/slamd64-version",
|
55
|
+
"Slackware" => "/etc/slackware-version",
|
56
|
+
"Amazon" => "/etc/system-release",
|
57
|
+
}.each_pair do |distribution, releasefile|
|
58
|
+
it "should be #{distribution} if #{releasefile} exists" do
|
59
|
+
FileTest.expects(:exists?).with(releasefile).returns true
|
60
|
+
Facter.fact(:operatingsystem).value.should == distribution
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "depending on LSB release information" do
|
65
|
+
before :each do
|
66
|
+
Facter.collection.loader.load(:lsb)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "on Ubuntu should use the lsbdistid fact" do
|
70
|
+
FileUtils.stubs(:exists?).with("/etc/debian_version").returns true
|
71
|
+
|
72
|
+
Facter.fact(:lsbdistid).expects(:value).returns("Ubuntu")
|
73
|
+
Facter.fact(:operatingsystem).value.should == "Ubuntu"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Check distributions that rely on the contents of /etc/redhat-release
|
80
|
+
{
|
81
|
+
"RedHat" => "Red Hat Enterprise Linux Server release 6.0 (Santiago)",
|
82
|
+
"CentOS" => "CentOS release 5.6 (Final)",
|
83
|
+
"Scientific" => "Scientific Linux release 6.0 (Carbon)",
|
84
|
+
"SLC" => "Scientific Linux CERN SLC release 5.7 (Boron)",
|
85
|
+
"Ascendos" => "Ascendos release 6.0 (Nameless)",
|
86
|
+
"CloudLinux" => "CloudLinux Server release 5.5",
|
87
|
+
}.each_pair do |operatingsystem, string|
|
88
|
+
it "should be #{operatingsystem} based on /etc/redhat-release contents #{string}" do
|
89
|
+
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
90
|
+
File.expects(:read).with("/etc/redhat-release").returns string
|
91
|
+
|
92
|
+
Facter.fact(:operatingsystem).value.should == operatingsystem
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "Oracle variant" do
|
97
|
+
it "should be OVS if /etc/ovs-release exists" do
|
98
|
+
Facter.stubs(:value).with(:lsbdistid)
|
99
|
+
FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
|
100
|
+
FileTest.expects(:exists?).with("/etc/ovs-release").returns true
|
101
|
+
Facter.fact(:operatingsystem).value.should == "OVS"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should be OEL if /etc/ovs-release doesn't exist" do
|
105
|
+
FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
|
106
|
+
FileTest.expects(:exists?).with("/etc/ovs-release").returns false
|
107
|
+
Facter.fact(:operatingsystem).value.should == "OEL"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should identify VMWare ESX" do
|
112
|
+
Facter.stubs(:value).with(:lsbdistid).returns(nil)
|
113
|
+
|
114
|
+
FileTest.expects(:exists?).with("/etc/vmware-release").returns true
|
115
|
+
Facter.fact(:operatingsystem).value.should == "VMWareESX"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should differentiate between Scientific Linux CERN and Scientific Linux" do
|
119
|
+
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
120
|
+
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)")
|
121
|
+
Facter.fact(:operatingsystem).value.should == "SLC"
|
122
|
+
end
|
91
123
|
end
|
92
124
|
end
|