Codebase list facter / 57acfea
Merge commit 'upstream/1.6.0' Stig Sandbeck Mathisen 12 years ago
82 changed file(s) with 955 addition(s) and 619 deletion(s). Raw diff Collapse all Expand all
0 1.6.0
1 ===
2 9404a7a (#7670) Add an acceptance test
3 0c23845 maint: Fix spelling of acceptance directory
4 926e912 (#7670) Stop preloading all facts in the application
5 2255abe (#7670) Never fail to find a fact that is present
6 8002c24 (#7507) Fix 1.9.2 test failure
7 0635822 Removed inappropriately uncredited Ohai method from ec2 fact
8 6b1cd16 (#6614) Update ipaddress6 fact to work with Ruby 1.9
9 21fe217 (#6612) Changed uptime spec to be endian agnostic
10 19f96b5 (#6728) Facter improperly detects openvzve on CloudLinux systems
11 5b10173 (#5135) Fix faulty logic in physicalprocessorcount
12 53cd946 Ensures that ARP facts are returned only on EC2 hosts
13 bfa038d Fixed #6974 - Moved to Apache 2.0 license
14 d56bca8 refactor the mechanism for allowing for resolution ordering to be influenced
15 9f4c5c6 (#6740) facter doesn't always respect facts in environment variables
16 7441b32 Partial fix for #6971 - Fix for virtual tests
17 7f3e89d (#2714) Fixed faulty test
18 bfc16f6 (#2714) Added timeout to prtdiag resulution
19 c2ff833 (#5135) Refactored physicalprocessorcount
20 0c4a98b Re-factor. Do not use pure-Ruby file reading against "/proc/cpuinfo" and possibly any entry under "/sys" from the sysfs file system.
21 cb52b06 Fix. Using sysfs file system entries to count the number of physical CPUs. Fall-back to "/proc/cpuinfo" included for backward-compatibility with legacy systems.
22 3efa9d7 (#3856) Add virtualbox detection via lspci (graphics card), dmidecode, and prtdiag for Solaris and corresponding tests. Darwin case is not handled yet.
23 7c80172 (#6883) Update Facter install.rb to be slightly more informative.
24 d31e3f9 (#5394) Document each Facter fact.
25 af4947c (#6862) Add a default subject for the mail_patches rake task
26 d6967a0 (#6613) Switch solaris macaddress fact to netstat
27 e056218 (#6817) Fix for Ruby 1.9 by calling .each_line on a string
28 861c2b2 maint: cleanup whitespace
29 f6c9927 (#6719) Corrected faulty logic in bugfix
30 e42e57c (#3856) Add virtualbox detection via lspci (graphics card), dmidecode, and prtdiag for Solaris and corresponding tests. Darwin case is not handled yet.
31 0b5b546 (#6883) Update Facter install.rb to be slightly more informative.
32 7c08270 (#5394) Document each Facter fact.
33 06eb3f5 (#6883) Update Facter install.rb to be slightly more informative.
34 1063753 (#6862) Add a default subject for the mail_patches rake task
35 56b5f10 (#6613) Switch solaris macaddress fact to netstat
36 fd4f31c (#6817) Fix for Ruby 1.9 by calling .each_line on a string
37 72996ff maint: cleanup whitespace
38
039 1.5.9
140 =====
241 4de8b20 Updated CHANGELOG for 1.5.9rc6
+0
-339
COPYING less more
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
2
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Lesser General Public License instead.) You can apply it to
18 your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
26
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
31
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
37
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
41
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
48
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
54
55 The precise terms and conditions for copying, distribution and
56 modification follow.
57
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
70
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
77
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
85
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
88
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
93
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
96
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
101
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
112
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
122
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
127
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
132
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
136
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
140
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
147
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
153
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
164
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
170
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
178
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
187
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
195
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
208
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
213
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
224
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
227
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
235
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281 How to Apply These Terms to Your New Programs
282
283 If you develop a new program, and you want it to be of the greatest
284 possible use to the public, the best way to achieve this is to make it
285 free software which everyone can redistribute and change under these terms.
286
287 To do so, attach the following notices to the program. It is safest
288 to attach them to the start of each source file to most effectively
289 convey the exclusion of warranty; and each file should have at least
290 the "copyright" line and a pointer to where the full notice is found.
291
292 <one line to give the program's name and a brief idea of what it does.>
293 Copyright (C) <year> <name of author>
294
295 This program is free software; you can redistribute it and/or modify
296 it under the terms of the GNU General Public License as published by
297 the Free Software Foundation; either version 2 of the License, or
298 (at your option) any later version.
299
300 This program is distributed in the hope that it will be useful,
301 but WITHOUT ANY WARRANTY; without even the implied warranty of
302 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303 GNU General Public License for more details.
304
305 You should have received a copy of the GNU General Public License along
306 with this program; if not, write to the Free Software Foundation, Inc.,
307 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
308
309 Also add information on how to contact you by electronic and paper mail.
310
311 If the program is interactive, make it output a short notice like this
312 when it starts in an interactive mode:
313
314 Gnomovision version 69, Copyright (C) year name of author
315 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316 This is free software, and you are welcome to redistribute it
317 under certain conditions; type `show c' for details.
318
319 The hypothetical commands `show w' and `show c' should show the appropriate
320 parts of the General Public License. Of course, the commands you use may
321 be called something other than `show w' and `show c'; they could even be
322 mouse-clicks or menu items--whatever suits your program.
323
324 You should also get your employer (if you work as a programmer) or your
325 school, if any, to sign a "copyright disclaimer" for the program, if
326 necessary. Here is a sample; alter the names:
327
328 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329 `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
331 <signature of Ty Coon>, 1 April 1989
332 Ty Coon, President of Vice
333
334 This General Public License does not permit incorporating your program into
335 proprietary programs. If your program is a subroutine library, you may
336 consider it more useful to permit linking proprietary applications with the
337 library. If this is what you want to do, use the GNU Lesser General
338 Public License instead of this License.
0 Facter - Host Fact Detection and Reporting. Copyright (C) 2005 Reductive Labs LLC
0 Facter - Host Fact Detection and Reporting
11
2 Reductive Labs can be contacted at: info@reductivelabs.com
2 Copyright 2011 Puppet Labs Inc
33
4 This program and entire repository is free software; you can
5 redistribute it and/or modify it under the terms of the GNU
6 General Public License as published by the Free Software
7 Foundation; either version 2 of the License, or any later version.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
87
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
8 http://www.apache.org/licenses/LICENSE-2.0
139
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
+0
-8
README less more
0 This package is largely meant to be a library for collecting facts about your
1 system. These facts are mostly strings (i.e., not numbers), and are things
2 like the output of 'uname', public ssh and cfengine keys, the number of
3 processors, etc.
4
5 See bin/facter for an example of the interface.
6
7 See http://www.puppetlabs.com/puppet/related-projects/facter for more details.
0 Facter
1 ======
2
3 This package is largely meant to be a library for collecting facts about your
4 system. These facts are mostly strings (i.e., not numbers), and are things
5 like the output of `uname`, public ssh and cfengine keys, the number of
6 processors, etc.
7
8 See `bin/facter` for an example of the interface.
9
10 Running Facter
11 --------------
12
13 Run the `facter` binary on the command for a full list of facts supported on your host.
14
15 Adding your own facts
16 ---------------------
17
18 See the [Adding Facts](http://docs.puppetlabs.com/guides/custom_facts.html) page for details of how to add your own custom facts to Facter.
19
20 Further Information
21 -------------------
22
23 See http://www.puppetlabs.com/puppet/related-projects/facter for more details.
+0
-26
README.rst less more
0 Facter
1 ======
2
3 This package is largely meant to be a library for collecting facts about your
4 system. These facts are mostly strings (i.e., not numbers), and are things
5 like the output of ``uname``, public ssh and cfengine keys, the number of
6 processors, etc.
7
8 See ``bin/facter`` for an example of the interface.
9
10 Running Facter
11 ++++++++++++++
12
13 Run the ``facter`` binary on the command for a full list of facts supported on your host.
14
15 Adding your own facts
16 +++++++++++++++++++++
17
18 See the `Adding Facts`_ page for details of how to add your own custom facts to Facter.
19
20 Further Information
21 +++++++++++++++++++
22
23 See http://www.puppetlabs.com/puppet/related-projects/facter for more details.
24
25 .. _Adding Facts: http://docs.puppetlabs.com/guides/custom_facts.html
+0
-4
TODO less more
0 More documentation.
1
2 The ability to specify fact names with strings or symbols; right now, only
3 strings are supported
+0
-31
accecptance/tests/ticket_7039_facter_multiple_facts_one_file.rb less more
0 test_name "#7039: Facter having issue handling multiple facts in a single file"
1
2 fact_file= %q{
3 Facter.add(:test_fact1) do
4 setcode do
5 "test fact 1"
6 end
7 end
8
9 Facter.add(:test_fact2) do
10 setcode do
11 "test fact 2"
12 end
13 end
14 }
15
16 agent1=agents.first
17 step "Agent: Create fact file with multiple facts"
18 create_remote_file(agent1, '/tmp/test_facts.rb', fact_file )
19
20 step "Agent: Verify test_fact1 from /tmp/test_facts.rb"
21 on(agent1, "export FACTERLIB=/tmp && facter --puppet test_fact1") do
22 fail_test "Fact 1 not returned by facter --puppet test_fact1" unless
23 stdout.include? 'test fact 1'
24 end
25
26 step "Agent: Verify test_fact2 from /tmp/test_facts.rb"
27 on(agent1, "export FACTERLIB=/tmp && facter --puppet test_fact2") do
28 fail_test "Fact 1 not returned by facter --puppet test_fact2" unless
29 stdout.include? 'test fact 2'
30 end
0 test_name "#7670: Facter should properly detect operatingsystem on Ubuntu after a clear"
1
2 script_contents = <<-OS_DETECT
3 require 'facter'
4 Facter['operatingsystem'].value
5 Facter.clear
6 exit Facter['operatingsystem'].value == 'Ubuntu'
7 OS_DETECT
8
9 script_name = "/tmp/facter_os_detection_test_#{$$}"
10
11 agents.each do |agent|
12 next unless agent['platform'].include? 'ubuntu'
13
14 create_remote_file(agent, script_name, script_contents)
15
16 on(agent, "ruby #{script_name}")
17 end
0 test_name "#7039: Facter having issue handling multiple facts in a single file"
1
2 fact_file= %q{
3 Facter.add(:test_fact1) do
4 setcode do
5 "test fact 1"
6 end
7 end
8
9 Facter.add(:test_fact2) do
10 setcode do
11 "test fact 2"
12 end
13 end
14 }
15
16 agent1=agents.first
17 step "Agent: Create fact file with multiple facts"
18 create_remote_file(agent1, '/tmp/test_facts.rb', fact_file )
19
20 step "Agent: Verify test_fact1 from /tmp/test_facts.rb"
21 on(agent1, "export FACTERLIB=/tmp && facter --puppet test_fact1") do
22 fail_test "Fact 1 not returned by facter --puppet test_fact1" unless
23 stdout.include? 'test fact 1'
24 end
25
26 step "Agent: Verify test_fact2 from /tmp/test_facts.rb"
27 on(agent1, "export FACTERLIB=/tmp && facter --puppet test_fact2") do
28 fail_test "Fact 1 not returned by facter --puppet test_fact2" unless
29 stdout.include? 'test fact 2'
30 end
5151 #
5252 # = Copyright
5353 #
54 # Copyright (c) 2006 Reductive Labs, LLC
55 # Licensed under the GNU Public License
54 # Copyright (c) 2011 Puppet Labs, Inc
55 # Licensed under the Apache 2.0 license
5656
5757 require 'facter/application'
5858
44
55 Summary: Ruby module for collecting simple facts about a host operating system
66 Name: facter
7 Version: 1.5.8
7 Version: 1.6.0
88 Release: 1%{?dist}
9 License: GPLv2+
9 License: Apache 2.0
1010 Group: System Environment/Base
1111 URL: http://www.puppetlabs.com/puppet/related-projects/%{name}/
1212 Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz
5151
5252
5353 %changelog
54 * Thu Jun 23 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.0-1
55 - Update to 1.6.0
56
5457 * Sat Aug 28 2010 Todd Zullinger <tmz@pobox.com> - 1.5.8-1
5558 - Update to 1.5.8
5659
00 PKG=CSWfacter
11 NAME=facter - System Fact Gatherer
2 VERSION=1.3.5
2 VERSION=1.6.0
33 CATEGORY=application
44 VENDOR=http://www.puppetlabs.com/puppet/related-projects/facter
55 HOTLINE=http://puppetlabs.com/cgi-bin/facter.cgi
118118 begin
119119 require pre
120120 rescue LoadError
121 puts "Could not load %s; cannot install" % pre
121 puts "Could not load #{pre} Ruby library; cannot install"
122122 exit -1
123123 end
124124 }
0 # Fact: Cfkey
1 #
2 # Purpose: Return the public key(s) for CFengine.
3 #
4 # Resolution:
5 # Tries each file of standard localhost.pub & cfkey.pub locations,
6 # checks if they appear to be a public key, and then join them all together.
7 #
8 # Caveats:
9 #
10
011 ## Cfkey.rb
112 ## Facts related to cfengine
2 ##
3 ## This program is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU General Public License
5 ## as published by the Free Software Foundation (version 2 of the License)
6 ## This program is distributed in the hope that it will be useful,
7 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
8 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 ## GNU General Public License for more details.
10 ## You should have received a copy of the GNU General Public License
11 ## along with this program; if not, write to the Free Software
12 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
1313 ##
1414
1515 Facter.add(:Cfkey) do
99 names = argv
1010
1111 # Create the facts hash that is printed to standard out.
12 # Pre-load all of the facts, since we can have multiple facts
13 # per file, and since we can't know ahead of time which file a
14 # fact will be in, we'll need to load every file.
15 facts = Facter.to_hash
1612 unless names.empty?
1713 facts = {}
1814 names.each do |name|
2420 end
2521 end
2622 end
23
24 # Print everything if they didn't ask for specific facts.
25 facts ||= Facter.to_hash
2726
2827 # Print the facts as YAML and exit
2928 if options[:yaml]
0 # Fact: architecture
1 #
2 # Purpose:
3 # Return the CPU hardware architecture.
4 #
5 # Resolution:
6 # On OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact.
7 # Gentoo and Debian call "x86_86" "amd64".
8 # Gentoo also calls "i386" "x86".
9 #
10 # Caveats:
11 #
12
013 Facter.add(:architecture) do
114 confine :kernel => [:linux, :"gnu/kfreebsd"]
215 setcode do
0 # Fact: domain
1 #
2 # Purpose:
3 # Return the host's primary DNS domain name.
4 #
5 # Resolution:
6 # On UNIX (excluding Darwin), first try and use the hostname fact,
7 # which uses the hostname system command, and then parse the output
8 # of that.
9 # Failing that it tries the dnsdomainname system command.
10 # Failing that it uses /etc/resolv.conf and takes the domain from that, or as
11 # a final resort, the search from that.
12 # Otherwise returns nil.
13 #
14 # On Windows uses the win32ole gem and winmgmts to get the DNSDomain value
15 # from the Win32 networking stack.
16 #
17 # Caveats:
18 #
19
020 Facter.add(:domain) do
121 setcode do
222 # Get the domain from various sources; the order of these
0 # Fact: facterversion
1 #
2 # Purpose: returns the version of the facter module.
3 #
4 # Resolution: Uses the version constant.
5 #
6 # Caveats:
7 #
8
09 Facter.add(:facterversion) do
110 setcode { Facter::FACTERVERSION.to_s }
211 end
0 # Fact: fqdn
1 #
2 # Purpose: Returns the fully qualified domain name of the host.
3 #
4 # Resolution: Simply joins the hostname fact with the domain name fact.
5 #
6 # Caveats: No attempt is made to check that the two facts are accurate or that
7 # the two facts go together. At no point is there any DNS resolution made
8 # either.
9 #
10
011 Facter.add(:fqdn) do
112 setcode do
213 host = Facter.value(:hostname)
0 # Fact: hardwareisa
1 #
2 # Purpose:
3 # Returns hardware processor type.
4 #
5 # Resolution:
6 # On Solaris, Linux and the BSDs simply uses the output of "uname -p"
7 #
8 # Caveats:
9 # Some linuxes return unknown to uname -p with relative ease.
10 #
11
012 Facter.add(:hardwareisa) do
113 setcode 'uname -p', '/bin/sh'
214 confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD OEL OVS GNU/kFreeBSD}
0 # Fact: hardwaremodel
1 #
2 # Purpose:
3 # Returns the hardware model of the system.
4 #
5 # Resolution:
6 # Uses purely "uname -m" on all platforms other than AIX and Windows.
7 # On AIX uses the parsed "modelname" output of "lsattr -El sys0 -a modelname".
8 # On Windows uses the 'host_cpu' pulled out of Ruby's config.
9 #
10 # Caveats:
11 #
12
013 Facter.add(:hardwaremodel) do
114 setcode 'uname -m'
215 end
0 # Fact: hostname
1 #
2 # Purpose: Return the system's short hostname.
3 #
4 # Resolution:
5 # On all system bar Darwin, parses the output of the "hostname" system command
6 # to everything before the first period.
7 # On Darwin, uses the system configuration util to get the LocalHostName
8 # variable.
9 #
10 # Caveats:
11 #
12
013 Facter.add(:hostname, :ldapname => "cn") do
114 setcode do
215 hostname = nil
0 # Fact: id
1 #
2 # Purpose: Internal fact used to specity the program to return the currently
3 # running user id.
4 #
5 # Resolution:
6 # On all Unixes bar Solaris, just returns "whoami".
7 # On Solaris, parses the output of the "id" command to grab the username, as
8 # Solaris doesn't have the whoami command.
9 #
10 # Caveats:
11 #
12
013 Facter.add(:id) do
114 setcode "whoami"
215 end
0 # Fact: interfaces
1 #
2 # Purpose:
3 #
4 # Resolution:
5 #
6 # Caveats:
7 #
8
09 # interfaces.rb
110 # Try to get additional Facts about the machine's network interfaces
211 #
0 # Fact: ipaddress
1 #
2 # Purpose: Return the main IP address for a host.
3 #
4 # Resolution:
5 # On the Unixes does an ifconfig, and returns the first non 127.0.0.0/8
6 # subnetted IP it finds.
7 # On Windows, it attempts to use the socket library and resolve the machine's
8 # hostname via DNS.
9 #
10 # On LDAP based hosts it tries to use either the win32/resolv library to
11 # resolve the hostname to an IP address, or on Unix, it uses the resolv
12 # library.
13 #
14 # As a fall back for undefined systems, it tries to run the "host" command to
15 # resolve the machine's hostname using the system DNS.
16 #
17 # Caveats:
18 # DNS resolution relies on working DNS infrastructure and resolvers on the
19 # host system.
20 # The ifconfig parsing purely takes the first IP address it finds without any
21 # checking this is a useful IP address.
22 #
23
024 Facter.add(:ipaddress) do
125 confine :kernel => :linux
226 setcode do
0 # Fact: ipaddress6
1 #
2 # Purpose: Returns the "main" IPv6 IP address of a system.
3 #
4 # Resolution:
5 # OS dependant code that parses the output of various networking
6 # tools and currently not very intelligent. Returns the first
7 # non-loopback and non-linklocal address found in the ouput unless
8 # a default route can be mapped to a routeable interface. Guessing
9 # an interface is currently only possible with BSD type systems
10 # to many assumptions have to be made on other platforms to make
11 # this work with the current code. Most code ported or modeled
12 # after the ipaddress fact for the sake of similar functionality
13 # and familiar mechanics.
14 #
15 # Caveats:
16 #
17
018 # Cody Herriges <c.a.herriges@gmail.com>
119 #
220 # Used the ipaddress fact that is already part of
321 # Facter as a template.
422
5 # OS dependant code that parses the output of various networking
6 # tools and currently not very intelligent. Returns the first
7 # non-loopback and non-linklocal address found in the ouput unless
8 # a default route can be mapped to a routeable interface. Guessing
9 # an interface is currently only possible with BSD type systems
10 # to many assumptions have to be made on other platforms to make
11 # this work with the current code. Most code ported or modeled
12 # after the ipaddress fact for the sake of similar functionality
13 # and familiar mechanics.
23 def get_address_after_token(output, token, return_first=false)
24 ip = nil
25
26 output.scan(/#{token} ((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match|
27 match = match.first
28 unless match =~ /fe80.*/ or match == "::1"
29 ip = match
30 break if return_first
31 end
32 end
33
34 ip
35 end
36
1437 Facter.add(:ipaddress6) do
1538 confine :kernel => :linux
1639 setcode do
17 ip = nil
1840 output = Facter::Util::Resolution.exec('/sbin/ifconfig')
1941
20 output.scan(/inet6 addr: ((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each { |str|
21 str = str.to_s
22 unless str =~ /fe80.*/ or str == "::1"
23 ip = str
24 end
25 }
26
27 ip
28
42 get_address_after_token(output, 'inet6 addr:')
2943 end
3044 end
3145
3347 confine :kernel => %w{SunOS}
3448 setcode do
3549 output = Facter::Util::Resolution.exec('/usr/sbin/ifconfig -a')
36 ip = nil
3750
38 output.scan(/inet6 ((?>[0-9,a-f,A-F]*\:{0,2})+[0-9,a-f,A-F]{0,4})/).each { |str|
39 str = str.to_s
40 unless str =~ /fe80.*/ or str == "::1"
41 ip = str
42 end
43 }
44
45 ip
46
51 get_address_after_token(output, 'inet6')
4752 end
4853 end
4954
5156 confine :kernel => %w{Darwin FreeBSD OpenBSD}
5257 setcode do
5358 output = Facter::Util::Resolution.exec('/sbin/ifconfig -a')
54 ip = nil
5559
56 output.scan(/inet6 ((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |str|
57 str = str.to_s
58 unless str =~ /fe80.*/ or str == "::1"
59 ip = str
60 break
61 end
62 end
63
64 ip
60 get_address_after_token(output, 'inet6', true)
6561 end
6662 end
67
0 # Fact: iphostnumber
1 #
2 # Purpose: On selected versions of Darwin, returns the host's IP address.
3 #
4 # Resolution:
5 # Uses either the scutil program to get the localhost name, or parses output
6 # of ifconfig for a MAC address.
7 #
8 # Caveats:
9 #
10
011 Facter.add(:iphostnumber) do
112 confine :kernel => :darwin, :kernelrelease => "R6"
213 setcode do
0 # Fact: kernel
1 #
2 # Purpose: Returns the operating system's name.
3 #
4 # Resolution:
5 # Uses Ruby's rbconfig to find host_os, if that is a Windows derivative, the
6 # returns 'windows', otherwise returns "uname -s" verbatim.
7 #
8 # Caveats:
9 #
10
011 Facter.add(:kernel) do
112 setcode do
213 require 'rbconfig'
0 # Fact: kernelmajversion
1 #
2 # Purpose: Return the operating system's release number's major value.
3 #
4 # Resolution:
5 # Takes the first 2 elements of the kernel version as delimited by periods.
6 #
7 # Caveats:
8 #
9
010 Facter.add("kernelmajversion") do
111 setcode do
212 Facter.value(:kernelversion).split('.')[0..1].join('.')
0 # Fact: kernelrelease
1 #
2 # Purpose: Return the operating system's release number.
3 #
4 # Resolution:
5 # On AIX returns the output from the "oslevel -s" system command.
6 # On Windows based systems, uses the win32ole gem to query Windows Management
7 # for the 'Win32_OperatingSystem' value.
8 # Otherwise uses the output of "uname -r" system command.
9 #
10 # Caveats:
11 #
12
013 Facter.add(:kernelrelease) do
114 setcode 'uname -r'
215 end
0 # Fact: kernelversion
1 #
2 # Purpose: Return the operating system's kernel version.
3 #
4 # Resolution:
5 # On Solaris and SunOS based machines, returns the output of "uname -v".
6 # Otherwise returns the 'kernerlversion' fact up to the first '-'. This may be
7 # the entire 'kernelversion' fact in many cases.
8 #
9 # Caveats:
10 #
11
012 Facter.add("kernelversion") do
113 setcode do
214 Facter['kernelrelease'].value.split('-')[0]
0 # Fact: lsb
1 #
2 # Purpose: Return Linux Standard Base information for the host.
3 #
4 # Resolution:
5 # Uses the lsb_release system command and parses the output with a series of
6 # regular expressions.
7 #
8 # Caveats:
9 # Only works on Linux (and the kfreebsd derivative) systems.
10 # Requires the lsb_release program, which may not be installed by default.
11 # Also is as only as accurate as that program outputs.
12
013 ## lsb.rb
114 ## Facts related to Linux Standard Base (LSB)
2 ##
3 ## This program is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU General Public License
5 ## as published by the Free Software Foundation (version 2 of the License)
6 ## This program is distributed in the hope that it will be useful,
7 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
8 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 ## GNU General Public License for more details.
10 ## You should have received a copy of the GNU General Public License
11 ## along with this program; if not, write to the Free Software
12 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
13 ##
1415
1516 { "LSBRelease" => %r{^LSB Version:\t(.*)$},
1617 "LSBDistId" => %r{^Distributor ID:\t(.*)$},
0 # Fact: lsbmajdistrelease
1 #
2 # Purpose: Returns the major version of the operation system version as gleaned
3 # from the lsbdistrelease fact.
4 #
5 # Resolution:
6 # Parses the lsbdistrelease fact for numbers followed by a period and
7 # returns those, or just the lsbdistrelease fact if none were found.
8 #
9 # Caveats:
10 #
11
012 # lsbmajdistrelease.rb
113 #
214 require 'facter'
0 # Fact: macaddress
1 #
2 # Purpose:
3 #
4 # Resolution:
5 #
6 # Caveats:
7 #
8
09 require 'facter/util/macaddress'
110
211 Facter.add(:macaddress) do
615 output = %x{/sbin/ifconfig -a}
716 output.each_line do |s|
817 ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
18 end
19 ether[0]
20 end
21 end
22
23 Facter.add(:macaddress) do
24 confine :operatingsystem => "Solaris"
25 setcode do
26 ether = []
27 output = Facter::Util::Resolution.exec("/usr/bin/netstat -np")
28 output.each_line do |s|
29 ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/
930 end
1031 ether[0]
1132 end
0 # Fact: macosx
1 #
2 # Purpose:
3 # Returns a number of Mac specific facts, from system profiler and
4 # sw_vers.
5 #
6 # Resolution:
7 # Uses util/macosx.rb to do the fact reconnaissance, then outputs them
8 # preceded by 'sp_'
9 #
10 # Caveats:
11 #
12
013 #
114 # macosx.rb
215 # Additional Facts coming from Mac OS X system_profiler command
417 # Copyright (C) 2007 Jeff McCune
518 # Author: Jeff McCune <jeff.mccune@northstarlabs.net>
619 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation (version 2 of the License)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
17
1820 # Jeff McCune
1921 # There's a lot more information coming out of system_profiler -xml
2022 # We could add quite a bit more, but I didn't want to overload facter
0 # Fact: manufacturer
1 #
2 # Purpose: Return the hardware manufacturer information about the hardware.
3 #
4 # Resolution:
5 # On OpenBSD, queries sysctl values, via a util class.
6 # On SunOS Sparc, uses prtdiag via a util class.
7 # On Windows, queries the system via a util class.
8 # Uses the 'util/manufacturer.rb' for fallback parsing.
9 #
10 # Caveats:
11 #
12
013 # manufacturer.rb
114 # Facts related to hardware manufacturer
215 #
0 # Fact: memory
1 #
2 # Purpose: Return information about memory and swap usage.
3 #
4 # Resolution:
5 # On Linuxes, uses Facter::Memory.meminfo_number from
6 # 'facter/util/memory.rb'
7 # On AIX, parses "swap -l" for swap values only.
8 # On OpenBSD, it parses "swapctl -l" for swap values, vmstat via a module for
9 # free memory, and "sysctl hw.physmem" for maximum memory.
10 # On Solaris, use "swap -l" for swap values, and parsing prtconf for maximum
11 # memory, and again, the vmstat module for free memory.
12 #
13 # Caveats:
14 # Some BSD platforms aren't covered at all. AIX is missing memory values.
15 #
16
017 # memory.rb
118 # Additional Facts for memory/swap usage
219 #
2239 Facter.add("SwapSize") do
2340 confine :kernel => :Darwin
2441 setcode do
25 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
26 swaptotal = 0
27 if swap =~ /total = (\S+)/ then swaptotal = $1; end
28 swaptotal
42 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
43 swaptotal = 0
44 if swap =~ /total = (\S+)/ then swaptotal = $1; end
45 swaptotal
2946 end
3047 end
3148
3249 Facter.add("SwapFree") do
3350 confine :kernel => :Darwin
3451 setcode do
35 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
36 swapfree = 0
37 if swap =~ /free = (\S+)/ then swapfree = $1; end
38 swapfree
52 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
53 swapfree = 0
54 if swap =~ /free = (\S+)/ then swapfree = $1; end
55 swapfree
3956 end
4057 end
4158
4259 Facter.add("SwapEncrypted") do
4360 confine :kernel => :Darwin
4461 setcode do
45 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
46 encrypted = false
47 if swap =~ /\(encrypted\)/ then encrypted = true; end
48 encrypted
62 swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
63 encrypted = false
64 if swap =~ /\(encrypted\)/ then encrypted = true; end
65 encrypted
4966 end
5067 end
5168
5673 if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/
5774 swaptotal += $1.to_i
5875 swapfree += $2.to_i
59 end
60 end
61
76 end
77 end
78
6279 Facter.add("SwapSize") do
6380 confine :kernel => :aix
6481 setcode do
153170 if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/
154171 swaptotal += $1.to_i / 2
155172 swapfree += $2.to_i / 2
156 end
157 end
158
173 end
174 end
175
159176 Facter.add("SwapSize") do
160177 confine :kernel => :sunos
161178 setcode do
0 # Fact: netmask
1 #
2 # Purpose: Returns the netmask for the main interfaces.
3 #
4 # Resolution: Uses the facter/util/netmask library routines.
5 #
6 # Caveats:
7 #
8
09 # netmask.rb
110 # Find the netmask of the primary ipaddress
211 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
0 # Fact: network
1 #
2 # Purpose:
3 # Get IP, network and netmask information for available network
4 # interfacs.
5 #
6 # Resolution:
7 # Uses 'facter/util/ip' to enumerate interfaces and return their information.
8 #
9 # Caveats:
10 #
11
012 require 'facter/util/ip'
113
214 Facter::Util::IP.get_interfaces.each do |interface|
0 # Fact: operatingsystem
1 #
2 # Purpose: Return the name of the operating system.
3 #
4 # Resolution:
5 # If the kernel is a Linux kernel, check for the existence of a selection of
6 # files in /etc/ to find the specific flavour.
7 # On SunOS based kernels, return Solaris.
8 # On systems other than Linux, use the kernel value.
9 #
10 # Caveats:
11 #
12
013 require 'facter/lsb'
114
215 Facter.add(:operatingsystem) do
0 # Fact: operatingsystemrelease
1 #
2 # Purpose: Returns the release of the operating system.
3 #
4 # Resolution:
5 # On RedHat derivatives, returns their '/etc/<variant>-release' file.
6 # On Debian, returns '/etc/debian_version'.
7 # On Ubuntu, parses '/etc/issue' for the release version.
8 # On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version
9 # information.
10 # On Slackware, parses '/etc/slackware-version'.
11 #
12 # On all remaining systems, returns the 'kernelrelease' value.
13 #
14 # Caveats:
15 #
16
017 Facter.add(:operatingsystemrelease) do
118 confine :operatingsystem => %w{CentOS Fedora oel ovs RedHat MeeGo}
219 setcode do
0 # Fact: path
1 #
2 # Purpose: Returns the $PATH variable.
3 #
4 # Resolution: Gets $PATH from the environment.
5 #
6 # Caveats:
7 #
8
09 Facter.add(:path) do
110 setcode do
211 ENV['PATH']
0 Facter.add("physicalprocessorcount") do
1 confine :kernel => :linux
0 # Fact: physicalprocessorcount
1 #
2 # Purpose: Return the number of physical processors.
3 #
4 # Resolution:
5 #
6 # Attempts to use sysfs to get the physical IDs of the processors. Falls
7 # back to /proc/cpuinfo and "physical id" if sysfs is not available.
8 #
9 # Caveats:
10 #
11 Facter.add('physicalprocessorcount') do
12 confine :kernel => :linux
213
3 setcode do
4 ppcount = Facter::Util::Resolution.exec('grep "physical id" /proc/cpuinfo|cut -d: -f 2|sort -u|wc -l')
14 setcode do
15 sysfs_cpu_directory = '/sys/devices/system/cpu' # This should always be there ...
16
17 if File.exists?(sysfs_cpu_directory)
18 #
19 # We assume that the sysfs file system has the correct number of entries
20 # under the "/sys/device/system/cpu" directory and if so then we process
21 # content of the file "physical_package_id" located inside the "topology"
22 # directory in each of the per-CPU sub-directories.
23 #
24 # As per Linux Kernel documentation and the file "cputopology.txt" located
25 # inside the "/usr/src/linux/Documentation" directory we can find following
26 # short explanation:
27 #
28 # (...)
29 #
30 # 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
31 #
32 # physical package id of cpuX. Typically corresponds to a physical
33 # socket number, but the actual value is architecture and platform
34 # dependent.
35 #
36 # (...)
37 #
38 lookup_pattern = "#{sysfs_cpu_directory}" +
39 "/cpu*/topology/physical_package_id"
40
41 Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size
42
43 else
44 #
45 # Try to count number of CPUs using the proc file system next ...
46 #
47 # We assume that /proc/cpuinfo has what we need and is so then we need
48 # to make sure that we only count unique entries ...
49 #
50 str = Facter::Util::Resolution.exec("grep 'physical.\\+:' /proc/cpuinfo")
51
52 if str then str.scan(/\d+/).uniq.size; end
553 end
54 end
655 end
0 # Fact: processor
1 #
2 # Purpose:
3 # Additional Facts about the machine's CPUs.
4 #
5 # Resolution:
6 # On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor.
7 # On AIX, parse the output of 'lsdev' for it's processor section.
8 # On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU
9 # count.
10 #
11 # Caveats:
12 #
13
014 # processor.rb
1 # Additional Facts about the machine's CPUs
215 #
316 # Copyright (C) 2006 Mooter Media Ltd
417 # Author: Matthew Palmer <matt@solutionsfirst.com.au>
0 # Fact: ps
1 #
2 # Purpose: Internal fact for what to use to list all processes. Used by
3 # Service{} type in Puppet.
4 #
5 # Resolution:
6 # Assumes "ps -ef" for all operating systems other than BSD derivatives, where
7 # it uses "ps auxwww"
8 #
9 # Caveats:
10 #
11
012 Facter.add(:ps) do
113 setcode do 'ps -ef' end
214 end
0 # Fact: puppetversion
1 #
2 # Purpose: Return the version of puppet installed.
3 #
4 # Resolution:
5 # Requres puppet via Ruby and returns it's version constant.
6 #
7 # Caveats:
8 #
9
010 Facter.add(:puppetversion) do
111 setcode do
212 begin
0 # Fact: rubysitedir
1 #
2 # Purpose: Returns Ruby's site library directory.
3 #
4 # Resolution: Works out the version to major/minor (1.8, 1.9, etc), then joins
5 # that with all the $: library paths.
6 #
7 # Caveats:
8 #
9
010 Facter.add :rubysitedir do
111 setcode do
212 version = RUBY_VERSION.to_s.sub(/\.\d+$/, '')
0 # Fact: rubyversion
1 #
2 # Purpose: Returns the version of Ruby facter is running under.
3 #
4 # Resolution: Returns RUBY_VERSION.
5 #
6 # Caveats:
7 #
8
09 Facter.add(:rubyversion) do
110 setcode { RUBY_VERSION.to_s }
211 end
0 # Fact: selinux
1 #
2 # Purpose:
3 #
4 # Resolution:
5 #
6 # Caveats:
7 #
8
09 # Fact for SElinux
110 # Written by immerda admin team (admin(at)immerda.ch)
211
0 # Fact: ssh
1 #
2 # Purpose:
3 #
4 # Resolution:
5 #
6 # Caveats:
7 #
8
09 ## ssh.rb
110 ## Facts related to SSH
2 ##
3 ## This program is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU General Public License
5 ## as published by the Free Software Foundation (version 2 of the License)
6 ## This program is distributed in the hope that it will be useful,
7 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
8 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 ## GNU General Public License for more details.
10 ## You should have received a copy of the GNU General Public License
11 ## along with this program; if not, write to the Free Software
12 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
1311 ##
1412
1513 ["/etc/ssh","/usr/local/etc/ssh","/etc","/usr/local/etc"].each do |dir|
0 # Fact: timezone
1 #
2 # Purpose: Return the machine's time zone.
3 #
4 # Resolution: Uses's Ruby's Time module's Time.new call.
5 #
6 # Caveats:
7 #
8
09 Facter.add("timezone") do
110 setcode do
211 Time.new.zone
0 # Fact: uptime
1 #
2 # Purpose: return the system uptime in a human readable format.
3 #
4 # Resolution:
5 # Does basic maths on the "uptime_seconds" fact to return a count of
6 # days, hours and minutes of uptime
7 #
8 # Caveats:
9 #
10
011 require 'facter/util/uptime'
112
213 Facter.add(:uptime) do
0 # Fact: uptime_days
1 #
2 # Purpose: Return purely number of days of uptime.
3 #
4 # Resolution: Divides uptime_hours fact by 24.
5 #
6 # Caveats:
7 #
8
09 Facter.add(:uptime_days) do
110 setcode do
211 hours = Facter.value(:uptime_hours)
0 # Fact: uptime_hours
1 #
2 # Purpose: Return purely number of hours of uptime.
3 #
4 # Resolution: Divides uptime_seconds fact by 3600.
5 #
6 # Caveats:
7 #
8
09 Facter.add(:uptime_hours) do
110 setcode do
211 seconds = Facter.value(:uptime_seconds)
0 # Fact: uptime_seconds
1 #
2 # Purpose: Return purely number of seconds of uptime.
3 #
4 # Resolution:
5 # Using the 'facter/util/uptime.rb' module, try a verity of methods to acquire
6 # the uptime on Unix.
7 #
8 # On Windows, the module calculates the uptime by the "LastBootupTime" Windows
9 # management value.
10 #
11 # Caveats:
12 #
13
014 require 'facter/util/uptime'
115
216 Facter.add(:uptime_seconds) do
6565 def fact(name)
6666 name = canonize(name)
6767
68 # Try to load the fact if necessary
6869 loader.load(name) unless @facts[name]
6970
70 return @facts[name]
71 # Try HARDER
72 loader.load_all unless @facts[name]
73
74 @facts[name]
7175 end
7276
7377 # Flush all cached values.
4040
4141 # Immediately sort the resolutions, so that we always have
4242 # a sorted list for looking up values.
43 # We always want to look them up in the order of number of
44 # confines, so the most restricted resolution always wins.
45 @resolves.sort! { |a, b| b.length <=> a.length }
43 @resolves.sort! { |a, b| b.weight <=> a.weight }
4644
4745 return resolve
4846 end
8989 next if fact and env_name != fact
9090
9191 Facter.add($1) do
92 has_weight 1_000_000
9293 setcode { value }
9394 end
9495
22 ##
33 ## Copyright (C) 2007 Jeff McCune
44 ## Author: Jeff McCune <jeff.mccune@northstarlabs.net>
5 ##
6 ## This program is free software; you can redistribute it and/or
7 ## modify it under the terms of the GNU General Public License
8 ## as published by the Free Software Foundation (version 2 of the License)
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; if not, write to the Free Software
15 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
165 ##
176
187 module Facter::Util::Macosx
00 ## memory.rb
11 ## Support module for memory related facts
2 ##
3 ## This program is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU General Public License
5 ## as published by the Free Software Foundation (version 2 of the License)
6 ## This program is distributed in the hope that it will be useful,
7 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
8 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 ## GNU General Public License for more details.
10 ## You should have received a copy of the GNU General Public License
11 ## along with this program; if not, write to the Free Software
12 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
132 ##
143
154 module Facter::Memory
7463 memspecfree = 0
7564
7665 vmstats = Facter::Util::Resolution.exec('vm_stat')
77 vmstats.each do |vmline|
66 vmstats.each_line do |vmline|
7867 case
7968 when vmline =~ /page\ssize\sof\s(\d+)\sbytes/
8069 pagesize = $1.to_i
9382 end
9483 end
9584 end
96
8484 end
8585 end
8686
87 def has_weight(weight)
88 @weight = weight
89 end
90
8791 # Create a new resolution mechanism.
8892 def initialize(name)
8993 @name = name
9094 @confines = []
9195 @value = nil
9296 @timeout = 0
97 @weight = nil
9398 end
9499
95 # Return the number of confines.
96 def length
97 @confines.length
100 # Return the importance of this resolution.
101 def weight
102 if @weight
103 @weight
104 else
105 @confines.length
106 end
98107 end
99108
100109 # We need this as a getter for 'timeout', because some versions
00 module Facter::Util::Virtual
11 def self.openvz?
2 FileTest.directory?("/proc/vz")
2 FileTest.directory?("/proc/vz") and FileTest.exists?( '/proc/vz/veinfo' )
33 end
44
55 def self.openvz_type
0 # Fact: virtual
1 #
2 # Purpose: Determine if the system's hardware is real or virtualised.
3 #
4 # Resolution:
5 # Assumes physical unless proven otherwise.
6 #
7 # On Darwin, use the macosx util module to acquire the SPDisplaysDataType,
8 # from that parse it to see if it's VMWare or Parallels pretending to be the
9 # display.
10 #
11 # On Linux, BSD, Solaris and HPUX:
12 # Much of the logic here is obscured behind util/virtual.rb, which rather
13 # than document here, which would encourage drift, just refer to it.
14 # The Xen tests in here rely on /sys and /proc, and check for the presence and
15 # contents of files in there.
16 # If after all the other tests, it's still seen as physical, then it tries to
17 # parse the output of the "lspci", "dmidecode" and "prtdiag" and parses them
18 # for obvious signs of being under VMWare or Parallels.
19 # Finally it checks for the existence of vmware-vmx, which would hint it's
20 # VMWare.
21 #
22 # Caveats:
23 # Virtualbox detection isn't implemented.
24 # Many checks rely purely on existence of files.
25 #
26
027 require 'facter/util/virtual'
128
229 Facter.add("virtual") do
2451
2552 setcode do
2653
27 if Facter::Util::Virtual.zone? and Facter.value(:operatingsystem) == "Solaris"
54 if Facter.value(:operatingsystem) == "Solaris" and Facter::Util::Virtual.zone?
2855 result = "zone"
2956 end
3057
76103 # --- look for the vmware video card to determine if it is virtual => vmware.
77104 # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
78105 result = "vmware" if p =~ /VM[wW]are/
106 # --- look for virtualbox video card to determine if it is virtual => virtualbox.
107 # --- 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
108 result = "virtualbox" if p =~ /VirtualBox/
79109 # --- look for pci vendor id used by Parallels video card
80110 # --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
81111 result = "parallels" if p =~ /1ab8:|[Pp]arallels/
86116 output.each_line do |pd|
87117 result = "parallels" if pd =~ /Parallels/
88118 result = "vmware" if pd =~ /VMware/
119 result = "virtualbox" if pd =~ /VirtualBox/
89120 end
90 else
91 output = Facter::Util::Resolution.exec('prtdiag')
121 elsif Facter.value(:kernel) == 'SunOS'
122 res = Facter::Util::Resolution.new('prtdiag')
123 res.timeout = 6
124 res.setcode('prtdiag')
125 output = res.value
92126 if not output.nil?
93127 output.each_line do |pd|
94128 result = "parallels" if pd =~ /Parallels/
95129 result = "vmware" if pd =~ /VMware/
130 result = "virtualbox" if pd =~ /VirtualBox/
96131 end
97132 end
98133 end
107142 end
108143 end
109144
145 # Fact: is_virtual
146 #
147 # Purpose: returning true or false for if a machine is virtualised or not.
148 #
149 # Resolution: The Xen domain 0 machine is virtualised to a degree, but is generally
150 # not viewed as being a virtual machine. This checks that the machine is not
151 # physical nor xen0, if that is the case, it is virtual.
152 #
153 # Caveats:
154 #
155
110156 Facter.add("is_virtual") do
111157 confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin GNU/kFreeBSD}
112158
0 # Fact: vlans
1 #
2 # Purpose: On Linux, return a list of all the VLANs on the system.
3 #
4 # Resolution: On Linux only, checks for and reads /proc/net/vlan/config and
5 # parses it.
6 #
7 # Caveats:
8 #
9
010 require 'facter/util/vlans'
111
212 Facter.add("vlans") do
0 # Fact: xendomains
1 #
2 # Purpose: Return the list of Xen domains on the Dom0.
3 #
4 # Resolution:
5 # On a Xen Dom0 host, return a list of Xen domains using the 'util/xendomains'
6 # library.
7 #
8 # Caveats:
9 #
10
011 require 'facter/util/xendomains'
112
213 Facter.add("xendomains") do
0 #--
1 # Copyright 2006 Luke Kanies <luke@madstop.com>
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 #
17 #--
0 # Facter - Host Fact Detection and Reporting
1 #
2 # Copyright 2011 Puppet Labs Inc
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
1815
1916 module Facter
2017 # This is just so the other classes have the constant.
2623 include Comparable
2724 include Enumerable
2825
29 FACTERVERSION = '1.5.9'
26 FACTERVERSION = '1.6.0'
3027 # = Facter
3128 # Functions as a hash of 'facts' you might care about about your
3229 # system, such as mac address, IP address, Video card, etc.
spec/fixtures/uptime/sysctl_kern_boottime less more
Binary diff not shown
1717
1818 # Ensure that we don't accidentally cache between test cases.
1919 config.before :each do
20 Facter::Util::Loader.any_instance.stubs(:load_all)
2021 Facter.clear
2122 end
2223 end
22 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
33
44 require 'facter'
5 require 'facter/util/ip'
56
67 describe "Per Interface IP facts" do
7 before do
8 Facter.loadfacts
9 end
10
118 it "should replace the ':' in an interface list with '_'" do
129 # So we look supported
1310 Facter.fact(:kernel).stubs(:value).returns("SunOS")
1411
15 Facter::Util::IP.expects(:get_interfaces).returns %w{eth0:1 eth1:2}
12 Facter::Util::IP.stubs(:get_interfaces).returns %w{eth0:1 eth1:2}
1613 Facter.fact(:interfaces).value.should == %{eth0_1,eth1_2}
1714 end
1815 end
55
66 describe "Memory facts" do
77 before do
8 Facter.loadfacts
8 # We need these facts loaded, but they belong to a file with a
9 # different name, so load the file explicitly.
10 Facter.collection.loader.load(:memory)
911 end
1012
1113 after do
3333
3434 it "should identify Oracle VM as OVS" do
3535 Facter.fact(:kernel).stubs(:value).returns("Linux")
36 Facter.stubs(:value).with(:lsbdistid).returns(nil)
3637 FileTest.stubs(:exists?).returns false
3738
3839 FileTest.expects(:exists?).with("/etc/ovs-release").returns true
4344
4445 it "should identify VMWare ESX" do
4546 Facter.fact(:kernel).stubs(:value).returns("Linux")
47 Facter.stubs(:value).with(:lsbdistid).returns(nil)
4648 FileTest.stubs(:exists?).returns false
4749
4850 FileTest.expects(:exists?).with("/etc/vmware-release").returns true
0 #!/usr/bin/env ruby
1
2 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
4 require 'facter'
5
6 describe "Physical processor count facts" do
7 before do
8 Facter.loadfacts
9 end
10 before do
11 Facter.clear
12 end
13 it "should return one physical CPU" do
14 Facter.fact(:kernel).stubs(:value).returns("Linux")
15 File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true)
16 Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(["/sys/devices/system/cpu/cpu0/topology/physical_package_id"])
17 Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0")
18
19 Facter.fact(:physicalprocessorcount).value.should == 1
20 end
21
22 it "should return four physical CPUs" do
23 Facter.fact(:kernel).stubs(:value).returns("Linux")
24 File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true)
25 Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(%w{
26 /sys/devices/system/cpu/cpu0/topology/physical_package_id
27 /sys/devices/system/cpu/cpu1/topology/physical_package_id
28 /sys/devices/system/cpu/cpu2/topology/physical_package_id
29 /sys/devices/system/cpu/cpu3/topology/physical_package_id
30 })
31
32 Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0")
33 Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu1/topology/physical_package_id").returns("1")
34 Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu2/topology/physical_package_id").returns("2")
35 Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu3/topology/physical_package_id").returns("3")
36
37 Facter.fact(:physicalprocessorcount).value.should == 4
38 end
39 end
5555 @fact.add { }
5656 end
5757
58 it "should re-sort the resolutions by length, so the most restricted resolutions are first" do
59 r1 = stub 'r1', :length => 1
60 r2 = stub 'r2', :length => 2
61 r3 = stub 'r3', :length => 0
58 it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do
59 r1 = stub 'r1', :weight => 1
60 r2 = stub 'r2', :weight => 2
61 r3 = stub 'r3', :weight => 0
6262 Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
6363 @fact.add { }
6464 @fact.add { }
8282 end
8383
8484 it "should return the first value returned by a resolution" do
85 r1 = stub 'r1', :length => 2, :value => nil, :suitable? => true
86 r2 = stub 'r2', :length => 1, :value => "yay", :suitable? => true
87 r3 = stub 'r3', :length => 0, :value => "foo", :suitable? => true
85 r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true
86 r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
87 r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true
8888 Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
8989 @fact.add { }
9090 @fact.add { }
9494 end
9595
9696 it "should short-cut returning the value once one is found" do
97 r1 = stub 'r1', :length => 2, :value => "foo", :suitable? => true
98 r2 = stub 'r2', :length => 1, :suitable? => true # would fail if 'value' were asked for
97 r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true
98 r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for
9999 Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
100100 @fact.add { }
101101 @fact.add { }
104104 end
105105
106106 it "should skip unsuitable resolutions" do
107 r1 = stub 'r1', :length => 2, :suitable? => false # would fail if 'value' were asked for'
108 r2 = stub 'r2', :length => 1, :value => "yay", :suitable? => true
107 r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for'
108 r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
109109 Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
110110 @fact.add { }
111111 @fact.add { }
1818
1919
2020 describe Facter::Util::Loader do
21 before :each do
22 Facter::Util::Loader.any_instance.unstub(:load_all)
23 end
24
2125 def with_env(values)
2226 old = {}
2327 values.each do |var, value|
1010
1111 it "should have a name" do
1212 Facter::Util::Resolution.new("yay").name.should == "yay"
13 end
14
15 it "should have a method for setting the weight" do
16 Facter::Util::Resolution.new("yay").should respond_to(:has_weight)
1317 end
1418
1519 it "should have a method for setting the code" do
194198 it "should provide a method for returning the number of confines" do
195199 @resolve = Facter::Util::Resolution.new("yay")
196200 @resolve.confine "one" => "foo", "two" => "fee"
197 @resolve.length.should == 2
201 @resolve.weight.should == 2
198202 end
199203
200204 it "should return 0 confines when no confines have been added" do
201 Facter::Util::Resolution.new("yay").length.should == 0
205 Facter::Util::Resolution.new("yay").weight.should == 0
206 end
207
208 it "should provide a way to set the weight" do
209 @resolve = Facter::Util::Resolution.new("yay")
210 @resolve.has_weight(45)
211 @resolve.weight.should == 45
212 end
213
214 it "should allow the weight to override the number of confines" do
215 @resolve = Facter::Util::Resolution.new("yay")
216 @resolve.confine "one" => "foo", "two" => "fee"
217 @resolve.weight.should == 2
218 @resolve.has_weight(45)
219 @resolve.weight.should == 45
202220 end
203221
204222 it "should have a method for determining if it is suitable" do
2626 end
2727
2828 it "should use 'sysctl kern.boottime'" do
29 sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'sysctl_kern_boottime') # Aug 01 14:13:47 -0700 2010
29 if [1].pack("L") == [1].pack("V") # Determine endianness
30 sysctl_output_filename = 'sysctl_kern_boottime_little_endian'
31 else
32 sysctl_output_filename = 'sysctl_kern_boottime_big_endian'
33 end
34 sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', sysctl_output_filename) # Aug 01 14:13:47 -0700 2010
3035 Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
3136 Time.stubs(:now).returns Time.parse("Aug 01 15:13:47 -0700 2010") # one hour later
3237 Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
88 end
99 it "should detect openvz" do
1010 FileTest.stubs(:directory?).with("/proc/vz").returns(true)
11 FileTest.stubs(:exists?).with("/proc/vz/veinfo").returns(true)
1112 Facter::Util::Virtual.should be_openvz
1213 end
1314
7272
7373 before do
7474 FileTest.expects(:exists?).with("/usr/lib/vmware/bin/vmware-vmx").returns false
75 Facter.fact(:operatingsystem).stubs(:value).returns(true)
7576 Facter.fact(:architecture).stubs(:value).returns(true)
7677 end
7778
9394 Facter.fact(:virtual).value.should == "vmware"
9495 end
9596
97 it "should be virtualbox with VirtualBox vendor name from lspci" do
98 Facter.fact(:kernel).stubs(:value).returns("Linux")
99 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
100 Facter.fact(:virtual).value.should == "virtualbox"
101 end
102
96103 it "should be vmware with VMWare vendor name from dmidecode" do
97104 Facter.fact(:kernel).stubs(:value).returns("Linux")
98105 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
107114 Facter.fact(:virtual).value.should == "parallels"
108115 end
109116
117 it "should be virtualbox with VirtualBox vendor name from dmidecode" do
118 Facter.fact(:kernel).stubs(:value).returns("Linux")
119 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
120 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
121 Facter.fact(:virtual).value.should == "virtualbox"
122 end
123
124 end
125 describe "on Solaris" do
110126 it "should be vmware with VMWare vendor name from prtdiag" do
111 Facter.fact(:kernel).stubs(:value).returns("Linux")
127 Facter.fact(:kernel).stubs(:value).returns("SunOS")
112128 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
113129 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
114 Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
130 Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
115131 Facter.fact(:virtual).value.should == "vmware"
116132 end
117133
118134 it "should be parallels with Parallels vendor name from prtdiag" do
119 Facter.fact(:kernel).stubs(:value).returns("Linux")
135 Facter.fact(:kernel).stubs(:value).returns("SunOS")
120136 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
121137 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
122 Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
123 Facter.fact(:virtual).value.should == "parallels"
138 Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: Parallels Virtual Platform")
139 Facter.fact(:virtual).value.should == "parallels"
140 end
141
142 it "should be virtualbox with VirtualBox vendor name from prtdiag" do
143 Facter.fact(:kernel).stubs(:value).returns("SunOS")
144 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
145 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
146 Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: innotek GmbH VirtualBox")
147 Facter.fact(:virtual).value.should == "virtualbox"
124148 end
125149 end
126150 end
151175 Facter.fact(:is_virtual).value.should == "true"
152176 end
153177
178 it "should be true when running on virtualbox" do
179 Facter.fact(:kernel).stubs(:value).returns("Linux")
180 Facter.fact(:virtual).stubs(:value).returns("virtualbox")
181 Facter.fact(:is_virtual).value.should == "true"
182 end
183
154184 it "should be true when running on openvz" do
155185 Facter.fact(:kernel).stubs(:value).returns("Linux")
156186 Facter.fact(:virtual).stubs(:value).returns("openvzve")
3333 # If we've got more than one patch, add --compose
3434 if files.length > 1
3535 compose = "--compose"
36 subject = %Q{--subject "#{type} #{name} against #{parent}"}
3637 else
3738 compose = ""
39 subject = ""
3840 end
3941
4042 # Now send the mail.
41 sh "git send-email #{compose} --no-signed-off-by-cc --suppress-from --to puppet-dev@googlegroups.com 00*.patch"
43 sh "git send-email #{compose} #{subject} --no-signed-off-by-cc --suppress-from --to puppet-dev@googlegroups.com 00*.patch"
4244
4345 # Finally, clean up the patches
4446 sh "rm 00*.patch"