facter 2.0.2-universal-darwin → 2.1.0-universal-darwin
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.
- checksums.yaml +4 -4
- data/Gemfile +14 -0
- data/ext/project_data.yaml +9 -6
- data/lib/facter/core/execution/base.rb +3 -3
- data/lib/facter/core/suitable.rb +1 -5
- data/lib/facter/dhcp_servers.rb +39 -0
- data/lib/facter/ec2.rb +33 -26
- data/lib/facter/ec2/rest.rb +130 -0
- data/lib/facter/fqdn.rb +2 -0
- data/lib/facter/gce.rb +16 -0
- data/lib/facter/gce/metadata.rb +87 -0
- data/lib/facter/kernelmajversion.rb +8 -0
- data/lib/facter/kernelrelease.rb +8 -0
- data/lib/facter/memory.rb +21 -15
- data/lib/facter/netmask.rb +1 -1
- data/lib/facter/operatingsystem.rb +20 -0
- data/lib/facter/operatingsystemmajrelease.rb +2 -1
- data/lib/facter/operatingsystemrelease.rb +19 -0
- data/lib/facter/osfamily.rb +3 -1
- data/lib/facter/partitions.rb +35 -0
- data/lib/facter/physicalprocessorcount.rb +9 -0
- data/lib/facter/processor.rb +25 -25
- data/lib/facter/util/config.rb +3 -1
- data/lib/facter/util/dhcp_servers.rb +43 -0
- data/lib/facter/util/ec2.rb +5 -0
- data/lib/facter/util/formatter.rb +2 -1
- data/lib/facter/util/ip.rb +1 -1
- data/lib/facter/util/loader.rb +10 -1
- data/lib/facter/util/manufacturer.rb +15 -16
- data/lib/facter/util/memory.rb +12 -12
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/operatingsystem.rb +21 -0
- data/lib/facter/util/partitions.rb +41 -0
- data/lib/facter/util/partitions/linux.rb +65 -0
- data/lib/facter/util/posix.rb +16 -0
- data/lib/facter/util/processor.rb +8 -10
- data/lib/facter/util/resolution.rb +4 -0
- data/lib/facter/util/values.rb +29 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/util/windows_root.rb +2 -32
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +53 -12
- data/spec/fixtures/ifconfig/openbsd_bridge_rules +11 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp +36 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static +24 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp +49 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static +37 -0
- data/spec/fixtures/unit/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/ec2/rest/meta-data/root +20 -0
- data/spec/fixtures/unit/gce/metadata/metadata.json +69 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3 +2 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3-current +3 -0
- data/spec/fixtures/unit/memory/aix-svmon +9 -0
- data/spec/fixtures/unit/memory/aix-swap_l +2 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-multiple +3 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-single +2 -0
- data/spec/fixtures/unit/memory/darwin-vm_stat +13 -0
- data/spec/fixtures/unit/memory/dragonfly-vmstat +3 -0
- data/spec/fixtures/unit/memory/freebsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/linux-proc_meminfo +10 -0
- data/spec/fixtures/unit/memory/openbsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/smartos_zone_swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-prtconf +4 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-multiple +3 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-vmstat +3 -0
- data/spec/fixtures/unit/netmask/ifconfig_aix_7.txt +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/util/manufacturer/smartos_smbios +533 -0
- data/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt +8 -0
- data/spec/fixtures/unit/util/operatingsystem/redhat-7.txt +12 -0
- data/spec/fixtures/unit/util/operatingsystem/sabayon.txt +7 -0
- data/spec/fixtures/unit/util/operatingsystem/wheezy.txt +9 -0
- data/spec/fixtures/unit/util/partitions/partitions/mount +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_container +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container +8 -0
- data/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container +9 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/core/execution/base_spec.rb +3 -5
- data/spec/unit/core/execution/posix_spec.rb +2 -2
- data/spec/unit/core/suitable_spec.rb +10 -0
- data/spec/unit/dhcp_servers_spec.rb +152 -0
- data/spec/unit/ec2/rest_spec.rb +145 -0
- data/spec/unit/ec2_spec.rb +87 -147
- data/spec/unit/fqdn_spec.rb +16 -0
- data/spec/unit/gce/metadata_spec.rb +49 -0
- data/spec/unit/gce_spec.rb +34 -0
- data/spec/unit/interfaces_spec.rb +9 -9
- data/spec/unit/kernelmajversion_spec.rb +14 -9
- data/spec/unit/kernelrelease_spec.rb +16 -0
- data/spec/unit/macaddress_spec.rb +12 -0
- data/spec/unit/memory_spec.rb +53 -122
- data/spec/unit/netmask_spec.rb +11 -0
- data/spec/unit/operatingsystem_spec.rb +19 -0
- data/spec/unit/operatingsystemmajrelease_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +8 -0
- data/spec/unit/osfamily_spec.rb +62 -0
- data/spec/unit/partitions_spec.rb +48 -0
- data/spec/unit/physicalprocessorcount_spec.rb +9 -0
- data/spec/unit/processor_spec.rb +15 -7
- data/spec/unit/util/config_spec.rb +13 -0
- data/spec/unit/util/dhcp_servers_spec.rb +63 -0
- data/spec/unit/util/ec2_spec.rb +4 -0
- data/spec/unit/util/formatter_spec.rb +50 -0
- data/spec/unit/util/loader_spec.rb +4 -4
- data/spec/unit/util/macosx_spec.rb +3 -2
- data/spec/unit/util/manufacturer_spec.rb +44 -0
- data/spec/unit/util/operatingsystem_spec.rb +92 -0
- data/spec/unit/util/partitions/partitions_spec.rb +67 -0
- data/spec/unit/util/partitions_spec.rb +19 -0
- data/spec/unit/util/posix_spec.rb +11 -0
- data/spec/unit/util/values_spec.rb +40 -0
- data/spec/unit/util/virtual_spec.rb +72 -2
- data/spec/unit/virtual_spec.rb +67 -18
- metadata +116 -4
- data/spec/fixtures/unit/util/loader/nosuchfact.rb +0 -1
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter'
|
5
|
+
|
6
|
+
describe "Partition facts" do
|
7
|
+
|
8
|
+
describe "on non-Linux OS" do
|
9
|
+
|
10
|
+
it "should not exist when kernel isn't Linux" do
|
11
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
12
|
+
Facter.fact(:partitions).value.should == nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "on Linux" do
|
17
|
+
it "should return a structured fact with uuid, size, mount point and filesytem for each partition" do
|
18
|
+
partitions = {
|
19
|
+
'sda1' => {
|
20
|
+
'uuid' => '13459663-22cc-47b4-a9e6-21dea9906e03',
|
21
|
+
'size' => '1234',
|
22
|
+
'mount' => '/',
|
23
|
+
'filesystem' => 'ext4',
|
24
|
+
},
|
25
|
+
'sdb2' => {
|
26
|
+
'uuid' => '98043570-eb10-457f-9718-0b85a26e66bf',
|
27
|
+
'size' => '5678',
|
28
|
+
'mount' => '/home',
|
29
|
+
'filesystem' => 'xfs',
|
30
|
+
},
|
31
|
+
}
|
32
|
+
|
33
|
+
Facter::Util::Partitions.stubs(:list).returns( partitions.keys )
|
34
|
+
|
35
|
+
partitions.each do |part,vals|
|
36
|
+
Facter::Util::Partitions.stubs(:uuid).with(part).returns(vals['uuid'])
|
37
|
+
Facter::Util::Partitions.stubs(:size).with(part).returns(vals['size'])
|
38
|
+
Facter::Util::Partitions.stubs(:mount).with(part).returns(vals['mount'])
|
39
|
+
Facter::Util::Partitions.stubs(:filesystem).with(part).returns(vals['filesystem'])
|
40
|
+
end
|
41
|
+
|
42
|
+
Facter.fact(:partitions).value.should == {
|
43
|
+
'sda1' => { 'uuid' => '13459663-22cc-47b4-a9e6-21dea9906e03', 'size' => '1234', 'mount' => '/', 'filesystem' => 'ext4' },
|
44
|
+
'sdb2' => { 'uuid' => '98043570-eb10-457f-9718-0b85a26e66bf', 'size' => '5678', 'mount' => '/home', 'filesystem' => 'xfs' },
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'facter/util/posix'
|
4
5
|
|
5
6
|
describe "Physical processor count facts" do
|
6
7
|
|
@@ -73,4 +74,12 @@ describe "Physical processor count facts" do
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
77
|
+
|
78
|
+
describe "on openbsd" do
|
79
|
+
it "should return 4 physical CPUs" do
|
80
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
81
|
+
Facter::Util::POSIX.expects(:sysctl).with("hw.ncpufound").returns("4")
|
82
|
+
Facter.fact(:physicalprocessorcount).value.should == "4"
|
83
|
+
end
|
84
|
+
end
|
76
85
|
end
|
data/spec/unit/processor_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'facter/util/posix'
|
3
4
|
require 'facter/util/processor'
|
4
5
|
require 'spec_helper'
|
5
6
|
require 'facter_spec/cpuinfo'
|
@@ -185,35 +186,42 @@ describe "Processor facts" do
|
|
185
186
|
|
186
187
|
it "should be 2 on dual-processor Darwin box" do
|
187
188
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
188
|
-
Facter::
|
189
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.ncpu").returns('2')
|
189
190
|
|
190
191
|
Facter.fact(:processorcount).value.should == "2"
|
191
192
|
end
|
192
193
|
|
193
194
|
it "should be 2 on dual-processor OpenBSD box" do
|
194
195
|
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
195
|
-
Facter::
|
196
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.ncpu").returns('2')
|
196
197
|
|
197
198
|
Facter.fact(:processorcount).value.should == "2"
|
198
199
|
end
|
199
200
|
|
201
|
+
it "should print the correct CPU Model on OpenBSD" do
|
202
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
203
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.model").returns('SomeVendor CPU 4.2GHz')
|
204
|
+
|
205
|
+
Facter.fact(:processor).value.should == "SomeVendor CPU 4.2GHz"
|
206
|
+
end
|
207
|
+
|
200
208
|
it "should be 2 on dual-processor FreeBSD box" do
|
201
209
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
202
|
-
Facter::
|
210
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.ncpu").returns('2')
|
203
211
|
|
204
212
|
Facter.fact(:processorcount).value.should == "2"
|
205
213
|
end
|
206
214
|
|
207
215
|
it "should print the correct CPU Model on FreeBSD" do
|
208
216
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
209
|
-
Facter::
|
217
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.model").returns('SomeVendor CPU 3GHz')
|
210
218
|
|
211
219
|
Facter.fact(:processor).value.should == "SomeVendor CPU 3GHz"
|
212
220
|
end
|
213
221
|
|
214
222
|
it "should be 2 on dual-processor DragonFly box" do
|
215
223
|
Facter.fact(:kernel).stubs(:value).returns("DragonFly")
|
216
|
-
Facter::
|
224
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.ncpu").returns('2')
|
217
225
|
|
218
226
|
Facter.fact(:processorcount).value.should == "2"
|
219
227
|
end
|
@@ -234,7 +242,7 @@ describe "Processor facts" do
|
|
234
242
|
let(:kstat_sparc) { @fixture_kstat_sparc }
|
235
243
|
let(:kstat_x86_64) { @fixture_kstat_x86_64 }
|
236
244
|
|
237
|
-
%w{ 5.
|
245
|
+
%w{ 5.5.1 5.6 5.7 }.each do |release|
|
238
246
|
%w{ sparc x86_64 }.each do |arch|
|
239
247
|
it "uses kstat on release #{release} (#{arch})" do
|
240
248
|
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
@@ -246,7 +254,7 @@ describe "Processor facts" do
|
|
246
254
|
end
|
247
255
|
end
|
248
256
|
|
249
|
-
%w{ 5.5.
|
257
|
+
%w{ 5.8 5.9 5.10 5.11 }.each do |release|
|
250
258
|
it "uses psrinfo on release #{release}" do
|
251
259
|
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
252
260
|
|
@@ -5,6 +5,19 @@ require 'spec_helper'
|
|
5
5
|
describe Facter::Util::Config do
|
6
6
|
include PuppetlabsSpec::Files
|
7
7
|
|
8
|
+
describe "ENV['HOME'] is unset", :unless => Facter::Util::Root.root? do
|
9
|
+
around do |example|
|
10
|
+
Facter::Core::Execution.with_env('HOME' => nil) do
|
11
|
+
example.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should not set @external_facts_dirs" do
|
16
|
+
Facter::Util::Config.setup_default_ext_facts_dirs
|
17
|
+
Facter::Util::Config.external_facts_dirs.should be_empty
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
8
21
|
describe "is_windows? function" do
|
9
22
|
it "should detect windows if Ruby RbConfig::CONFIG['host_os'] returns a windows OS" do
|
10
23
|
host_os = ["mswin","win32","dos","mingw","cygwin"]
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter/util/dhcp_servers'
|
5
|
+
|
6
|
+
describe Facter::Util::DHCPServers do
|
7
|
+
|
8
|
+
describe "retrieving the gateway device" do
|
9
|
+
it "returns nil when there are no default routes" do
|
10
|
+
Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route_nogw'))
|
11
|
+
described_class.gateway_device.should be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the interface associated with the first default route" do
|
15
|
+
Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route'))
|
16
|
+
described_class.gateway_device.should eq "eth0"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "nmcli_version" do
|
21
|
+
{
|
22
|
+
'nmcli tool, version 0.9.8.0' => [0, 9, 8, 0],
|
23
|
+
'nmcli tool, version 0.9.8.10' => [0, 9, 8, 10],
|
24
|
+
'nmcli tool, version 0.9.8.9' => [0, 9, 8, 9],
|
25
|
+
'nmcli tool, version 0.9.9.0' => [0, 9, 9, 0],
|
26
|
+
'nmcli tool, version 0.9.9.9' => [0, 9, 9, 9],
|
27
|
+
'version 0.9.9.0-20.git20131003.fc20' => [0, 9, 9, 0],
|
28
|
+
'nmcli tool, version 0.9.9' => [0, 9, 9, 0],
|
29
|
+
'nmcli tool, version 0.9' => [0, 9, 0, 0],
|
30
|
+
'nmcli tool, version 1' => [1, 0, 0, 0]
|
31
|
+
}.each do |version, expected|
|
32
|
+
it "should turn #{version} into the integer #{expected}" do
|
33
|
+
Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli')
|
34
|
+
Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns(version)
|
35
|
+
|
36
|
+
result = Facter::Util::DHCPServers.nmcli_version
|
37
|
+
result.is_a?(Array).should be true
|
38
|
+
result.should == expected
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "device_dhcp_server" do
|
44
|
+
{
|
45
|
+
'0.1.2.3' => false,
|
46
|
+
'0.9.8.10' => false,
|
47
|
+
'0.9.9.0' => true,
|
48
|
+
'0.9.10.0' => true,
|
49
|
+
'0.10.0.0' => true,
|
50
|
+
'1.0.0.0' => true
|
51
|
+
}.each do |version, uses_show|
|
52
|
+
it "should use #{if uses_show then 'show' else 'list' end} for version #{version}" do
|
53
|
+
command = if uses_show then 'nmcli -f all d show eth0' else 'nmcli -f all d list iface eth0' end
|
54
|
+
Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli')
|
55
|
+
Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns "nmcli tool, version #{version}"
|
56
|
+
Facter::Core::Execution.stubs(:exec).with(command).returns 'DHCP4.OPTION[1]: dhcp_server_identifier = 192.168.1.1'
|
57
|
+
Facter::Util::DHCPServers.device_dhcp_server('eth0').should == '192.168.1.1'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
data/spec/unit/util/ec2_spec.rb
CHANGED
@@ -4,6 +4,10 @@ require 'spec_helper'
|
|
4
4
|
require 'facter/util/ec2'
|
5
5
|
|
6
6
|
describe Facter::Util::EC2 do
|
7
|
+
before do
|
8
|
+
# Squelch deprecation notices
|
9
|
+
Facter.stubs(:warnonce)
|
10
|
+
end
|
7
11
|
# This is the standard prefix for making an API call in EC2 (or fake)
|
8
12
|
# environments.
|
9
13
|
let(:api_prefix) { "http://169.254.169.254" }
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'facter/util/formatter'
|
3
|
+
|
4
|
+
describe Facter::Util::Formatter do
|
5
|
+
describe "formatting as json" do
|
6
|
+
it "formats the text as json when json is available", :if => Facter.json? do
|
7
|
+
JSON.expects(:pretty_generate).with({"hello" => "world"}).returns(%Q({"hello": "world"}))
|
8
|
+
expect(described_class.format_json({"hello" => "world"})).to eq %Q({"hello": "world"})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "raises an error when JSON is not available" do
|
12
|
+
Facter.stubs(:json?).returns false
|
13
|
+
expect {
|
14
|
+
described_class.format_json({"hello" => "world"})
|
15
|
+
}.to raise_error(/'json' library is not present/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "formatting as yaml" do
|
20
|
+
it "dumps the text as YAML" do
|
21
|
+
expect(described_class.format_yaml({"hello" => "world"})).to match(/hello: world/)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "formatting as plaintext" do
|
26
|
+
it "formats a single string value without quotes" do
|
27
|
+
expect(described_class.format_plaintext({"foo" => "bar"})).to eq "bar"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "formats a structured value with #inspect" do
|
31
|
+
value = ["bar"]
|
32
|
+
value.expects(:inspect).returns %Q(["bar"])
|
33
|
+
hash = {"foo" => value, "baz" => "quux"}
|
34
|
+
expect(described_class.format_plaintext(hash)).to match(%Q([bar]))
|
35
|
+
end
|
36
|
+
it "formats multiple string values as key/value pairs" do
|
37
|
+
hash = {"foo" => "bar", "baz" => "quux"}
|
38
|
+
expect(described_class.format_plaintext(hash)).to match(/foo => bar/)
|
39
|
+
expect(described_class.format_plaintext(hash)).to match(/baz => quux/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "formats multiple structured values with #inspect" do
|
43
|
+
value = ["bar"]
|
44
|
+
value.expects(:inspect).twice.returns %Q(["bar"])
|
45
|
+
hash = {"foo" => value, "baz" => "quux"}
|
46
|
+
expect(described_class.format_plaintext(hash)).to match(/foo => \["bar"\]/)
|
47
|
+
expect(described_class.format_plaintext(hash)).to match(/baz => quux/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -277,10 +277,10 @@ describe Facter::Util::Loader do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
it "should load facts on the facter search path only once" do
|
280
|
-
|
280
|
+
loader = loader_from(:env => {})
|
281
|
+
loader.load_all
|
281
282
|
|
282
|
-
|
283
|
-
|
284
|
-
Facter.value(:nosuchfact).should be_nil
|
283
|
+
loader.expects(:kernel_load).with(regexp_matches(/ec2/)).never
|
284
|
+
loader.load(:ec2)
|
285
285
|
end
|
286
286
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'facter/util/
|
4
|
+
require 'facter/util/config'
|
5
|
+
require 'facter/util/macosx' unless Facter::Util::Config.is_windows?
|
5
6
|
|
6
|
-
describe Facter::Util::Macosx do
|
7
|
+
describe "Facter::Util::Macosx", :unless => Facter::Util::Config.is_windows? do
|
7
8
|
let(:badplist) do
|
8
9
|
'<?xml version="1.0" encoding="UTF-8"?>
|
9
10
|
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
|
@@ -63,6 +63,17 @@ describe Facter::Manufacturer do
|
|
63
63
|
Facter.value(:reldate).should == "12/01/2006"
|
64
64
|
end
|
65
65
|
|
66
|
+
it "can parse smbios output that contains non-UTF8 characters" do
|
67
|
+
smbios_output = my_fixture_read("smartos_smbios")
|
68
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/smbios 2>/dev/null').returns(smbios_output)
|
69
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
70
|
+
|
71
|
+
query = { 'BIOS information' => [ { 'Release Date:' => 'reldate' } ] }
|
72
|
+
|
73
|
+
Facter::Manufacturer.dmi_find_system_info(query)
|
74
|
+
Facter.value(:reldate).should == "06/11/2007"
|
75
|
+
end
|
76
|
+
|
66
77
|
it "should not split on dmi keys containing the string Handle" do
|
67
78
|
dmidecode_output = <<-eos
|
68
79
|
Handle 0x1000, DMI type 16, 15 bytes
|
@@ -176,4 +187,37 @@ Handle 0x001F
|
|
176
187
|
Facter.value(:serialnumber).should == "56 4d 40 2b 4d 81 94 d6-e6 c5 56 a4 56 0c 9e 9f"
|
177
188
|
Facter.value(:productname).should == "VMware Virtual Platform"
|
178
189
|
end
|
190
|
+
|
191
|
+
describe "using sysctl to look up manufacturer information" do
|
192
|
+
before do
|
193
|
+
Facter.fact(:kernel).stubs(:value).returns 'OpenBSD'
|
194
|
+
end
|
195
|
+
|
196
|
+
let(:mfg_keys) do
|
197
|
+
{
|
198
|
+
'hw.vendor' => 'manufacturer',
|
199
|
+
'hw.product' => 'productname',
|
200
|
+
'hw.serialno' => 'serialnumber'
|
201
|
+
}
|
202
|
+
end
|
203
|
+
|
204
|
+
it "creates a new fact for the each hash key" do
|
205
|
+
mfg_keys.values.each do |value|
|
206
|
+
Facter.expects(:add).with(value)
|
207
|
+
end
|
208
|
+
described_class.sysctl_find_system_info(mfg_keys)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "uses sysctl to determine the value for that fact" do
|
212
|
+
mfg_keys.keys.each do |sysctl|
|
213
|
+
Facter::Util::POSIX.expects(:sysctl).with(sysctl).returns "sysctl #{sysctl}"
|
214
|
+
end
|
215
|
+
|
216
|
+
described_class.sysctl_find_system_info(mfg_keys)
|
217
|
+
|
218
|
+
mfg_keys.invert.each_pair do |factname, value|
|
219
|
+
expect(Facter.value(factname)).to eq "sysctl #{value}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
179
223
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'facter/util/operatingsystem'
|
3
|
+
|
4
|
+
describe Facter::Util::Operatingsystem do
|
5
|
+
describe "reading the os-release file" do
|
6
|
+
|
7
|
+
it "correctly parses the file on Cumulus Linux" do
|
8
|
+
values = described_class.os_release(my_fixture('cumuluslinux.txt'))
|
9
|
+
|
10
|
+
expect(values).to eq({
|
11
|
+
'NAME' => "Cumulus Linux",
|
12
|
+
'VERSION_ID' => "1.5.2",
|
13
|
+
'VERSION' => "1.5.2-28283a7-201311181623-final",
|
14
|
+
'PRETTY_NAME' => "Cumulus Linux",
|
15
|
+
'ID' => "cumulus-linux",
|
16
|
+
'ID_LIKE' => "debian",
|
17
|
+
'CPE_NAME' => "cpe:/o:cumulusnetworks:cumulus_linux:1.5.2-28283a7-201311181623-final",
|
18
|
+
'HOME_URL' => "http://www.cumulusnetworks.com/",
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
it "correctly parses the file on Sabayon" do
|
23
|
+
values = described_class.os_release(my_fixture('sabayon.txt'))
|
24
|
+
|
25
|
+
expect(values).to eq({
|
26
|
+
"NAME" => "Sabayon",
|
27
|
+
"ID" => "sabayon",
|
28
|
+
"PRETTY_NAME" => "Sabayon/Linux",
|
29
|
+
"ANSI_COLOR" => "1;32",
|
30
|
+
"HOME_URL" => "http://www.sabayon.org/",
|
31
|
+
"SUPPORT_URL" => "http://forum.sabayon.org/",
|
32
|
+
"BUG_REPORT_URL" => "https://bugs.sabayon.org/",
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
36
|
+
it "correctly parses the file on Debian Wheezy" do
|
37
|
+
values = described_class.os_release(my_fixture('wheezy.txt'))
|
38
|
+
|
39
|
+
expect(values).to eq({
|
40
|
+
"PRETTY_NAME" => "Debian GNU/Linux 7 (wheezy)",
|
41
|
+
"NAME" => "Debian GNU/Linux",
|
42
|
+
"VERSION_ID" => "7",
|
43
|
+
"VERSION" => "7 (wheezy)",
|
44
|
+
"ID" => "debian",
|
45
|
+
"ANSI_COLOR" => "1;31",
|
46
|
+
"HOME_URL" => "http://www.debian.org/",
|
47
|
+
"SUPPORT_URL" => "http://www.debian.org/support/",
|
48
|
+
"BUG_REPORT_URL" => "http://bugs.debian.org/",
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
52
|
+
it "correctly parses the file on Debian Wheezy" do
|
53
|
+
values = described_class.os_release(my_fixture('wheezy.txt'))
|
54
|
+
|
55
|
+
expect(values).to eq({
|
56
|
+
"PRETTY_NAME" => "Debian GNU/Linux 7 (wheezy)",
|
57
|
+
"NAME" => "Debian GNU/Linux",
|
58
|
+
"VERSION_ID" => "7",
|
59
|
+
"VERSION" => "7 (wheezy)",
|
60
|
+
"ID" => "debian",
|
61
|
+
"ANSI_COLOR" => "1;31",
|
62
|
+
"HOME_URL" => "http://www.debian.org/",
|
63
|
+
"SUPPORT_URL" => "http://www.debian.org/support/",
|
64
|
+
"BUG_REPORT_URL" => "http://bugs.debian.org/",
|
65
|
+
})
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it "correctly parses the file on RedHat 7" do
|
70
|
+
values = described_class.os_release(my_fixture('redhat-7.txt'))
|
71
|
+
expect(values).to eq({
|
72
|
+
"NAME" => "Red Hat Enterprise Linux Everything",
|
73
|
+
"VERSION" => "7.0 (Maipo)",
|
74
|
+
"ID" => "rhel",
|
75
|
+
"VERSION_ID" => "7.0",
|
76
|
+
"PRETTY_NAME" => "Red Hat Enterprise Linux Everything 7.0 (Maipo)",
|
77
|
+
"ANSI_COLOR" => "0;31",
|
78
|
+
"CPE_NAME" => "cpe:/o:redhat:enterprise_linux:7.0:beta:everything",
|
79
|
+
"REDHAT_BUGZILLA_PRODUCT" => "Red Hat Enterprise Linux 7",
|
80
|
+
"REDHAT_BUGZILLA_PRODUCT_VERSION" => "7.0",
|
81
|
+
"REDHAT_SUPPORT_PRODUCT" => "Red Hat Enterprise Linux",
|
82
|
+
"REDHAT_SUPPORT_PRODUCT_VERSION" => "7.0",
|
83
|
+
})
|
84
|
+
end
|
85
|
+
|
86
|
+
it "does not try to read an unreadable '/etc/os-release' file" do
|
87
|
+
File.expects(:readable?).with('/some/nonexistent/file').returns false
|
88
|
+
|
89
|
+
expect(described_class.os_release('/some/nonexistent/file')).to be_empty
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|