facter 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +42 -0
- data/COPYING +0 -458
- data/LICENSE +670 -13
- data/Rakefile +54 -10
- data/bin/facter +6 -2
- data/conf/osx/createpackage.sh +2 -1
- data/conf/osx/preflight +2 -1
- data/conf/redhat/facter.spec +25 -9
- data/install.rb +0 -0
- data/lib/facter.rb +6 -6
- data/lib/facter/Cfkey.rb +2 -2
- data/lib/facter/domain.rb +21 -52
- data/lib/facter/fqdn.rb +2 -1
- data/lib/facter/hardwareisa.rb +1 -1
- data/lib/facter/id.rb +12 -1
- data/lib/facter/interfaces.rb +32 -0
- data/lib/facter/ipaddress.rb +1 -1
- data/lib/facter/kernelrelease.rb +2 -2
- data/lib/facter/kernelversion.rb +4 -4
- data/lib/facter/lsb.rb +1 -1
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +27 -27
- data/lib/facter/macosx.rb +3 -3
- data/lib/facter/manufacturer.rb +11 -2
- data/lib/facter/network.rb +10 -0
- data/lib/facter/operatingsystem.rb +4 -0
- data/lib/facter/operatingsystemrelease.rb +12 -15
- data/lib/facter/processor.rb +1 -1
- data/lib/facter/puppetversion.rb +2 -2
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/uptime.rb +20 -0
- data/lib/facter/util/fact.rb +1 -1
- data/lib/facter/util/ip.rb +134 -66
- data/lib/facter/util/macosx.rb +43 -30
- data/lib/facter/util/manufacturer.rb +13 -6
- data/lib/facter/util/netmask.rb +21 -23
- data/lib/facter/util/plist.rb +1 -1
- data/lib/facter/util/uptime.rb +32 -0
- data/lib/facter/virtual.rb +66 -53
- data/spec/integration/facter.rb +0 -0
- data/spec/spec_helper.rb +1 -10
- data/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig +12 -0
- data/spec/unit/data/Mac_OS_X_10.5.5_ifconfig +26 -0
- data/spec/unit/data/darwin_ifconfig_single_interface +6 -0
- data/spec/unit/facter.rb +1 -1
- data/spec/unit/interfaces.rb +19 -0
- data/spec/unit/util/collection.rb +2 -2
- data/spec/unit/util/confine.rb +0 -0
- data/spec/unit/util/fact.rb +0 -0
- data/spec/unit/util/ip.rb +65 -9
- data/spec/unit/util/loader.rb +1 -1
- data/spec/unit/util/macosx.rb +47 -0
- data/spec/unit/util/resolution.rb +0 -0
- metadata +12 -4
- data/lib/facter/ipmess.rb +0 -46
@@ -114,7 +114,7 @@ describe Facter::Util::Collection do
|
|
114
114
|
it "should be case-insensitive" do
|
115
115
|
@coll.fact("yayness").should equal(@fact)
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
it "should treat strings and symbols equivalently" do
|
119
119
|
@coll.fact(:yayness).should equal(@fact)
|
120
120
|
end
|
@@ -156,7 +156,7 @@ describe Facter::Util::Collection do
|
|
156
156
|
it "should be case-insensitive" do
|
157
157
|
@coll.value("yayness").should_not be_nil
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "should treat strings and symbols equivalently" do
|
161
161
|
@coll.value(:yayness).should_not be_nil
|
162
162
|
end
|
data/spec/unit/util/confine.rb
CHANGED
File without changes
|
data/spec/unit/util/fact.rb
CHANGED
File without changes
|
data/spec/unit/util/ip.rb
CHANGED
@@ -4,37 +4,93 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
4
4
|
|
5
5
|
require 'facter/util/ip'
|
6
6
|
|
7
|
-
describe Facter::
|
7
|
+
describe Facter::Util::IP do
|
8
|
+
[:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin].each do |platform|
|
9
|
+
it "should be supported on #{platform}" do
|
10
|
+
Facter::Util::IP.supported_platforms.should be_include(platform)
|
11
|
+
end
|
12
|
+
end
|
8
13
|
|
9
14
|
it "should return a list of interfaces" do
|
10
|
-
|
15
|
+
Facter::Util::IP.should respond_to(:get_interfaces)
|
11
16
|
end
|
12
17
|
|
13
18
|
it "should return an empty list of interfaces on an unknown kernel" do
|
14
19
|
Facter.stubs(:value).returns("UnknownKernel")
|
15
|
-
Facter::
|
20
|
+
Facter::Util::IP.get_interfaces().should == []
|
16
21
|
end
|
17
22
|
|
18
23
|
it "should return a list with a single interface on Linux with a single interface" do
|
19
24
|
sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface'
|
20
25
|
linux_ifconfig = File.new(sample_output_file).read()
|
21
|
-
Facter::
|
22
|
-
Facter::
|
26
|
+
Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
|
27
|
+
Facter::Util::IP.get_interfaces().should == ["eth0"]
|
23
28
|
end
|
24
29
|
|
30
|
+
|
25
31
|
it "should return a value for a specific interface" do
|
26
|
-
|
32
|
+
Facter::Util::IP.should respond_to(:get_interface_value)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not return interface information for unsupported platforms" do
|
36
|
+
Facter.stubs(:value).with(:kernel).returns("bleah")
|
37
|
+
Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == []
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return interface information for directly supported platforms" do
|
41
|
+
sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
|
42
|
+
solaris_ifconfig_interface = File.new(sample_output_file).read()
|
43
|
+
|
44
|
+
Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
45
|
+
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
46
|
+
|
47
|
+
Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return interface information for platforms supported via an alias" do
|
51
|
+
sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
|
52
|
+
ifconfig_interface = File.new(sample_output_file).read()
|
53
|
+
|
54
|
+
Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface)
|
55
|
+
Facter.stubs(:value).with(:kernel).returns("FreeBSD")
|
56
|
+
|
57
|
+
Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return interface information for OS X" do
|
61
|
+
sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
|
62
|
+
ifconfig_interface = File.new(sample_output_file).read()
|
63
|
+
|
64
|
+
Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface)
|
65
|
+
Facter.stubs(:value).with(:kernel).returns("Darwin")
|
66
|
+
|
67
|
+
Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66"
|
27
68
|
end
|
28
69
|
|
29
70
|
it "should return a human readable netmask on Solaris" do
|
30
71
|
sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
|
31
72
|
solaris_ifconfig_interface = File.new(sample_output_file).read()
|
32
73
|
|
33
|
-
Facter::
|
74
|
+
Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
34
75
|
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
35
76
|
|
36
|
-
Facter::
|
77
|
+
Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
|
37
78
|
end
|
38
79
|
|
39
|
-
|
80
|
+
it "should return a human readable netmask on Darwin" do
|
81
|
+
sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface"
|
40
82
|
|
83
|
+
darwin_ifconfig_interface = File.new(sample_output_file).read()
|
84
|
+
|
85
|
+
Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface)
|
86
|
+
Facter.stubs(:value).with(:kernel).returns("Darwin")
|
87
|
+
|
88
|
+
Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0"
|
89
|
+
end
|
90
|
+
|
91
|
+
[:freebsd, :netbsd, :openbsd, :sunos, :darwin].each do |platform|
|
92
|
+
it "should require conversion from hex on #{platform}" do
|
93
|
+
Facter::Util::IP.convert_from_hex?(platform).should == true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/spec/unit/util/loader.rb
CHANGED
@@ -83,7 +83,7 @@ describe Facter::Util::Loader do
|
|
83
83
|
@loader.load(:testing)
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it "should load any files in the search path with names matching the fact name" do
|
88
88
|
@loader.expects(:search_path).returns %w{/one/dir /two/dir}
|
89
89
|
FileTest.stubs(:exist?).returns false
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
|
+
|
5
|
+
require 'facter/util/macosx'
|
6
|
+
|
7
|
+
describe Facter::Util::Macosx do
|
8
|
+
it "should be able to retrieve profiler data as xml for a given data field" do
|
9
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/system_profiler -xml foo").returns "yay"
|
10
|
+
Facter::Util::Macosx.profiler_xml("foo").should == "yay"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should use PList to convert xml to data structures" do
|
14
|
+
Plist.expects(:parse_xml).with("foo").returns "bar"
|
15
|
+
|
16
|
+
Facter::Util::Macosx.intern_xml("foo").should == "bar"
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "when collecting profiler data" do
|
20
|
+
it "should return the first value in the '_items' hash in the first value of the results of the system_profiler data, with the '_name' field removed, if the profiler returns data" do
|
21
|
+
@result = [
|
22
|
+
'_items' => [
|
23
|
+
{'_name' => "foo", "yay" => "bar"}
|
24
|
+
]
|
25
|
+
]
|
26
|
+
Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh"
|
27
|
+
Facter::Util::Macosx.expects(:intern_xml).with("eh").returns @result
|
28
|
+
Facter::Util::Macosx.profiler_data("foo").should == {"yay" => "bar"}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return nil if an exception is thrown during parsing of xml" do
|
32
|
+
Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh"
|
33
|
+
Facter::Util::Macosx.expects(:intern_xml).with("eh").raises "boo!"
|
34
|
+
Facter::Util::Macosx.profiler_data("foo").should be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the profiler data for 'SPHardwareDataType' as the hardware information" do
|
39
|
+
Facter::Util::Macosx.expects(:profiler_data).with("SPHardwareDataType").returns "eh"
|
40
|
+
Facter::Util::Macosx.hardware_overview.should == "eh"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the profiler data for 'SPSoftwareDataType' as the os information" do
|
44
|
+
Facter::Util::Macosx.expects(:profiler_data).with("SPSoftwareDataType").returns "eh"
|
45
|
+
Facter::Util::Macosx.os_overview.should == "eh"
|
46
|
+
end
|
47
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Kanies
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-28 00:00:00 +01:00
|
13
13
|
default_executable: facter
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- bin/facter
|
34
34
|
- lib/facter.rb
|
35
35
|
- lib/facter/lsb.rb
|
36
|
+
- lib/facter/network.rb
|
36
37
|
- lib/facter/processor.rb
|
37
38
|
- lib/facter/id.rb
|
38
39
|
- lib/facter/operatingsystem.rb
|
@@ -42,6 +43,7 @@ files:
|
|
42
43
|
- lib/facter/uniqueid.rb
|
43
44
|
- lib/facter/memory.rb
|
44
45
|
- lib/facter/hardwareisa.rb
|
46
|
+
- lib/facter/uptime.rb
|
45
47
|
- lib/facter/facterversion.rb
|
46
48
|
- lib/facter/ps.rb
|
47
49
|
- lib/facter/rubysitedir.rb
|
@@ -51,6 +53,7 @@ files:
|
|
51
53
|
- lib/facter/Cfkey.rb
|
52
54
|
- lib/facter/lsbmajdistrelease.rb
|
53
55
|
- lib/facter/hardwaremodel.rb
|
56
|
+
- lib/facter/interfaces.rb
|
54
57
|
- lib/facter/kernelversion.rb
|
55
58
|
- lib/facter/macaddress.rb
|
56
59
|
- lib/facter/util/resolution.rb
|
@@ -59,6 +62,7 @@ files:
|
|
59
62
|
- lib/facter/util/loader.rb
|
60
63
|
- lib/facter/util/memory.rb
|
61
64
|
- lib/facter/util/fact.rb
|
65
|
+
- lib/facter/util/uptime.rb
|
62
66
|
- lib/facter/util/plist.rb
|
63
67
|
- lib/facter/util/macosx.rb
|
64
68
|
- lib/facter/util/ip.rb
|
@@ -75,20 +79,24 @@ files:
|
|
75
79
|
- lib/facter/virtual.rb
|
76
80
|
- lib/facter/manufacturer.rb
|
77
81
|
- lib/facter/kernel.rb
|
78
|
-
- lib/facter/ipmess.rb
|
79
82
|
- lib/facter/netmask.rb
|
80
83
|
- spec/spec.opts
|
81
84
|
- spec/unit
|
82
85
|
- spec/unit/facter.rb
|
83
86
|
- spec/unit/data
|
87
|
+
- spec/unit/data/Mac_OS_X_10.5.5_ifconfig
|
88
|
+
- spec/unit/data/6.0-STABLE_FreeBSD_ifconfig
|
84
89
|
- spec/unit/data/solaris_ifconfig_single_interface
|
85
90
|
- spec/unit/data/linux_ifconfig_all_with_single_interface
|
91
|
+
- spec/unit/data/darwin_ifconfig_single_interface
|
92
|
+
- spec/unit/interfaces.rb
|
86
93
|
- spec/unit/util
|
87
94
|
- spec/unit/util/resolution.rb
|
88
95
|
- spec/unit/util/collection.rb
|
89
96
|
- spec/unit/util/confine.rb
|
90
97
|
- spec/unit/util/loader.rb
|
91
98
|
- spec/unit/util/fact.rb
|
99
|
+
- spec/unit/util/macosx.rb
|
92
100
|
- spec/unit/util/ip.rb
|
93
101
|
- spec/integration
|
94
102
|
- spec/integration/facter.rb
|
@@ -127,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
135
|
requirements: []
|
128
136
|
|
129
137
|
rubyforge_project: facter
|
130
|
-
rubygems_version: 1.0
|
138
|
+
rubygems_version: 1.2.0
|
131
139
|
signing_key:
|
132
140
|
specification_version: 2
|
133
141
|
summary: Facter collects Operating system facts.
|
data/lib/facter/ipmess.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# ipmess.rb
|
2
|
-
# Try to get additional Facts about the machine's network interfaces
|
3
|
-
#
|
4
|
-
# Original concept Copyright (C) 2007 psychedelys <psychedelys@gmail.com>
|
5
|
-
# Update and *BSD support (C) 2007 James Turnbull <james@lovedthanlost.net>
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'facter/util/ip'
|
9
|
-
|
10
|
-
Facter.add(:interfaces) do
|
11
|
-
confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
|
12
|
-
setcode do
|
13
|
-
Facter::IPAddress.get_interfaces.join(",")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
case Facter.value(:kernel)
|
18
|
-
when 'SunOS', 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD'
|
19
|
-
Facter::IPAddress.get_interfaces.each do |interface|
|
20
|
-
mi = interface.gsub('/:|\./', '_')
|
21
|
-
|
22
|
-
Facter.add("ipaddress_" + mi) do
|
23
|
-
confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
|
24
|
-
setcode do
|
25
|
-
label = 'ipaddress'
|
26
|
-
Facter::IPAddress.get_interface_value(interface, label)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Facter.add("macaddress_" + mi) do
|
31
|
-
confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
|
32
|
-
setcode do
|
33
|
-
label = 'macaddress'
|
34
|
-
Facter::IPAddress.get_interface_value(interface, label)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
Facter.add("netmask_" + mi) do
|
39
|
-
confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
|
40
|
-
setcode do
|
41
|
-
label = 'netmask'
|
42
|
-
Facter::IPAddress.get_interface_value(interface, label)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|