facter 1.6.18 → 1.7.0.rc1
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/Gemfile +23 -8
- data/bin/facter +4 -1
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/changelog.erb +4 -22
- data/ext/debian/control +2 -2
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/facter.spec.erb +10 -9
- data/install.rb +27 -53
- data/lib/facter.rb +23 -5
- data/lib/facter/application.rb +21 -0
- data/lib/facter/blockdevices.rb +105 -0
- data/lib/facter/domain.rb +19 -7
- data/lib/facter/filesystems.rb +38 -0
- data/lib/facter/hardwaremodel.rb +3 -2
- data/lib/facter/ipaddress6.rb +1 -2
- data/lib/facter/kernelrelease.rb +10 -2
- data/lib/facter/ldom.rb +47 -0
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/manufacturer.rb +7 -1
- data/lib/facter/memory.rb +58 -160
- data/lib/facter/operatingsystem.rb +17 -2
- data/lib/facter/operatingsystemmajrelease.rb +33 -0
- data/lib/facter/operatingsystemrelease.rb +88 -37
- data/lib/facter/osfamily.rb +6 -2
- data/lib/facter/processor.rb +2 -2
- data/lib/facter/ps.rb +5 -0
- data/lib/facter/ssh.rb +50 -12
- data/lib/facter/util/cfpropertylist.rb +6 -0
- data/lib/facter/util/cfpropertylist/LICENSE +19 -0
- data/lib/facter/util/cfpropertylist/README +44 -0
- data/lib/facter/util/cfpropertylist/Rakefile +44 -0
- data/lib/facter/util/cfpropertylist/THANKS +7 -0
- data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +6 -0
- data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +562 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +26 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +402 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +244 -0
- data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +135 -0
- data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +140 -0
- data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +136 -0
- data/lib/facter/util/collection.rb +36 -14
- data/lib/facter/util/composite_loader.rb +12 -0
- data/lib/facter/util/config.rb +36 -0
- data/lib/facter/util/confine.rb +1 -6
- data/lib/facter/util/directory_loader.rb +83 -0
- data/lib/facter/util/fact.rb +49 -42
- data/lib/facter/util/file_read.rb +32 -0
- data/lib/facter/util/ip.rb +2 -9
- data/lib/facter/util/loader.rb +16 -2
- data/lib/facter/util/macosx.rb +15 -2
- data/lib/facter/util/memory.rb +154 -27
- data/lib/facter/util/nothing_loader.rb +15 -0
- data/lib/facter/util/parser.rb +141 -0
- data/lib/facter/util/processor.rb +27 -35
- data/lib/facter/util/resolution.rb +97 -26
- data/lib/facter/util/solaris_zones.rb +153 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/version.rb +72 -2
- data/lib/facter/virtual.rb +56 -3
- data/lib/facter/zfs_version.rb +10 -0
- data/lib/facter/zonename.rb +6 -0
- data/lib/facter/zones.rb +17 -0
- data/lib/facter/zpool_version.rb +10 -0
- data/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/ldom/ldom_v1 +6 -0
- data/spec/fixtures/unit/filesystems/linux +28 -0
- data/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode +549 -0
- data/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt +0 -0
- data/spec/fixtures/unit/zfs_version/freebsd_8.2 +14 -0
- data/spec/fixtures/unit/zfs_version/freebsd_9.0 +13 -0
- data/spec/fixtures/unit/zfs_version/linux-fuse_0.6.9 +14 -0
- data/spec/fixtures/unit/zfs_version/solaris_10 +10 -0
- data/spec/fixtures/unit/zfs_version/solaris_11 +12 -0
- data/spec/fixtures/unit/zpool_version/freebsd_8.2 +26 -0
- data/spec/fixtures/unit/zpool_version/freebsd_9.0 +38 -0
- data/spec/fixtures/unit/zpool_version/linux-fuse_0.6.9 +35 -0
- data/spec/fixtures/unit/zpool_version/solaris_10 +31 -0
- data/spec/fixtures/unit/zpool_version/solaris_11 +43 -0
- data/spec/integration/facter_spec.rb +12 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/unit/architecture_spec.rb +1 -1
- data/spec/unit/blockdevices_spec.rb +109 -0
- data/spec/unit/domain_spec.rb +189 -81
- data/spec/unit/ec2_spec.rb +15 -8
- data/spec/unit/filesystems_spec.rb +50 -0
- data/spec/unit/hardwaremodel_spec.rb +8 -1
- data/spec/unit/id_spec.rb +6 -5
- data/spec/unit/ipaddress6_spec.rb +14 -2
- data/spec/unit/ipaddress_spec.rb +1 -1
- data/spec/unit/kernel_spec.rb +24 -0
- data/spec/unit/kernelmajversion_spec.rb +17 -0
- data/spec/unit/kernelrelease_spec.rb +53 -0
- data/spec/unit/kernelversion_spec.rb +32 -0
- data/spec/unit/ldom_spec.rb +74 -0
- data/spec/unit/macaddress_spec.rb +3 -1
- data/spec/unit/manufacturer_spec.rb +115 -0
- data/spec/unit/memory_spec.rb +442 -75
- data/spec/unit/operatingsystem_spec.rb +16 -2
- data/spec/unit/operatingsystemmajrelease_spec.rb +16 -0
- data/spec/unit/operatingsystemrelease_spec.rb +110 -1
- data/spec/unit/processor_spec.rb +22 -7
- data/spec/unit/ps_spec.rb +42 -0
- data/spec/unit/ssh_spec.rb +76 -0
- data/spec/unit/util/collection_spec.rb +94 -118
- data/spec/unit/util/config_spec.rb +36 -5
- data/spec/unit/util/confine_spec.rb +31 -43
- data/spec/unit/util/directory_loader_spec.rb +87 -0
- data/spec/unit/util/fact_spec.rb +37 -25
- data/spec/unit/util/file_read_spec.rb +29 -0
- data/spec/unit/util/ip_spec.rb +4 -2
- data/spec/unit/util/loader_spec.rb +102 -45
- data/spec/unit/util/macosx_spec.rb +40 -9
- data/spec/unit/util/manufacturer_spec.rb +12 -1
- data/spec/unit/util/parser_spec.rb +135 -0
- data/spec/unit/util/resolution_spec.rb +136 -4
- data/spec/unit/util/solaris_zones_spec.rb +127 -0
- data/spec/unit/util/virtual_spec.rb +54 -0
- data/spec/unit/version_spec.rb +42 -0
- data/spec/unit/virtual_spec.rb +102 -27
- data/spec/unit/zfs_version_spec.rb +76 -0
- data/spec/unit/zonename_spec.rb +14 -0
- data/spec/unit/zones_spec.rb +55 -0
- data/spec/unit/zpool_version_spec.rb +76 -0
- metadata +113 -11
- data/lib/facter/arp.rb +0 -28
data/spec/unit/ec2_spec.rb
CHANGED
@@ -28,7 +28,8 @@ describe "ec2 facts" do
|
|
28
28
|
with("#{api_prefix}/2008-02-01/meta-data/foo").
|
29
29
|
at_least_once.returns(StringIO.new("bar"))
|
30
30
|
|
31
|
-
Facter.collection.
|
31
|
+
Facter.collection.internal_loader.load(:ec2)
|
32
|
+
|
32
33
|
Facter.fact(:ec2_foo).value.should == "bar"
|
33
34
|
end
|
34
35
|
|
@@ -41,7 +42,8 @@ describe "ec2 facts" do
|
|
41
42
|
with("#{api_prefix}/2008-02-01/meta-data/foo").
|
42
43
|
at_least_once.returns(StringIO.new("bar\nbaz"))
|
43
44
|
|
44
|
-
Facter.collection.
|
45
|
+
Facter.collection.internal_loader.load(:ec2)
|
46
|
+
|
45
47
|
Facter.fact(:ec2_foo).value.should == "bar,baz"
|
46
48
|
end
|
47
49
|
|
@@ -58,7 +60,8 @@ describe "ec2 facts" do
|
|
58
60
|
with("#{api_prefix}/2008-02-01/meta-data/foo/bar").
|
59
61
|
at_least_once.returns(StringIO.new("baz"))
|
60
62
|
|
61
|
-
Facter.collection.
|
63
|
+
Facter.collection.internal_loader.load(:ec2)
|
64
|
+
|
62
65
|
Facter.fact(:ec2_foo_bar).value.should == "baz"
|
63
66
|
end
|
64
67
|
|
@@ -72,7 +75,7 @@ describe "ec2 facts" do
|
|
72
75
|
with("#{api_prefix}/latest/user-data/").
|
73
76
|
returns("test")
|
74
77
|
|
75
|
-
Facter.collection.
|
78
|
+
Facter.collection.internal_loader.load(:ec2)
|
76
79
|
Facter.fact(:ec2_userdata).value.should == ["test"]
|
77
80
|
end
|
78
81
|
end
|
@@ -99,7 +102,7 @@ describe "ec2 facts" do
|
|
99
102
|
returns("test")
|
100
103
|
|
101
104
|
# Force a fact load
|
102
|
-
Facter.collection.
|
105
|
+
Facter.collection.internal_loader.load(:ec2)
|
103
106
|
|
104
107
|
Facter.fact(:ec2_userdata).value.should == ["test"]
|
105
108
|
end
|
@@ -127,7 +130,7 @@ describe "ec2 facts" do
|
|
127
130
|
returns("test")
|
128
131
|
|
129
132
|
# Force a fact load
|
130
|
-
Facter.collection.
|
133
|
+
Facter.collection.internal_loader.load(:ec2)
|
131
134
|
|
132
135
|
Facter.fact(:ec2_userdata).value.should == ["test"]
|
133
136
|
end
|
@@ -145,7 +148,7 @@ describe "ec2 facts" do
|
|
145
148
|
raises(RuntimeError, 'host unreachable')
|
146
149
|
|
147
150
|
# Force a fact load
|
148
|
-
Facter.collection.
|
151
|
+
Facter.collection.internal_loader.load(:ec2)
|
149
152
|
|
150
153
|
Facter.fact(:ec2_userdata).value.should be_nil
|
151
154
|
end
|
@@ -153,6 +156,10 @@ describe "ec2 facts" do
|
|
153
156
|
end
|
154
157
|
|
155
158
|
describe "when api connect test fails" do
|
159
|
+
before :each do
|
160
|
+
Facter.stubs(:warnonce)
|
161
|
+
end
|
162
|
+
|
156
163
|
it "should not populate ec2_userdata" do
|
157
164
|
# Emulate ec2 for now as it matters little to this test
|
158
165
|
Facter::Util::EC2.stubs(:has_euca_mac?).returns(true)
|
@@ -166,7 +173,7 @@ describe "ec2 facts" do
|
|
166
173
|
with("#{api_prefix}/2008-02-01/user-data/").never
|
167
174
|
|
168
175
|
# Force a fact load
|
169
|
-
Facter.collection.
|
176
|
+
Facter.collection.internal_loader.load(:ec2)
|
170
177
|
|
171
178
|
Facter.fact(:ec2_userdata).should == nil
|
172
179
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Filesystem facts' do
|
6
|
+
describe 'on non-Linux OS' do
|
7
|
+
it 'should not exist' do
|
8
|
+
Facter.fact(:kernel).stubs(:value).returns('SunOS')
|
9
|
+
Facter.fact(:filesystems).value.should == nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'on Linux' do
|
14
|
+
before :each do
|
15
|
+
Facter.fact(:kernel).stubs(:value).returns('Linux')
|
16
|
+
fixture_data = my_fixture_read('linux')
|
17
|
+
Facter::Util::Resolution.expects(:exec) \
|
18
|
+
.with('cat /proc/filesystems 2> /dev/null').returns(fixture_data)
|
19
|
+
Facter.collection.internal_loader.load(:filesystems)
|
20
|
+
end
|
21
|
+
|
22
|
+
after :each do
|
23
|
+
Facter.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should exist' do
|
27
|
+
Facter.fact(:filesystems).value.should_not == nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should detect the correct number of filesystems' do
|
31
|
+
Facter.fact(:filesystems).value.split(',').length.should == 6
|
32
|
+
end
|
33
|
+
|
34
|
+
# Check that lines from /proc/filesystems that start with 'nodev' are
|
35
|
+
# skipped
|
36
|
+
it 'should not detect sysfs' do
|
37
|
+
Facter.fact(:filesystems).value.split(',').should_not include('sysfs')
|
38
|
+
end
|
39
|
+
|
40
|
+
# Check that all other lines are counted as valid filesystems
|
41
|
+
it 'should detect ext4' do
|
42
|
+
Facter.fact(:filesystems).value.split(',').should include('ext4')
|
43
|
+
end
|
44
|
+
|
45
|
+
# fuseblk is never included in the filesystem list
|
46
|
+
it 'should not detect fuseblk' do
|
47
|
+
Facter.fact(:filesystems).value.split(',').should_not include('fuseblk')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -25,10 +25,17 @@ describe "Hardwaremodel fact" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should detect x64" do
|
28
|
-
cpu = mock('cpu', :Architecture => 9)
|
28
|
+
cpu = mock('cpu', :Architecture => 9, :AddressWidth => 64)
|
29
29
|
Facter::Util::WMI.expects(:execquery).returns([cpu])
|
30
30
|
|
31
31
|
Facter.fact(:hardwaremodel).value.should == "x64"
|
32
32
|
end
|
33
|
+
|
34
|
+
it "(#16948) reports i686 when a 32 bit OS is running on a 64 bit CPU" do
|
35
|
+
cpu = mock('cpu', :Architecture => 9, :AddressWidth => 32, :Level => 6)
|
36
|
+
Facter::Util::WMI.expects(:execquery).returns([cpu])
|
37
|
+
|
38
|
+
Facter.fact(:hardwaremodel).value.should == "i686"
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
data/spec/unit/id_spec.rb
CHANGED
@@ -3,14 +3,15 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe "id fact" do
|
6
|
+
include FacterSpec::ConfigHelper
|
6
7
|
|
7
8
|
kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ]
|
8
9
|
|
9
10
|
kernel.each do |k|
|
10
11
|
describe "with kernel reported as #{k}" do
|
11
12
|
it "should return the current user" do
|
13
|
+
given_a_configuration_of(:is_windows => k == 'windows')
|
12
14
|
Facter.fact(:kernel).stubs(:value).returns(k)
|
13
|
-
Facter::Util::Config.stubs(:is_windows?).returns(k == 'windows')
|
14
15
|
Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar'
|
15
16
|
|
16
17
|
Facter.fact(:id).value.should == 'bar'
|
@@ -19,10 +20,10 @@ describe "id fact" do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should return the current user on Solaris" do
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
given_a_configuration_of(:is_windows => false)
|
24
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
|
25
|
+
Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar'
|
25
26
|
|
26
|
-
|
27
|
+
Facter.fact(:id).value.should == 'bar'
|
27
28
|
end
|
28
29
|
end
|
@@ -11,9 +11,12 @@ def netsh_fixture(filename)
|
|
11
11
|
File.read(fixtures('netsh', filename))
|
12
12
|
end
|
13
13
|
|
14
|
+
|
14
15
|
describe "IPv6 address fact" do
|
16
|
+
include FacterSpec::ConfigHelper
|
17
|
+
|
15
18
|
before do
|
16
|
-
|
19
|
+
given_a_configuration_of(:is_windows => false)
|
17
20
|
end
|
18
21
|
|
19
22
|
it "should return ipaddress6 information for Darwin" do
|
@@ -34,6 +37,15 @@ describe "IPv6 address fact" do
|
|
34
37
|
Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
|
35
38
|
end
|
36
39
|
|
40
|
+
it "should return ipaddress6 information for Linux with recent net-tools" do
|
41
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux')
|
42
|
+
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
43
|
+
Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
|
44
|
+
returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt'))
|
45
|
+
|
46
|
+
Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
|
47
|
+
end
|
48
|
+
|
37
49
|
it "should return ipaddress6 information for Solaris" do
|
38
50
|
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
|
39
51
|
Facter::Util::IP.stubs(:get_ifconfig).returns("/usr/sbin/ifconfig")
|
@@ -45,7 +57,7 @@ describe "IPv6 address fact" do
|
|
45
57
|
|
46
58
|
it "should return ipaddress6 information for Windows" do
|
47
59
|
ENV.stubs(:[]).with('SYSTEMROOT').returns('d:/windows')
|
48
|
-
|
60
|
+
given_a_configuration_of(:is_windows => true)
|
49
61
|
|
50
62
|
fixture = netsh_fixture('windows_netsh_addresses_with_multiple_interfaces')
|
51
63
|
Facter::Util::Resolution.stubs(:exec).with('d:/windows/system32/netsh.exe interface ipv6 show address level=verbose').
|
data/spec/unit/ipaddress_spec.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Kernel fact" do
|
6
|
+
include FacterSpec::ConfigHelper
|
7
|
+
|
8
|
+
describe "on Windows" do
|
9
|
+
it "should return the kernel as 'windows'" do
|
10
|
+
given_a_configuration_of(:is_windows => true, :data_dir => "data_dir")
|
11
|
+
|
12
|
+
Facter.fact(:kernel).value.should == "windows"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "on everything else" do
|
17
|
+
it "should return the kernel using 'uname -s'" do
|
18
|
+
given_a_configuration_of(:is_windows => false)
|
19
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns("test_kernel")
|
20
|
+
|
21
|
+
Facter.fact(:kernel).value.should == 'test_kernel'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Kernel major version fact" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Facter.fact(:kernelversion).stubs(:value).returns("12.34.56")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return the kernel major release using the kernel release" do
|
12
|
+
Facter.fact(:kernelmajversion).value.should == "12.34"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Kernel release fact" do
|
6
|
+
|
7
|
+
describe "on Windows" do
|
8
|
+
before do
|
9
|
+
Facter.fact(:kernel).stubs(:value).returns("windows")
|
10
|
+
require 'facter/util/wmi'
|
11
|
+
version = stubs 'version'
|
12
|
+
version.stubs(:Version).returns("test_kernel")
|
13
|
+
Facter::Util::WMI.stubs(:execquery).with("SELECT Version from Win32_OperatingSystem").returns([version])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return the kernel release" do
|
17
|
+
Facter.fact(:kernelrelease).value.should == "test_kernel"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "on AIX" do
|
22
|
+
before do
|
23
|
+
Facter.fact(:kernel).stubs(:value).returns("aix")
|
24
|
+
Facter::Util::Resolution.stubs(:exec).with('oslevel -s').returns("test_kernel")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the kernel release" do
|
28
|
+
Facter.fact(:kernelrelease).value.should == "test_kernel"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "on HP-UX" do
|
33
|
+
before do
|
34
|
+
Facter.fact(:kernel).stubs(:value).returns("hp-ux")
|
35
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -r').returns("B.11.31")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should remove preceding letters" do
|
39
|
+
Facter.fact(:kernelrelease).value.should == "11.31"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "on everything else" do
|
44
|
+
before do
|
45
|
+
Facter.fact(:kernel).stubs(:value).returns("linux")
|
46
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -r').returns("test_kernel")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return the kernel release" do
|
50
|
+
Facter.fact(:kernelrelease).value.should == "test_kernel"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Kernel version fact" do
|
6
|
+
|
7
|
+
describe "on Solaris/Sun OS" do
|
8
|
+
before do
|
9
|
+
Facter.fact(:kernel).stubs(:value).returns('sunos')
|
10
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -v').returns("1.234.5")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return the kernel version using 'uname -v'" do
|
14
|
+
Facter.fact(:kernelversion).value.should == "1.234.5"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "on everything else" do
|
19
|
+
before do
|
20
|
+
Facter.fact(:kernel).stubs(:value).returns('linux')
|
21
|
+
Facter.fact(:kernelrelease).stubs(:value).returns('1.23.4-56')
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the kernel version using kernel release" do
|
25
|
+
Facter.fact(:kernelversion).value.should == "1.23.4"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
def ldom_fixtures(filename)
|
6
|
+
File.read(fixtures('ldom', filename))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "ldom fact" do
|
10
|
+
before do
|
11
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when running on ldom hardware" do
|
15
|
+
before :each do
|
16
|
+
# For virtinfo documentation:
|
17
|
+
# http://docs.oracle.com/cd/E23824_01/html/821-1462/virtinfo-1m.html
|
18
|
+
Facter::Util::Resolution.stubs(:exec).with("virtinfo -ap").
|
19
|
+
returns(ldom_fixtures('ldom_v1'))
|
20
|
+
Facter.collection.internal_loader.load(:ldom)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return correct impl on version 1.0" do
|
24
|
+
Facter.fact(:ldom_domainrole_impl).value.should == "LDoms"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return correct control on version 1.0" do
|
28
|
+
Facter.fact(:ldom_domainrole_control).value.should == "false"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return correct io on version 1.0" do
|
32
|
+
Facter.fact(:ldom_domainrole_io).value.should == "true"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return correct service on version 1.0" do
|
36
|
+
Facter.fact(:ldom_domainrole_service).value.should == "true"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return correct root on version 1.0" do
|
40
|
+
Facter.fact(:ldom_domainrole_root).value.should == "true"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return correct domain name on version 1.0" do
|
44
|
+
Facter.fact(:ldom_domainname).value.should == "primary"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return correct uuid on version 1.0" do
|
48
|
+
Facter.fact(:ldom_domainuuid).value.should == "8e0d6ec5-cd55-e57f-ae9f-b4cc050999a4"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return correct ldomcontrol on version 1.0" do
|
52
|
+
Facter.fact(:ldom_domaincontrol).value.should == "san-t2k-6"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return correct serial on version 1.0" do
|
56
|
+
Facter.fact(:ldom_domainchassis).value.should == "0704RB0280"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return correct virtual on version 1.0" do
|
60
|
+
Facter.fact(:virtual).value.should == "LDoms"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "when running on non ldom hardware" do
|
65
|
+
before :each do
|
66
|
+
Facter::Util::Resolution.stubs(:exec).with("virtinfo -ap").returns(nil)
|
67
|
+
Facter.collection.internal_loader.load(:ldom)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return correct virtual" do
|
71
|
+
Facter.fact(:ldom_domainrole_impl).should == nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -13,8 +13,10 @@ def netsh_fixture(filename)
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "macaddress fact" do
|
16
|
+
include FacterSpec::ConfigHelper
|
17
|
+
|
16
18
|
before do
|
17
|
-
|
19
|
+
given_a_configuration_of(:is_windows => false)
|
18
20
|
end
|
19
21
|
|
20
22
|
describe "when run on Linux" do
|