facter 1.6.14 → 1.6.15.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/Rakefile CHANGED
@@ -6,16 +6,16 @@ require 'facter/version'
6
6
 
7
7
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
8
8
 
9
- require 'rubygems'
10
- require 'rspec'
11
- require 'rspec/core/rake_task'
12
- require 'rake'
13
-
14
9
  begin
10
+ require 'rubygems'
11
+ require 'rspec'
12
+ require 'rspec/core/rake_task'
15
13
  require 'rcov'
16
14
  rescue LoadError
17
15
  end
18
16
 
17
+ require 'rake'
18
+
19
19
  Dir['tasks/**/*.rake'].each { |t| load t }
20
20
  Dir['ext/packaging/tasks/**/*'].sort.each { |t| load t }
21
21
 
@@ -55,17 +55,19 @@ task :default do
55
55
  sh %{rake -T}
56
56
  end
57
57
 
58
- desc "Run all specs"
59
- RSpec::Core::RakeTask.new do |t|
60
- t.pattern ='spec/{unit,integration}/**/*_spec.rb'
61
- t.fail_on_error = true
62
- end
58
+ if defined?(RSpec::Core::RakeTask)
59
+ desc "Run all specs"
60
+ RSpec::Core::RakeTask.new do |t|
61
+ t.pattern ='spec/{unit,integration}/**/*_spec.rb'
62
+ t.fail_on_error = true
63
+ end
63
64
 
64
- RSpec::Core::RakeTask.new('spec:rcov') do |t|
65
- t.pattern ='spec/{unit,integration}/**/*_spec.rb'
66
- t.fail_on_error = true
67
- if defined?(Rcov)
68
- t.rcov = true
69
- t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
65
+ RSpec::Core::RakeTask.new('spec:rcov') do |t|
66
+ t.pattern ='spec/{unit,integration}/**/*_spec.rb'
67
+ t.fail_on_error = true
68
+ if defined?(Rcov)
69
+ t.rcov = true
70
+ t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
71
+ end
70
72
  end
71
73
  end
@@ -15,6 +15,7 @@ yum_host: 'burji.puppetlabs.com'
15
15
  yum_repo_path: '/opt/repository/yum/'
16
16
  build_gem: TRUE
17
17
  build_dmg: TRUE
18
+ build_ips: TRUE
18
19
  apt_host: 'burji.puppetlabs.com'
19
20
  apt_repo_url: 'http://apt.puppetlabs.com'
20
21
  apt_repo_path: '/opt/repository/incoming'
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/make -f
2
2
 
3
- LIBDIR=$(shell /usr/bin/ruby18 -rrbconfig -e 'puts Config::CONFIG["rubylibdir"]')
3
+ LIBDIR=$(shell /usr/bin/ruby18 -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')
4
4
  DESTDIR=$(CURDIR)/pkg/ips/proto
5
5
 
6
6
  binary-install/facter::
7
- /usr/bin/ruby18 install.rb --destdir=$(DESTDIR) --bindir=/usr/bin --sbindir=/usr/sbin --sitelibdir=$(LIBDIR) --mandir=/usr/share/man
7
+ /usr/bin/ruby18 install.rb --destdir=$(DESTDIR) --bindir=/usr/bin --sitelibdir=$(LIBDIR) --mandir=/usr/share/man
@@ -14,13 +14,15 @@ def metadata(id = "")
14
14
  metadata(key)
15
15
  end
16
16
  end
17
+ rescue => details
18
+ Facter.warn "Could not retrieve ec2 metadata: #{details.message}"
17
19
  end
18
20
 
19
21
  def userdata()
20
- begin
21
- value = open("http://169.254.169.254/2008-02-01/user-data/").read.split
22
- Facter.add(:ec2_userdata) { setcode { value } }
23
- rescue OpenURI::HTTPError
22
+ Facter.add(:ec2_userdata) do
23
+ setcode do
24
+ open("http://169.254.169.254/2008-02-01/user-data/").read.split
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -31,7 +31,7 @@ Facter::Util::IP.get_interfaces.each do |interface|
31
31
  # Make a fact for each detail of each interface. Yay.
32
32
  # There's no point in confining these facts, since we wouldn't be able to create
33
33
  # them if we weren't running on a supported platform.
34
- %w{ipaddress ipaddress6 macaddress netmask}.each do |label|
34
+ %w{ipaddress ipaddress6 macaddress netmask mtu}.each do |label|
35
35
  Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do
36
36
  setcode do
37
37
  Facter::Util::IP.get_interface_value(interface, label)
@@ -27,6 +27,8 @@ require 'facter/util/processor'
27
27
  processor_list = case Facter::Util::Processor.kernel_fact_value
28
28
  when "AIX"
29
29
  Facter::Util::Processor.aix_processor_list
30
+ when "HP-UX"
31
+ Facter::Util::Processor.hpux_processor_list
30
32
  when "SunOS"
31
33
  Facter::Util::Processor.enum_kstat
32
34
  else
@@ -35,7 +37,7 @@ end
35
37
 
36
38
  processor_list.each_with_index do |desc, i|
37
39
  Facter.add("Processor#{i}") do
38
- confine :kernel => [ :aix, :sunos, :linux, :"gnu/kfreebsd" ]
40
+ confine :kernel => [ :aix, :"hp-ux", :sunos, :linux, :"gnu/kfreebsd" ]
39
41
  setcode do
40
42
  desc
41
43
  end
@@ -77,6 +79,14 @@ Facter.add("ProcessorCount") do
77
79
  end
78
80
  end
79
81
 
82
+ Facter.add("ProcessorCount") do
83
+ confine :kernel => :"hp-ux"
84
+ setcode do
85
+ processor_list = Facter::Util::Processor.hpux_processor_list
86
+ processor_list.length.to_s
87
+ end
88
+ end
89
+
80
90
  Facter.add("Processor") do
81
91
  confine :kernel => :openbsd
82
92
  setcode do
@@ -14,10 +14,8 @@ module Facter::Util::EC2
14
14
  url = "http://169.254.169.254:80/"
15
15
  Timeout::timeout(wait_sec) {open(url)}
16
16
  return true
17
- rescue Timeout::Error
18
- return false
19
- rescue
20
- return false
17
+ rescue
18
+ return false
21
19
  end
22
20
 
23
21
  # Test if this host has a mac address used by Eucalyptus clouds, which
@@ -36,19 +34,24 @@ module Facter::Util::EC2
36
34
  # Test if the host has an arp entry in its cache that matches the EC2 arp,
37
35
  # which is normally +fe:ff:ff:ff:ff:ff+.
38
36
  def has_ec2_arp?
39
- mac_address = "fe:ff:ff:ff:ff:ff"
40
- if Facter.value(:kernel) == 'windows'
41
- arp_command = "arp -a"
42
- mac_address.gsub!(":","-")
43
- else
44
- arp_command = "arp -an"
45
- end
37
+ kernel = Facter.value(:kernel)
38
+
39
+ mac_address_re = case kernel
40
+ when /Windows/i
41
+ /fe-ff-ff-ff-ff-ff/i
42
+ else
43
+ /fe:ff:ff:ff:ff:ff/i
44
+ end
45
+
46
+ arp_command = case kernel
47
+ when /Windows/i, /SunOS/i
48
+ "arp -a"
49
+ else
50
+ "arp -an"
51
+ end
46
52
 
47
- arp_table = Facter::Util::Resolution.exec(arp_command)
48
- if not arp_table.nil?
49
- arp_table.each_line do |line|
50
- return true if line.downcase.include?(mac_address)
51
- end
53
+ if arp_table = Facter::Util::Resolution.exec(arp_command)
54
+ return true if arp_table.match(mac_address_re)
52
55
  end
53
56
  return false
54
57
  end
@@ -8,20 +8,23 @@ module Facter::Util::IP
8
8
  :ipaddress => /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
9
9
  :ipaddress6 => /inet6 addr: ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
10
10
  :macaddress => /(?:ether|HWaddr)\s+((\w{1,2}:){5,}\w{1,2})/,
11
- :netmask => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
11
+ :netmask => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
12
+ :mtu => /MTU:(\d+)/
12
13
  },
13
14
  :bsd => {
14
15
  :aliases => [:openbsd, :netbsd, :freebsd, :darwin, :"gnu/kfreebsd", :dragonfly],
15
16
  :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
16
17
  :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
17
18
  :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
18
- :netmask => /netmask\s+0x(\w{8})/
19
+ :netmask => /netmask\s+0x(\w{8})/,
20
+ :mtu => /mtu\s+(\d+)/
19
21
  },
20
22
  :sunos => {
21
23
  :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
22
24
  :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
23
25
  :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
24
- :netmask => /netmask\s+(\w{8})/
26
+ :netmask => /netmask\s+(\w{8})/,
27
+ :mtu => /mtu\s+(\d+)/
25
28
  },
26
29
  :"hp-ux" => {
27
30
  :ipaddress => /\s+inet (\S+)\s.*/,
@@ -70,6 +70,145 @@ module Processor
70
70
  Facter.value(:kernel)
71
71
  end
72
72
 
73
+ ##
74
+ # hpux_processor_list is intended to generate a list of values for the
75
+ # processorX facts.
76
+ def self.hpux_processor_list
77
+ return_value = []
78
+ hpux_proc_id_list = []
79
+ cpu = ""
80
+
81
+ ##
82
+ # first, try parsing machinfo output.
83
+ if output = machinfo then
84
+ output.split("\n").each do |line|
85
+ if line.match(/processor model:\s+\d+\s+(.*)/) then
86
+ cpu = $1.to_s
87
+ elsif line.match(/\d+\s+((?:PA-RISC|Intel).*processors.*)/) then
88
+ cpu = $1.to_s
89
+ cpu.sub!(/processors/, "processor")
90
+ end
91
+ end
92
+ end
93
+
94
+ ##
95
+ # if that fails, try looking using model command and cross referencing against
96
+ # sched.models, which could be in three places. This file only catered for
97
+ # PA-RISC. Unfortunately, the file is not up to date sometimes.
98
+ if cpu.empty? then
99
+ m = model
100
+ m.sub!(/\s+$/, "")
101
+ m.sub!(/.*\//, "")
102
+ m.sub!(/.*\s+/, "")
103
+
104
+ if sched_models_lines = read_sched_models
105
+ sched_models_lines.each do |l|
106
+ if l.match(m) and l.match(/^\S+\s+\d+\.\d+\s+(\S+)/) then
107
+ cpu = "PA-RISC " + $1.to_s.sub!(/^PA/, "") + " processor"
108
+ break # we assume first match is the only match.
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ ##
115
+ # if that also fails, report the CPU version based on unistd.h and chip type based on getconf.
116
+ if cpu.empty? then
117
+ cpu_version = getconf_cpu_version
118
+ cpu_chip_type = getconf_cpu_chip_type
119
+ cpu_string = ""
120
+
121
+ if lines = read_unistd_h("/usr/include/sys/unistd.h") then
122
+ lines.each do |l|
123
+ if l.match(/define.*0x#{cpu_version.to_i.to_s(16)}.*\/\*\s+(.*)\s+\*\//) then
124
+ cpu_string = $1.to_s
125
+ break
126
+ end
127
+ end
128
+ end
129
+
130
+ if cpu_string.empty? then
131
+ cpu_string = "CPU v" + cpu_version
132
+ end
133
+
134
+ cpu = cpu_string + " CHIP TYPE #" + cpu_chip_type
135
+ end
136
+
137
+ ##
138
+ # now count (logical) CPUs using ioscan. We set processorX for X in 0..processorcount
139
+ # to cpu as worked out above. HP-UX does not support more than one installed CPU
140
+ # model.
141
+ if output = ioscan then
142
+ output.split("\n").each do |line|
143
+ if line.match(/processor/) then
144
+ hpux_proc_id_list << cpu
145
+ end
146
+ end
147
+ end
148
+
149
+ hpux_proc_id_list
150
+ end
151
+
152
+ ##
153
+ # read_sched_models is intended to be stubbed instead of File.readlines
154
+ # @return [Array] of strings containing the lines of the file or nil if the
155
+ # sched.models file could not be located.
156
+ def self.read_sched_models
157
+ path = if File.exists?("/usr/lib/sched.models")
158
+ "/usr/lib/sched.models"
159
+ elsif File.exists?("/usr/sam/lib/mo/sched.models")
160
+ "/usr/sam/lib/mo/sched.models"
161
+ elsif File.exists?("/opt/langtools/lib/sched.models")
162
+ "/opt/langtools/lib/sched.models"
163
+ end
164
+
165
+ if path
166
+ File.readlines(path)
167
+ end
168
+ end
169
+ private_class_method :read_sched_models
170
+
171
+ ##
172
+ # read_unistd_h is intended to be stubbed instead of File.readlines
173
+ # @return [Array] of Strings or nil if the file does not exist.
174
+ def self.read_unistd_h(path)
175
+ if File.exists?(path) then
176
+ File.readlines(path)
177
+ end
178
+ end
179
+ private_class_method :read_unistd_h
180
+
181
+ ##
182
+ # machinfo delegates directly to Facter::Util::Resolution.exec, as with lsdev
183
+ # above.
184
+ def self.machinfo(command="/usr/contrib/bin/machinfo")
185
+ Facter::Util::Resolution.exec(command)
186
+ end
187
+
188
+ ##
189
+ # model delegates directly to Facter::Util::Resolution.exec.
190
+ def self.model(command="model")
191
+ Facter::Util::Resolution.exec(command)
192
+ end
193
+
194
+ ##
195
+ # ioscan delegates directly to Facter::Util::Resolution.exec.
196
+ def self.ioscan(command="ioscan -fknCprocessor")
197
+ Facter::Util::Resolution.exec(command)
198
+ end
199
+
200
+ ##
201
+ # getconf_cpu_version delegates directly to Facter::Util::Resolution.exec.
202
+ def self.getconf_cpu_version(command="getconf CPU_VERSION")
203
+ Facter::Util::Resolution.exec(command)
204
+ end
205
+
206
+ ##
207
+ # getconf_cpu_chip_type delegates directly to Facter::Util::Resolution.exec.
208
+ def self.getconf_cpu_chip_type(command="getconf CPU_CHIP_TYPE")
209
+ Facter::Util::Resolution.exec(command)
210
+ end
211
+
73
212
  def self.enum_cpuinfo
74
213
  processor_num = -1
75
214
  processor_list = []
@@ -1,6 +1,6 @@
1
1
  module Facter
2
2
  if not defined? FACTERVERSION then
3
- FACTERVERSION = '1.6.14'
3
+ FACTERVERSION = '1.6.15-rc1'
4
4
  end
5
5
 
6
6
  def self.version
@@ -0,0 +1,26 @@
1
+ CPU info:
2
+ 4 PA-RISC 8800 processors (1000 MHz, 64 MB)
3
+ CPU version 5
4
+ 8 logical processors (2 per socket)
5
+
6
+ Memory: 24574 MB (24 GB)
7
+
8
+ Firmware info:
9
+ Firmware revision: 45.44
10
+ IPMI is supported on this system.
11
+ BMC firmware revision: 3.52
12
+
13
+ Platform info:
14
+ Model: "9000/800/rp4440 "
15
+ Machine ID number: XXXXXXXXXXXXXXXXXXX
16
+ Machine serial number: SGHXXXXXXX
17
+
18
+ OS info:
19
+ Nodename: myhost
20
+ Release: HP-UX B.11.31
21
+ Version: U (unlimited-user license)
22
+ Machine: 9000/800
23
+ ID Number: 97704309
24
+ vmunix _release_version:
25
+ _release_version:
26
+ @(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf
@@ -0,0 +1,49 @@
1
+ CPU info:
2
+ Number of CPUs = 2
3
+ Number of enabled CPUs = 2
4
+ Clock speed = 1600 MHz
5
+ Bus speed = 400 MT/s
6
+ CPUID registers
7
+ vendor information = "GenuineIntel"
8
+ processor serial number = 0x0000000000000000
9
+ processor version info = 0x000000001f020104
10
+ architecture revision: 0
11
+ processor family: 31 Intel(R) Itanium 2 Family Processors
12
+ processor model: 2 Intel(R) Itanium 2 processor
13
+ Bus features
14
+ implemented = 0xbdf0000060000000
15
+ selected = 0x0000000040000000
16
+ Bus Lock Signal masked
17
+ processor revision: 1 Stepping A1
18
+ largest CPUID reg: 4
19
+ processor capabilities = 0x0000000000000001
20
+ implements long branch: 1
21
+
22
+ Cache info:
23
+ L1 Instruction: size = 16 KB, associativity = 4
24
+ L1 Data: size = 16 KB, associativity = 4
25
+ L2 Unified: size = 256 KB, associativity = 8
26
+ L3 Unified: size = 6144 KB, associativity = 12
27
+
28
+ Memory = 20468 MB (19.988281 GB)
29
+
30
+ Firmware info:
31
+ Firmware revision = 03.17
32
+ FP SWA driver revision: 1.18
33
+ IPMI is supported on this system.
34
+ BMC version: 3.48
35
+
36
+ Platform info:
37
+ model string = "ia64 hp server rx2620"
38
+ machine id number = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
39
+ machine serial number = XXXXXXXXXX
40
+
41
+ OS info:
42
+ sysname = HP-UX
43
+ nodename = myhost
44
+ release = B.11.23
45
+ version = U (unlimited-user license)
46
+ machine = ia64
47
+ idnumber = XXXXXXXXXX
48
+ vmunix _release_version:
49
+ @(#) $Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $
@@ -0,0 +1,26 @@
1
+ CPU info:
2
+ 4 Intel(R) Itanium 2 9100 series processors (1.59 GHz, 18 MB)
3
+ 532 MT/s bus, CPU version A1
4
+ 8 logical processors (2 per socket)
5
+
6
+ Memory: 24542 MB (23.97 GB)
7
+
8
+ Firmware info:
9
+ Firmware revision: 04.11
10
+ FP SWA driver revision: 1.18
11
+ IPMI is supported on this system.
12
+ BMC firmware revision: 5.24
13
+
14
+ Platform info:
15
+ Model: "ia64 hp server rx6600"
16
+ Machine ID number: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
17
+ Machine serial number: XXXXXXXXXX
18
+
19
+ OS info:
20
+ Nodename: bt1353b6
21
+ Release: HP-UX B.11.31
22
+ Version: U (unlimited-user license)
23
+ Machine: ia64
24
+ ID Number: XXXXXXXXXX
25
+ vmunix _release_version:
26
+ @(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf