facter 2.1.0-x86-mingw32 → 2.2.0-x86-mingw32
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/COMMITTERS.md +25 -34
- data/CONTRIBUTING.md +27 -5
- data/README.md +32 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +3 -2
- data/ext/osx/file_mapping.yaml +5 -0
- data/ext/redhat/facter.spec.erb +4 -1
- data/lib/facter/Cfkey.rb +2 -2
- data/lib/facter/architecture.rb +2 -2
- data/lib/facter/augeasversion.rb +2 -2
- data/lib/facter/blockdevices.rb +12 -12
- data/lib/facter/dhcp_servers.rb +4 -4
- data/lib/facter/domain.rb +4 -4
- data/lib/facter/ec2.rb +17 -0
- data/lib/facter/ec2/rest.rb +2 -2
- data/lib/facter/facterversion.rb +2 -2
- data/lib/facter/filesystems.rb +10 -3
- data/lib/facter/fqdn.rb +1 -1
- data/lib/facter/gid.rb +16 -0
- data/lib/facter/hardwareisa.rb +3 -3
- data/lib/facter/hardwaremodel.rb +3 -3
- data/lib/facter/hostname.rb +1 -1
- data/lib/facter/id.rb +4 -4
- data/lib/facter/interfaces.rb +3 -0
- data/lib/facter/ipaddress6.rb +9 -9
- data/lib/facter/kernel.rb +2 -2
- data/lib/facter/kernelmajversion.rb +2 -2
- data/lib/facter/kernelrelease.rb +4 -4
- data/lib/facter/kernelversion.rb +3 -3
- data/lib/facter/ldom.rb +11 -0
- data/lib/facter/lsbdistcodename.rb +8 -4
- data/lib/facter/lsbdistdescription.rb +6 -10
- data/lib/facter/lsbdistid.rb +8 -4
- data/lib/facter/lsbdistrelease.rb +8 -4
- data/lib/facter/lsbmajdistrelease.rb +7 -12
- data/lib/facter/lsbminordistrelease.rb +22 -0
- data/lib/facter/lsbrelease.rb +8 -4
- data/lib/facter/macaddress.rb +1 -0
- data/lib/facter/macosx.rb +1 -1
- data/lib/facter/manufacturer.rb +3 -3
- data/lib/facter/memory.rb +8 -8
- data/lib/facter/netmask.rb +2 -1
- data/lib/facter/network.rb +3 -3
- data/lib/facter/operatingsystem.rb +9 -126
- data/lib/facter/operatingsystem/base.rb +61 -0
- data/lib/facter/operatingsystem/cumuluslinux.rb +27 -0
- data/lib/facter/operatingsystem/implementation.rb +30 -0
- data/lib/facter/operatingsystem/linux.rb +467 -0
- data/lib/facter/operatingsystem/sunos.rb +54 -0
- data/lib/facter/operatingsystem/vmkernel.rb +11 -0
- data/lib/facter/operatingsystem/windows.rb +37 -0
- data/lib/facter/operatingsystemmajrelease.rb +14 -33
- data/lib/facter/operatingsystemrelease.rb +14 -235
- data/lib/facter/os.rb +69 -0
- data/lib/facter/osfamily.rb +4 -23
- data/lib/facter/partitions.rb +4 -3
- data/lib/facter/path.rb +2 -2
- data/lib/facter/physicalprocessorcount.rb +10 -74
- data/lib/facter/processor.rb +13 -129
- data/lib/facter/processors.rb +60 -0
- data/lib/facter/processors/os.rb +234 -0
- data/lib/facter/ps.rb +5 -4
- data/lib/facter/puppetversion.rb +1 -1
- data/lib/facter/rackspace.rb +34 -0
- data/lib/facter/rubysitedir.rb +3 -0
- data/lib/facter/rubyversion.rb +2 -2
- data/lib/facter/selinux.rb +57 -2
- data/lib/facter/ssh.rb +1 -0
- data/lib/facter/system_uptime.rb +42 -0
- data/lib/facter/timezone.rb +1 -1
- data/lib/facter/uptime.rb +5 -23
- data/lib/facter/uptime_days.rb +4 -6
- data/lib/facter/uptime_hours.rb +4 -6
- data/lib/facter/uptime_seconds.rb +5 -9
- data/lib/facter/util/formatter.rb +1 -1
- data/lib/facter/util/manufacturer.rb +1 -1
- data/lib/facter/util/partitions.rb +3 -1
- data/lib/facter/util/partitions/linux.rb +1 -1
- data/lib/facter/util/partitions/openbsd.rb +35 -0
- data/lib/facter/util/uptime.rb +4 -3
- data/lib/facter/util/virtual.rb +3 -1
- data/lib/facter/util/xendomains.rb +12 -3
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +24 -23
- data/lib/facter/vlans.rb +1 -1
- data/lib/facter/xendomains.rb +1 -1
- data/lib/facter/zfs_version.rb +6 -2
- data/lib/facter/zones.rb +6 -5
- data/lib/facter/zpool_version.rb +1 -1
- data/spec/fixtures/cpuinfo/amd64dual-grep +2 -0
- data/spec/fixtures/cpuinfo/amd64twentyfour-grep +24 -0
- data/spec/fixtures/cpuinfo/two_multicore-grep +4 -0
- data/spec/fixtures/cpuinfo/two_singlecore-grep +2 -0
- data/spec/fixtures/unit/processors/os/darwin-system-profiler +287 -0
- data/spec/fixtures/unit/zfs_version/zfs_new +61 -0
- data/spec/fixtures/unit/zfs_version/zfs_old +43 -0
- data/spec/fixtures/unit/zfs_version/zfsonlinux_0.6.1 +13 -0
- data/spec/fixtures/unit/zpool_version/zfsonlinux_0.6.1 +48 -0
- data/spec/unit/ec2/rest_spec.rb +6 -6
- data/spec/unit/gid_spec.rb +22 -0
- data/spec/unit/hardwaremodel_spec.rb +2 -0
- data/spec/unit/lsbdistcodename_spec.rb +22 -17
- data/spec/unit/lsbdistdescription_spec.rb +22 -17
- data/spec/unit/lsbdistid_spec.rb +23 -18
- data/spec/unit/lsbdistrelease_spec.rb +22 -17
- data/spec/unit/lsbmajdistrelease_spec.rb +23 -6
- data/spec/unit/lsbminordistrelease_spec.rb +31 -0
- data/spec/unit/lsbrelease_spec.rb +22 -17
- data/spec/unit/macaddress_spec.rb +3 -0
- data/spec/unit/operatingsystem/base_spec.rb +76 -0
- data/spec/unit/operatingsystem/cumuluslinux_spec.rb +40 -0
- data/spec/unit/operatingsystem/implementation_spec.rb +49 -0
- data/spec/unit/operatingsystem/linux_spec.rb +538 -0
- data/spec/unit/operatingsystem/sunos_spec.rb +144 -0
- data/spec/unit/operatingsystem/vmkernel_spec.rb +13 -0
- data/spec/unit/operatingsystem/windows_spec.rb +68 -0
- data/spec/unit/operatingsystem_spec.rb +10 -153
- data/spec/unit/operatingsystemmajrelease_spec.rb +14 -31
- data/spec/unit/operatingsystemrelease_spec.rb +13 -229
- data/spec/unit/os_spec.rb +131 -0
- data/spec/unit/osfamily_spec.rb +9 -54
- data/spec/unit/partitions_spec.rb +41 -3
- data/spec/unit/physicalprocessorcount_spec.rb +6 -78
- data/spec/unit/processor_spec.rb +18 -381
- data/spec/unit/processors/os_spec.rb +446 -0
- data/spec/unit/processors_spec.rb +203 -0
- data/spec/unit/rackspace_spec.rb +40 -0
- data/spec/unit/system_uptime_spec.rb +80 -0
- data/spec/unit/util/formatter_spec.rb +5 -0
- data/spec/unit/util/macaddress_spec.rb +2 -0
- data/spec/unit/util/processor_spec.rb +120 -0
- data/spec/unit/util/uptime_spec.rb +3 -4
- data/spec/unit/util/virtual_spec.rb +8 -0
- data/spec/unit/util/xendomains_spec.rb +54 -9
- data/spec/unit/virtual_spec.rb +8 -1
- data/spec/unit/zfs_version_spec.rb +20 -8
- data/spec/unit/zpool_version_spec.rb +5 -0
- metadata +660 -589
- checksums.yaml +0 -7
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter'
|
5
|
+
|
6
|
+
describe "rackspace facts" do
|
7
|
+
describe "on Rackspace Cloud" do
|
8
|
+
before :each do
|
9
|
+
Facter.collection.internal_loader.load(:rackspace)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should set is_rsc to true" do
|
13
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider").returns("Rackspace")
|
14
|
+
Facter.fact(:is_rsc).value.should == "true"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the region to dfw" do
|
18
|
+
Facter.fact(:is_rsc).stubs(:value).returns("true")
|
19
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/region").returns("dfw")
|
20
|
+
Facter.fact(:rsc_region).value.should == "dfw"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should get the instance id" do
|
24
|
+
Facter.fact(:is_rsc).stubs(:value).returns("true")
|
25
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read name").returns("instance-75a96685-85d6-44c6-aed8-41ef0fb2cfcc")
|
26
|
+
Facter.fact(:rsc_instance_id).value.should == "75a96685-85d6-44c6-aed8-41ef0fb2cfcc"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "not on Rackspace Cloud" do
|
31
|
+
before do
|
32
|
+
Facter.collection.internal_loader.load(:rackspace)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shouldn't set is_rsc" do
|
36
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider").returns("other")
|
37
|
+
Facter.fact(:is_rsc).value.should == nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter/util/uptime'
|
5
|
+
|
6
|
+
describe "system_uptime:" do
|
7
|
+
before { Facter.clear }
|
8
|
+
after { Facter.clear }
|
9
|
+
|
10
|
+
describe "When uptime information is available" do
|
11
|
+
describe "uptime" do
|
12
|
+
test_cases = [
|
13
|
+
[60 * 60 * 24 * 3, '3 days'],
|
14
|
+
[60 * 60 * 24 * 3 + 25, '3 days'],
|
15
|
+
[60 * 60 * 24 * 1, '1 day'],
|
16
|
+
[60 * 60 * 24 * 1 + 25, '1 day'],
|
17
|
+
[60 * (60 * 3 + 45), '3:45 hours'],
|
18
|
+
[60 * (60 * 3 + 4), '3:04 hours'],
|
19
|
+
[60 * 60, '1:00 hours'],
|
20
|
+
[60 * 35, '0:35 hours']
|
21
|
+
]
|
22
|
+
|
23
|
+
test_cases.each do |seconds, expected|
|
24
|
+
it "should return #{expected.inspect} for #{seconds} seconds in Linux" do
|
25
|
+
Facter.fact(:kernel).stubs(:value).returns("linux")
|
26
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(seconds)
|
27
|
+
Facter.fact(:system_uptime).value['uptime'].should eq expected
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return #{expected.inspect} for #{seconds} seconds in Windows" do
|
31
|
+
Facter.fact(:kernel).stubs(:value).returns("windows")
|
32
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(seconds)
|
33
|
+
Facter.fact(:system_uptime).value['uptime'].should eq expected
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "when uptime information is available" do
|
40
|
+
before do
|
41
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(60 * 60 * 24 + 23)
|
42
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(60 * 60 * 24 + 23)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should include a key for seconds" do
|
46
|
+
Facter.fact(:system_uptime).value['seconds'].should eq 60 * 60 * 24 + 23
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should include a key for hours" do
|
50
|
+
Facter.fact(:system_uptime).value['hours'].should eq 24
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should include a key for days" do
|
54
|
+
Facter.fact(:system_uptime).value['days'].should eq 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "when uptime information is not available" do
|
59
|
+
before do
|
60
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(nil)
|
61
|
+
Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(nil)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have an 'uptime' key with value 'unknown'" do
|
65
|
+
Facter.fact(:system_uptime).value['uptime'].should eq "unknown"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have a 'seconds' key with value nil" do
|
69
|
+
Facter.fact(:system_uptime).value['seconds'].should eq nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have a 'hours' key with value nil" do
|
73
|
+
Facter.fact(:system_uptime).value['hours'].should eq nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have a 'days' key with value nil" do
|
77
|
+
Facter.fact(:system_uptime).value['days'].should eq nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -27,12 +27,17 @@ describe Facter::Util::Formatter do
|
|
27
27
|
expect(described_class.format_plaintext({"foo" => "bar"})).to eq "bar"
|
28
28
|
end
|
29
29
|
|
30
|
+
it "can return false:FalseClass as a single fact value" do
|
31
|
+
expect(described_class.format_plaintext({"foo" => false})).to eq "false"
|
32
|
+
end
|
33
|
+
|
30
34
|
it "formats a structured value with #inspect" do
|
31
35
|
value = ["bar"]
|
32
36
|
value.expects(:inspect).returns %Q(["bar"])
|
33
37
|
hash = {"foo" => value, "baz" => "quux"}
|
34
38
|
expect(described_class.format_plaintext(hash)).to match(%Q([bar]))
|
35
39
|
end
|
40
|
+
|
36
41
|
it "formats multiple string values as key/value pairs" do
|
37
42
|
hash = {"foo" => "bar", "baz" => "quux"}
|
38
43
|
expect(described_class.format_plaintext(hash)).to match(/foo => bar/)
|
@@ -91,6 +91,8 @@ describe "The macaddress fact" do
|
|
91
91
|
|
92
92
|
before :each do
|
93
93
|
Facter.fact(:kernel).stubs(:value).returns('windows')
|
94
|
+
Facter.fact(:operatingsystem).stubs(:value).returns('windows')
|
95
|
+
Facter.fact(:osfamily).stubs(:value).returns('windows')
|
94
96
|
Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings)
|
95
97
|
end
|
96
98
|
|
@@ -89,4 +89,124 @@ describe Facter::Util::Processor do
|
|
89
89
|
Facter::Util::Processor.enum_kstat[7].should == "SPARC64-VII"
|
90
90
|
end
|
91
91
|
end
|
92
|
+
|
93
|
+
describe "on AIX" do
|
94
|
+
let(:lsattr) do
|
95
|
+
"type PowerPC_POWER5 Processor type False\n"
|
96
|
+
end
|
97
|
+
|
98
|
+
def lsdev_examples
|
99
|
+
examples = "proc0 Available 00-00 Processor\n" +
|
100
|
+
"proc4 Available 00-04 Processor\n" +
|
101
|
+
"proc8 Defined 00-08 Processor\n" +
|
102
|
+
"proc12 Defined 00-12 Processor\n"
|
103
|
+
examples
|
104
|
+
end
|
105
|
+
|
106
|
+
before :each do
|
107
|
+
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
108
|
+
Facter::Util::Processor.stubs(:lsdev).returns(lsdev_examples)
|
109
|
+
Facter::Util::Processor.stubs(:lsattr).returns(lsattr)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should create an array of processors" do
|
113
|
+
Facter::Util::Processor.aix_processor_list[0].should eq "PowerPC_POWER5"
|
114
|
+
Facter::Util::Processor.aix_processor_list[1].should eq "PowerPC_POWER5"
|
115
|
+
Facter::Util::Processor.aix_processor_list[2].should eq "PowerPC_POWER5"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "on HP-UX" do
|
120
|
+
let(:ioscan) do
|
121
|
+
"Class I H/W Path Driver S/W State H/W Type Description\n" +
|
122
|
+
"===================================================================\n" +
|
123
|
+
"processor 0 0/120 processor CLAIMED PROCESSOR Processor\n" +
|
124
|
+
"processor 1 0/123 processor CLAIMED PROCESSOR Processor\n"
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "when machinfo is available" do
|
128
|
+
def self.machinfo_examples
|
129
|
+
examples = []
|
130
|
+
examples << [File.read(fixtures('hpux','machinfo','ia64-rx2620')), "Intel(R) Itanium 2 processor"]
|
131
|
+
examples << [File.read(fixtures('hpux','machinfo','ia64-rx6600')), "Intel(R) Itanium 2 9100 series processor (1.59 GHz, 18 MB)"]
|
132
|
+
examples << [File.read(fixtures('hpux','machinfo','ia64-rx8640')), "Intel(R) Itanium 2 9100 series"]
|
133
|
+
examples << [File.read(fixtures('hpux','machinfo','hppa-rp4440')), "PA-RISC 8800 processor (1000 MHz, 64 MB)"]
|
134
|
+
examples << [File.read(fixtures('hpux','machinfo','superdome-server-SD32B')), "Intel(R) Itanium 2 9000 series"]
|
135
|
+
examples << [File.read(fixtures('hpux','machinfo','superdome2-16s')), "Intel(R) Itanium(R) Processor 9340 (1.6 GHz, 15 MB)"]
|
136
|
+
examples
|
137
|
+
end
|
138
|
+
|
139
|
+
machinfo_examples.each_with_index do |example, i|
|
140
|
+
machinfo_example, expected_cpu = example
|
141
|
+
context "machinfo example ##{i}" do
|
142
|
+
before :each do
|
143
|
+
Facter.fact(:kernel).stubs(:value).returns("HP-UX")
|
144
|
+
Facter::Util::Processor.stubs(:ioscan).returns(ioscan)
|
145
|
+
Facter::Util::Processor.stubs(:machinfo).returns(machinfo_example)
|
146
|
+
end
|
147
|
+
|
148
|
+
%w{ 0 1 }.each do |j|
|
149
|
+
it "should find #{expected_cpu}" do
|
150
|
+
Facter::Util::Processor.hpux_processor_list[j.to_i].should eq expected_cpu
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "when machinfo is not available" do
|
158
|
+
def self.model_and_getconf_examples
|
159
|
+
examples = []
|
160
|
+
examples << ["9000/800/L3000-5x", "sched.models_present", "unistd.h_present", "532", "616", "PA-RISC 8600 processor"]
|
161
|
+
examples << ["9000/800/L3000-5x", "", "unistd.h_present", "532", "616", "HP PA-RISC2.0 CHIP TYPE #616"]
|
162
|
+
examples << ["9000/800/L3000-5x", "", "", "532", "616", "CPU v532 CHIP TYPE #616"]
|
163
|
+
examples << ["ia64 hp server rx2660", "sched.models_present", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"]
|
164
|
+
examples << ["ia64 hp server rx2660", "", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"]
|
165
|
+
examples << ["ia64 hp server rx2660", "", "", "768", "536936708", "CPU v768 CHIP TYPE #536936708"]
|
166
|
+
examples
|
167
|
+
end
|
168
|
+
|
169
|
+
sched_models = File.readlines(fixtures('hpux','sched.models'))
|
170
|
+
unistd_h = File.readlines(fixtures('hpux','unistd.h'))
|
171
|
+
model_and_getconf_examples.each_with_index do |example, i|
|
172
|
+
model_example, sm, unistd, getconf_cpu_ver, getconf_chip_type, expected_cpu = example
|
173
|
+
context "and model and getconf example ##{i}" do
|
174
|
+
before :each do
|
175
|
+
Facter.fact(:kernel).stubs(:value).returns("HP-UX")
|
176
|
+
Facter::Util::Processor.stubs(:ioscan).returns(ioscan)
|
177
|
+
Facter::Util::Processor.stubs(:getconf_cpu_version).returns(getconf_cpu_ver)
|
178
|
+
Facter::Util::Processor.stubs(:getconf_cpu_chip_type).returns(getconf_chip_type)
|
179
|
+
Facter::Util::Processor.stubs(:machinfo).returns(nil)
|
180
|
+
Facter::Util::Processor.stubs(:model).returns(model_example)
|
181
|
+
end
|
182
|
+
|
183
|
+
if unistd == "unistd.h_present" then
|
184
|
+
before :each do
|
185
|
+
Facter::Util::Processor.stubs(:read_unistd_h).returns(unistd_h)
|
186
|
+
end
|
187
|
+
else
|
188
|
+
before :each do
|
189
|
+
Facter::Util::Processor.stubs(:read_unistd_h).returns(nil)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if sm == "sched.models_present" then
|
194
|
+
before :each do
|
195
|
+
Facter::Util::Processor.stubs(:read_sched_models).returns(sched_models)
|
196
|
+
end
|
197
|
+
else
|
198
|
+
before :each do
|
199
|
+
Facter::Util::Processor.stubs(:read_sched_models).returns(nil)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
%w{ 0 1 }.each do |j|
|
204
|
+
it "should find #{expected_cpu}" do
|
205
|
+
Facter::Util::Processor.hpux_processor_list[j.to_i].should eq expected_cpu
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
92
212
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'facter/util/uptime'
|
5
|
+
require 'facter/util/posix'
|
5
6
|
|
6
7
|
describe Facter::Util::Uptime do
|
7
8
|
|
@@ -26,15 +27,13 @@ describe Facter::Util::Uptime do
|
|
26
27
|
end
|
27
28
|
|
28
29
|
it "should use 'sysctl -n kern.boottime' on OpenBSD" do
|
29
|
-
|
30
|
-
Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
|
30
|
+
Facter::Util::POSIX.stubs(:sysctl).returns(my_fixture_read("sysctl_kern_boottime_openbsd"))
|
31
31
|
Time.stubs(:now).returns Time.parse("Dec 09 22:11:46 +0000 2011") # one hour later
|
32
32
|
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should use 'sysctl -n kern.boottime' on Darwin, etc." do
|
36
|
-
|
37
|
-
Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
|
36
|
+
Facter::Util::POSIX.stubs(:sysctl).returns(my_fixture_read("sysctl_kern_boottime_darwin"))
|
38
37
|
Time.stubs(:now).returns Time.parse("Oct 30 22:52:27 +0000 2011") # one hour later
|
39
38
|
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|
40
39
|
end
|
@@ -223,6 +223,14 @@ describe Facter::Util::Virtual do
|
|
223
223
|
Facter::Util::Virtual.should be_kvm
|
224
224
|
end
|
225
225
|
|
226
|
+
it "should detect kvm on SunOS" do
|
227
|
+
FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false)
|
228
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
229
|
+
FileTest.stubs(:exists?).with("/usr/sbin/prtconf").returns(true)
|
230
|
+
Facter::Core::Execution.stubs(:exec).with("/usr/sbin/prtconf -v").returns("Qemu virtual machine")
|
231
|
+
Facter::Util::Virtual.should be_kvm
|
232
|
+
end
|
233
|
+
|
226
234
|
it "should identify FreeBSD jail when in jail" do
|
227
235
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
228
236
|
Facter::Core::Execution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1")
|
@@ -4,18 +4,63 @@ require 'spec_helper'
|
|
4
4
|
require 'facter/util/xendomains'
|
5
5
|
|
6
6
|
describe Facter::Util::Xendomains do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
let(:xen0_domains) { my_fixture_read("xendomains") }
|
9
|
+
|
10
|
+
describe "when the xl command is present" do
|
11
|
+
before do
|
12
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns('/usr/sbin/xl')
|
12
13
|
end
|
13
14
|
|
14
|
-
describe "
|
15
|
-
|
16
|
-
|
17
|
-
Facter::Util::
|
15
|
+
describe "and the xm command is not present" do
|
16
|
+
|
17
|
+
before do
|
18
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
|
19
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
|
18
20
|
end
|
21
|
+
|
22
|
+
it "lists the domains running on Xen0 with the 'xl' command" do
|
23
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
|
24
|
+
Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "and the xm command is also present" do
|
29
|
+
before do
|
30
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/bin/xm')
|
31
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
|
32
|
+
end
|
33
|
+
|
34
|
+
it "prefers xl over xm" do
|
35
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
|
36
|
+
Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when xl is not present" do
|
42
|
+
before do
|
43
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
|
44
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').never
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "and the xm command is present" do
|
48
|
+
before do
|
49
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/sbin/xm')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "lists the domains running on Xen0 with the 'xm' command" do
|
53
|
+
Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
|
54
|
+
Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "neither xl or xm are present" do
|
60
|
+
it "returns nil" do
|
61
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
|
62
|
+
Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
|
63
|
+
Facter::Util::Xendomains.get_domains.should == nil
|
19
64
|
end
|
20
65
|
end
|
21
66
|
end
|
data/spec/unit/virtual_spec.rb
CHANGED
@@ -24,6 +24,7 @@ describe "Virtual fact" do
|
|
24
24
|
|
25
25
|
it "should be zone on Solaris when a zone" do
|
26
26
|
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
27
|
+
Facter.fact(:operatingsystem).stubs(:value).returns("Solaris")
|
27
28
|
Facter::Util::Virtual.stubs(:zone?).returns(true)
|
28
29
|
Facter::Util::Virtual.stubs(:vserver?).returns(false)
|
29
30
|
Facter::Util::Virtual.stubs(:xen?).returns(false)
|
@@ -39,6 +40,7 @@ describe "Virtual fact" do
|
|
39
40
|
|
40
41
|
it "should be hpvm on HP-UX when in HP-VM" do
|
41
42
|
Facter.fact(:kernel).stubs(:value).returns("HP-UX")
|
43
|
+
Facter.fact(:operatingsystem).stubs(:value).returns("HP-UX")
|
42
44
|
Facter::Util::Virtual.stubs(:hpvm?).returns(true)
|
43
45
|
Facter.fact(:virtual).value.should == "hpvm"
|
44
46
|
end
|
@@ -303,6 +305,11 @@ describe "Virtual fact" do
|
|
303
305
|
Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("oVirt Node")
|
304
306
|
Facter.fact(:virtual).value.should == "ovirt"
|
305
307
|
end
|
308
|
+
|
309
|
+
it "should be kvm with KVM product name from sysctl" do
|
310
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("KVM")
|
311
|
+
Facter.fact(:virtual).value.should == "kvm"
|
312
|
+
end
|
306
313
|
end
|
307
314
|
|
308
315
|
describe "on Windows" do
|
@@ -499,7 +506,7 @@ describe "is_virtual fact" do
|
|
499
506
|
Facter.fact(:is_virtual).value.should == "true"
|
500
507
|
end
|
501
508
|
|
502
|
-
it "should be true when running on
|
509
|
+
it "should be true when running on gce" do
|
503
510
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
504
511
|
Facter.fact(:virtual).stubs(:value).returns("gce")
|
505
512
|
Facter.fact(:is_virtual).value.should == "true"
|
@@ -18,31 +18,47 @@ describe "zfs_version fact" do
|
|
18
18
|
Facter::Core::Execution.stubs(:which).with("zfs").returns("/usr/bin/zfs")
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should return nil on old versions of Solaris 10" do
|
22
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_old'))
|
23
|
+
Facter.fact(:zfs_version).value.should == nil
|
24
|
+
end
|
25
|
+
|
21
26
|
it "should return correct version on Solaris 10" do
|
27
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
22
28
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('solaris_10'))
|
23
29
|
Facter.fact(:zfs_version).value.should == "3"
|
24
30
|
end
|
25
31
|
|
26
32
|
it "should return correct version on Solaris 11" do
|
33
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
27
34
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('solaris_11'))
|
28
35
|
Facter.fact(:zfs_version).value.should == "5"
|
29
36
|
end
|
30
37
|
|
31
38
|
it "should return correct version on FreeBSD 8.2" do
|
39
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
32
40
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('freebsd_8.2'))
|
33
41
|
Facter.fact(:zfs_version).value.should == "4"
|
34
42
|
end
|
35
43
|
|
36
44
|
it "should return correct version on FreeBSD 9.0" do
|
45
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
37
46
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('freebsd_9.0'))
|
38
47
|
Facter.fact(:zfs_version).value.should == "5"
|
39
48
|
end
|
40
49
|
|
41
50
|
it "should return correct version on Linux with ZFS-fuse" do
|
51
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
42
52
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9'))
|
43
53
|
Facter.fact(:zfs_version).value.should == "4"
|
44
54
|
end
|
45
55
|
|
56
|
+
it "should return correct version on Linux with zfsonlinux" do
|
57
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
58
|
+
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('zfsonlinux_0.6.1'))
|
59
|
+
Facter.fact(:zfs_version).value.should == "5"
|
60
|
+
end
|
61
|
+
|
46
62
|
it "should return nil if zfs command is not available" do
|
47
63
|
Facter::Core::Execution.stubs(:which).with("zfs").returns(nil)
|
48
64
|
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9'))
|
@@ -50,20 +66,16 @@ describe "zfs_version fact" do
|
|
50
66
|
end
|
51
67
|
|
52
68
|
it "should return nil if zfs fails to run" do
|
53
|
-
Facter::Core::Execution.stubs(:exec).with("zfs
|
69
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(nil)
|
54
70
|
Facter.fact(:zfs_version).value.should == nil
|
55
71
|
end
|
56
72
|
|
57
73
|
it "handles the zfs command becoming available at a later point in time" do
|
58
74
|
# Simulate Puppet configuring the zfs tools from a persistent daemon by
|
59
75
|
# simulating three sequential responses to which('zfs').
|
60
|
-
Facter::Core::Execution.stubs(:which).
|
61
|
-
|
62
|
-
|
63
|
-
Facter::Core::Execution.stubs(:exec).
|
64
|
-
with("zfs upgrade -v").
|
65
|
-
returns(my_fixture_read('linux-fuse_0.6.9'))
|
66
|
-
|
76
|
+
Facter::Core::Execution.stubs(:which).with("zfs").returns(nil,nil,"/usr/bin/zfs")
|
77
|
+
Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new'))
|
78
|
+
Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9'))
|
67
79
|
fact = Facter.fact(:zfs_version)
|
68
80
|
|
69
81
|
# zfs is not present the first two times the fact is resolved.
|