facter 1.5.4 → 1.5.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.

Files changed (47) hide show
  1. data/CHANGELOG +75 -22
  2. data/COPYING +289 -623
  3. data/Rakefile +60 -55
  4. data/bin/facter +39 -26
  5. data/conf/osx/PackageInfo.plist +30 -30
  6. data/conf/osx/createpackage.sh +17 -17
  7. data/conf/osx/preflight +1 -1
  8. data/install.rb +226 -226
  9. data/lib/facter.rb +12 -12
  10. data/lib/facter/architecture.rb +14 -3
  11. data/lib/facter/ec2.rb +35 -0
  12. data/lib/facter/hardwareisa.rb +1 -1
  13. data/lib/facter/id.rb +1 -1
  14. data/lib/facter/ipaddress.rb +41 -41
  15. data/lib/facter/kernel.rb +2 -2
  16. data/lib/facter/kernelmajversion.rb +5 -0
  17. data/lib/facter/lsb.rb +5 -5
  18. data/lib/facter/lsbmajdistrelease.rb +1 -1
  19. data/lib/facter/macaddress.rb +6 -6
  20. data/lib/facter/manufacturer.rb +8 -8
  21. data/lib/facter/memory.rb +5 -4
  22. data/lib/facter/netmask.rb +4 -4
  23. data/lib/facter/network.rb +4 -5
  24. data/lib/facter/operatingsystem.rb +13 -7
  25. data/lib/facter/operatingsystemrelease.rb +5 -5
  26. data/lib/facter/selinux.rb +45 -0
  27. data/lib/facter/timezone.rb +1 -1
  28. data/lib/facter/uniqueid.rb +2 -2
  29. data/lib/facter/uptime.rb +3 -3
  30. data/lib/facter/util/confine.rb +12 -12
  31. data/lib/facter/util/ip.rb +18 -22
  32. data/lib/facter/util/macosx.rb +5 -0
  33. data/lib/facter/util/manufacturer.rb +37 -37
  34. data/lib/facter/util/plist/generator.rb +181 -179
  35. data/lib/facter/util/plist/parser.rb +162 -163
  36. data/lib/facter/util/resolution.rb +2 -2
  37. data/lib/facter/util/uptime.rb +10 -12
  38. data/lib/facter/util/values.rb +14 -0
  39. data/lib/facter/virtual.rb +54 -34
  40. data/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces +10 -0
  41. data/spec/unit/operatingsystem.rb +36 -0
  42. data/spec/unit/selinux.rb +48 -0
  43. data/spec/unit/util/confine.rb +70 -5
  44. data/spec/unit/util/ip.rb +29 -3
  45. metadata +89 -77
  46. data/documentation/custom.page +0 -22
  47. data/documentation/index.page +0 -19
@@ -0,0 +1,10 @@
1
+ lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
2
+ inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
3
+ inet 127.0.0.1 netmask 0xff000000
4
+ inet6 ::1 prefixlen 128
5
+ en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
6
+ inet6 fe80::223:6cff:fe99:602b%en1 prefixlen 64 scopeid 0x5
7
+ inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255
8
+ ether 00:23:6c:99:60:2b
9
+ media: autoselect status: active
10
+ supported media: autoselect
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ require 'facter'
6
+
7
+ describe "Operating System fact" do
8
+
9
+
10
+ after do
11
+ Facter.clear
12
+ end
13
+
14
+ it "should default to the kernel name" do
15
+ Facter.fact(:kernel).stubs(:value).returns("Nutmeg")
16
+
17
+ Facter.fact(:operatingsystem).value.should == "Nutmeg"
18
+ end
19
+
20
+ it "should be Solaris for SunOS" do
21
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
22
+
23
+ Facter.fact(:operatingsystem).value.should == "Solaris"
24
+ end
25
+
26
+ it "should identify Oracle VM as OVS" do
27
+
28
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
29
+ FileTest.stubs(:exists?).returns false
30
+
31
+ FileTest.expects(:exists?).with("/etc/ovs-release").returns true
32
+ FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
33
+
34
+ Facter.fact(:operatingsystem).value.should == "OVS"
35
+ end
36
+ end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ require 'facter'
6
+
7
+ describe "SELinux facts" do
8
+
9
+
10
+ after do
11
+ Facter.clear
12
+ end
13
+
14
+ it "should return true if SELinux enabled" do
15
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
16
+
17
+ FileTest.stubs(:exists?).returns false
18
+ File.stubs(:read).with("/proc/self/attr/current").returns("notkernel")
19
+
20
+ FileTest.expects(:exists?).with("/selinux/enforce").returns true
21
+ FileTest.expects(:exists?).with("/proc/self/attr/current").returns true
22
+ File.expects(:read).with("/proc/self/attr/current").returns("kernel")
23
+
24
+ Facter.fact(:selinux).value.should == "true"
25
+ end
26
+
27
+ it "should return true if SELinux policy enabled" do
28
+ Facter.fact(:selinux).stubs(:value).returns("true")
29
+
30
+ FileTest.stubs(:exists?).returns false
31
+ File.stubs(:read).with("/selinux/enforce").returns("0")
32
+
33
+ FileTest.expects(:exists?).with("/selinux/enforce").returns true
34
+ File.expects(:read).with("/selinux/enforce").returns("1")
35
+
36
+ Facter.fact(:selinux_enforced).value.should == "true"
37
+ end
38
+
39
+ it "should return an SELinux policy version" do
40
+ Facter.fact(:selinux).stubs(:value).returns("true")
41
+
42
+ File.stubs(:read).with("/selinux/policyvers").returns("")
43
+
44
+ File.expects(:read).with("/selinux/policyvers").returns("1")
45
+
46
+ Facter.fact(:selinux_policyversion).value.should == "1"
47
+ end
48
+ end
@@ -3,6 +3,9 @@
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
4
 
5
5
  require 'facter/util/confine'
6
+ require 'facter/util/values'
7
+
8
+ include Facter::Util::Values
6
9
 
7
10
  describe Facter::Util::Confine do
8
11
  it "should require a fact name" do
@@ -17,10 +20,6 @@ describe Facter::Util::Confine do
17
20
  Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"]
18
21
  end
19
22
 
20
- it "should convert all values to strings" do
21
- Facter::Util::Confine.new("yay", :test).values.should == %w{test}
22
- end
23
-
24
23
  it "should fail if no fact name is provided" do
25
24
  lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError)
26
25
  end
@@ -35,7 +34,7 @@ describe Facter::Util::Confine do
35
34
 
36
35
  describe "when evaluating" do
37
36
  before do
38
- @confine = Facter::Util::Confine.new("yay", "one", "two")
37
+ @confine = Facter::Util::Confine.new("yay", "one", "two", "Four", :xy, true, 1, [3,4])
39
38
  @fact = mock 'fact'
40
39
  Facter.stubs(:[]).returns @fact
41
40
  end
@@ -66,10 +65,76 @@ describe Facter::Util::Confine do
66
65
  @confine.true?.should be_true
67
66
  end
68
67
 
68
+ it "should return true if any of the provided symbol values matches the fact's value" do
69
+ @fact.stubs(:value).returns :xy
70
+
71
+ @confine.true?.should be_true
72
+ end
73
+
74
+ it "should return true if any of the provided integer values matches the fact's value" do
75
+ @fact.stubs(:value).returns 1
76
+
77
+ @confine.true?.should be_true
78
+ end
79
+
80
+ it "should return true if any of the provided boolan values matches the fact's value" do
81
+ @fact.stubs(:value).returns true
82
+
83
+ @confine.true?.should be_true
84
+ end
85
+
86
+ it "should return true if any of the provided array values matches the fact's value" do
87
+ @fact.stubs(:value).returns [3,4]
88
+
89
+ @confine.true?.should be_true
90
+ end
91
+
92
+ it "should return true if any of the provided symbol values matches the fact's string value" do
93
+ @fact.stubs(:value).returns :one
94
+
95
+ @confine.true?.should be_true
96
+ end
97
+
98
+ it "should return true if any of the provided string values matches case-insensitive the fact's value" do
99
+ @fact.stubs(:value).returns "four"
100
+
101
+ @confine.true?.should be_true
102
+ end
103
+
104
+ it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do
105
+ @fact.stubs(:value).returns :four
106
+
107
+ @confine.true?.should be_true
108
+ end
109
+
110
+ it "should return true if any of the provided symbol values matches the fact's string value" do
111
+ @fact.stubs(:value).returns :Xy
112
+
113
+ @confine.true?.should be_true
114
+ end
115
+
69
116
  it "should return false if none of the provided values matches the fact's value" do
70
117
  @fact.stubs(:value).returns "three"
71
118
 
72
119
  @confine.true?.should be_false
73
120
  end
121
+
122
+ it "should return false if none of the provided integer values matches the fact's value" do
123
+ @fact.stubs(:value).returns 2
124
+
125
+ @confine.true?.should be_false
126
+ end
127
+
128
+ it "should return false if none of the provided boolan values matches the fact's value" do
129
+ @fact.stubs(:value).returns false
130
+
131
+ @confine.true?.should be_false
132
+ end
133
+
134
+ it "should return false if none of the provided array values matches the fact's value" do
135
+ @fact.stubs(:value).returns [1,2]
136
+
137
+ @confine.true?.should be_false
138
+ end
74
139
  end
75
140
  end
@@ -27,6 +27,12 @@ describe Facter::Util::IP do
27
27
  Facter::Util::IP.get_interfaces().should == ["eth0"]
28
28
  end
29
29
 
30
+ it "should return a list two interfaces on Darwin with two interfaces" do
31
+ sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces'
32
+ darwin_ifconfig = File.new(sample_output_file).read()
33
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig)
34
+ Facter::Util::IP.get_interfaces().should == ["lo0", "en0"]
35
+ end
30
36
 
31
37
  it "should return a value for a specific interface" do
32
38
  Facter::Util::IP.should respond_to(:get_interface_value)
@@ -37,7 +43,17 @@ describe Facter::Util::IP do
37
43
  Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == []
38
44
  end
39
45
 
40
- it "should return interface information for directly supported platforms" do
46
+ it "should return ipaddress information for Solaris" do
47
+ sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
48
+ solaris_ifconfig_interface = File.new(sample_output_file).read()
49
+
50
+ Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
51
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
52
+
53
+ Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138"
54
+ end
55
+
56
+ it "should return netmask information for Solaris" do
41
57
  sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
42
58
  solaris_ifconfig_interface = File.new(sample_output_file).read()
43
59
 
@@ -47,7 +63,7 @@ describe Facter::Util::IP do
47
63
  Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
48
64
  end
49
65
 
50
- it "should return interface information for platforms supported via an alias" do
66
+ it "should return interface information for FreeBSD supported via an alias" do
51
67
  sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
52
68
  ifconfig_interface = File.new(sample_output_file).read()
53
69
 
@@ -57,7 +73,7 @@ describe Facter::Util::IP do
57
73
  Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c"
58
74
  end
59
75
 
60
- it "should return interface information for OS X" do
76
+ it "should return macaddress information for OS X" do
61
77
  sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
62
78
  ifconfig_interface = File.new(sample_output_file).read()
63
79
 
@@ -67,6 +83,16 @@ describe Facter::Util::IP do
67
83
  Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66"
68
84
  end
69
85
 
86
+ it "should return all interfaces correctly on OS X" do
87
+ sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
88
+ ifconfig_interface = File.new(sample_output_file).read()
89
+
90
+ Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface)
91
+ Facter.stubs(:value).with(:kernel).returns("Darwin")
92
+
93
+ Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"]
94
+ end
95
+
70
96
  it "should return a human readable netmask on Solaris" do
71
97
  sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
72
98
  solaris_ifconfig_interface = File.new(sample_output_file).read()
metadata CHANGED
@@ -1,126 +1,138 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
- - Luke Kanies
7
+ - Reductive Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-17 00:00:00 +01:00
13
- default_executable: facter
12
+ date: 2009-05-22 00:00:00 +00:00
13
+ default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Facter is a module for collecting simple facts about a host Operating system.
17
- email: dev@reductivelabs.com
18
- executables:
19
- - facter
16
+ description:
17
+ email: puppet@reductivelabs.com
18
+ executables: []
19
+
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - install.rb
25
+ - README.rst
26
26
  - COPYING
27
- - TODO
28
- - INSTALL
29
- - Rakefile
27
+ - CHANGELOG
30
28
  - README
31
- - README.rst
32
29
  - LICENSE
33
- - CHANGELOG
30
+ - INSTALL
31
+ - Rakefile
32
+ - TODO
33
+ - install.rb
34
34
  - bin/facter
35
- - lib/facter.rb
36
- - lib/facter/lsb.rb
37
- - lib/facter/network.rb
35
+ - lib/facter
38
36
  - lib/facter/processor.rb
39
- - lib/facter/id.rb
40
- - lib/facter/operatingsystem.rb
41
- - lib/facter/architecture.rb
42
- - lib/facter/operatingsystemrelease.rb
43
- - lib/facter/domain.rb
37
+ - lib/facter/macaddress.rb
38
+ - lib/facter/hostname.rb
39
+ - lib/facter/selinux.rb
40
+ - lib/facter/facterversion.rb
41
+ - lib/facter/macosx.rb
42
+ - lib/facter/hardwaremodel.rb
43
+ - lib/facter/kernelrelease.rb
44
+ - lib/facter/uptime.rb
45
+ - lib/facter/ec2.rb
46
+ - lib/facter/fqdn.rb
47
+ - lib/facter/iphostnumber.rb
44
48
  - lib/facter/uniqueid.rb
49
+ - lib/facter/puppetversion.rb
50
+ - lib/facter/timezone.rb
51
+ - lib/facter/manufacturer.rb
52
+ - lib/facter/operatingsystem.rb
53
+ - lib/facter/network.rb
54
+ - lib/facter/rubysitedir.rb
55
+ - lib/facter/ssh.rb
56
+ - lib/facter/rubyversion.rb
57
+ - lib/facter/netmask.rb
58
+ - lib/facter/kernelmajversion.rb
45
59
  - lib/facter/memory.rb
46
60
  - lib/facter/hardwareisa.rb
47
- - lib/facter/uptime.rb
48
- - lib/facter/facterversion.rb
61
+ - lib/facter/architecture.rb
49
62
  - lib/facter/ps.rb
50
- - lib/facter/rubysitedir.rb
51
- - lib/facter/hostname.rb
52
- - lib/facter/iphostnumber.rb
53
- - lib/facter/rubyversion.rb
54
- - lib/facter/Cfkey.rb
55
- - lib/facter/lsbmajdistrelease.rb
56
- - lib/facter/hardwaremodel.rb
57
- - lib/facter/interfaces.rb
63
+ - lib/facter/lsb.rb
64
+ - lib/facter/id.rb
65
+ - lib/facter/ipaddress.rb
66
+ - lib/facter/virtual.rb
58
67
  - lib/facter/kernelversion.rb
59
- - lib/facter/macaddress.rb
60
- - lib/facter/util/resolution.rb
61
- - lib/facter/util/collection.rb
68
+ - lib/facter/operatingsystemrelease.rb
69
+ - lib/facter/interfaces.rb
70
+ - lib/facter/util
62
71
  - lib/facter/util/confine.rb
63
- - lib/facter/util/loader.rb
64
- - lib/facter/util/memory.rb
65
- - lib/facter/util/fact.rb
66
- - lib/facter/util/uptime.rb
67
- - lib/facter/util/plist.rb
68
72
  - lib/facter/util/macosx.rb
69
- - lib/facter/util/ip.rb
73
+ - lib/facter/util/uptime.rb
74
+ - lib/facter/util/plist
70
75
  - lib/facter/util/plist/parser.rb
71
76
  - lib/facter/util/plist/generator.rb
77
+ - lib/facter/util/fact.rb
72
78
  - lib/facter/util/manufacturer.rb
79
+ - lib/facter/util/loader.rb
80
+ - lib/facter/util/collection.rb
73
81
  - lib/facter/util/netmask.rb
74
- - lib/facter/fqdn.rb
75
- - lib/facter/ssh.rb
76
- - lib/facter/ipaddress.rb
77
- - lib/facter/puppetversion.rb
78
- - lib/facter/macosx.rb
79
- - lib/facter/kernelrelease.rb
80
- - lib/facter/virtual.rb
81
- - lib/facter/manufacturer.rb
82
- - lib/facter/kernel.rb
82
+ - lib/facter/util/memory.rb
83
+ - lib/facter/util/plist.rb
84
+ - lib/facter/util/ip.rb
85
+ - lib/facter/util/resolution.rb
86
+ - lib/facter/util/values.rb
83
87
  - lib/facter/physicalprocessorcount.rb
84
- - lib/facter/netmask.rb
85
- - lib/facter/timezone.rb
86
- - spec/spec.opts
88
+ - lib/facter/lsbmajdistrelease.rb
89
+ - lib/facter/domain.rb
90
+ - lib/facter/kernel.rb
91
+ - lib/facter/Cfkey.rb
92
+ - lib/facter.rb
93
+ - conf/redhat
94
+ - conf/redhat/facter.spec
95
+ - conf/solaris
96
+ - conf/solaris/pkginfo
97
+ - conf/osx
98
+ - conf/osx/createpackage.sh
99
+ - conf/osx/PackageInfo.plist
100
+ - conf/osx/preflight
101
+ - etc/facter.conf
87
102
  - spec/unit
103
+ - spec/unit/selinux.rb
88
104
  - spec/unit/facter.rb
105
+ - spec/unit/operatingsystem.rb
89
106
  - spec/unit/data
107
+ - spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces
108
+ - spec/unit/data/linux_ifconfig_all_with_single_interface
109
+ - spec/unit/data/darwin_ifconfig_single_interface
90
110
  - spec/unit/data/Mac_OS_X_10.5.5_ifconfig
91
111
  - spec/unit/data/6.0-STABLE_FreeBSD_ifconfig
92
112
  - spec/unit/data/solaris_ifconfig_single_interface
93
- - spec/unit/data/linux_ifconfig_all_with_single_interface
94
- - spec/unit/data/darwin_ifconfig_single_interface
95
113
  - spec/unit/interfaces.rb
96
114
  - spec/unit/util
97
- - spec/unit/util/resolution.rb
98
- - spec/unit/util/collection.rb
99
115
  - spec/unit/util/confine.rb
100
- - spec/unit/util/loader.rb
101
- - spec/unit/util/fact.rb
102
116
  - spec/unit/util/macosx.rb
117
+ - spec/unit/util/fact.rb
118
+ - spec/unit/util/loader.rb
119
+ - spec/unit/util/collection.rb
103
120
  - spec/unit/util/ip.rb
121
+ - spec/unit/util/resolution.rb
122
+ - spec/spec_helper.rb
104
123
  - spec/integration
105
124
  - spec/integration/facter.rb
106
- - spec/spec_helper.rb
125
+ - spec/spec.opts
107
126
  - spec/Rakefile
108
- - conf/osx
109
- - conf/osx/createpackage.sh
110
- - conf/osx/PackageInfo.plist
111
- - conf/osx/preflight
112
- - conf/redhat
113
- - conf/redhat/facter.spec
114
- - conf/solaris
115
- - conf/solaris/pkginfo
116
- - documentation/index.page
117
- - documentation/custom.page
118
- - etc/facter.conf
119
- has_rdoc: false
120
- homepage: http://reductivelabs.com/projects/facter
127
+ has_rdoc: true
128
+ homepage: http://reductivelabs.com
121
129
  post_install_message:
122
- rdoc_options: []
123
-
130
+ rdoc_options:
131
+ - --title
132
+ - Facter - System Inventory Tool
133
+ - --main
134
+ - README
135
+ - --line-numbers
124
136
  require_paths:
125
137
  - lib
126
138
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -138,9 +150,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
150
  requirements: []
139
151
 
140
152
  rubyforge_project: facter
141
- rubygems_version: 1.2.0
153
+ rubygems_version: 1.3.1
142
154
  signing_key:
143
155
  specification_version: 2
144
- summary: Facter collects Operating system facts.
156
+ summary: Facter, a system inventory tool
145
157
  test_files: []
146
158