facter 1.6.5 → 1.6.6

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/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ 1.6.6
2
+ ===
3
+ e046144 Updated CHANGELOG for 1.6.6rc2
4
+ c273d34 Make ec2 facts work on CentOS again (#12666)
5
+ c218d84 (#12362) Use Tempfile to generate temp files
6
+ f6bbe14 (#12170) Adds gem spec description Without this patch, the gem spec file is missing a description attribute, which caus
7
+ 5c5c330 Changes apple rake task to reflect package name facter instead of puppet.
8
+ 9b5cb26 Updating conf/redhat/facter.spec for 1.6.5 release.
9
+ 7d3889d (#12079) Fix order-dependent test failure due to odd stubbing.
10
+ 7f2a0e2 add a simple test for openstack ec2 facts
11
+ cb598aa Support EC2 facts on OpenStack
12
+
1
13
  1.6.5
2
14
  ===
3
15
  71d3d3d (#12077) Add pciutils RPM dependency
data/Rakefile CHANGED
@@ -38,6 +38,7 @@ spec = Gem::Specification.new do |spec|
38
38
  spec.executables = %w{facter}
39
39
  spec.version = Facter::FACTERVERSION
40
40
  spec.summary = 'Facter, a system inventory tool'
41
+ spec.description = 'You can prove anything with facts!'
41
42
  spec.author = 'Puppet Labs'
42
43
  spec.email = 'info@puppetlabs.com'
43
44
  spec.homepage = 'http://puppetlabs.com'
@@ -1,17 +1,18 @@
1
- %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG["sitelibdir"]'
1
+ %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG["sitelibdir"]')}
2
2
 
3
3
  %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5
4
4
  %define has_ruby_noarch %has_ruby_abi
5
- %global _ver 1.6.4
6
5
 
7
6
  Summary: Ruby module for collecting simple facts about a host operating system
8
7
  Name: facter
9
- Version: 1.6.4
10
- Release: 0.1rc1%{?dist}
8
+ Version: 1.6.6
9
+ Release: 1%{?dist}
10
+ #Release: 0.1rc1%{?dist}
11
11
  License: Apache 2.0
12
12
  Group: System Environment/Base
13
- URL: http://www.puppetlabs.com/puppet/related-projects/%{name}/
14
- Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz
13
+ URL: http://www.puppetlabs.com/puppet/related-projects/%{name}
14
+ #Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz
15
+ Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz
15
16
  #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz.asc
16
17
 
17
18
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -21,6 +22,8 @@ BuildArch: noarch
21
22
 
22
23
  Requires: ruby >= 1.8.1
23
24
  Requires: which
25
+ # Note: dmidecode is only available on x86 and x86_64 so this package may need to move into being
26
+ # arch specific if people are using ppc, arm, s390 etc
24
27
  Requires: dmidecode
25
28
  Requires: pciutils
26
29
  %if %has_ruby_abi
@@ -34,7 +37,8 @@ system. Some of the facts are preconfigured, such as the hostname and the
34
37
  operating system. Additional facts can be added through simple Ruby scripts
35
38
 
36
39
  %prep
37
- %setup -q -n %{name}-%{version}rc1
40
+ %setup -q -n %{name}-%{version}
41
+ #%setup -q -n %{name}-%{version}rc1
38
42
 
39
43
  %build
40
44
 
@@ -55,6 +59,12 @@ rm -rf %{buildroot}
55
59
 
56
60
 
57
61
  %changelog
62
+ * Thu Feb 23 2012 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.6-1
63
+ - Update for 1.6.6
64
+
65
+ * Wed Jan 25 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 1.6.5-1
66
+ - Update to 1.6.5
67
+
58
68
  * Wed Nov 30 2011 Matthaus Litteken <matthaus@puppetlabs.com> - 1.6.4-0.1rc1
59
69
  - 1.6.4 rc1
60
70
 
data/install.rb CHANGED
@@ -37,6 +37,7 @@ require 'find'
37
37
  require 'fileutils'
38
38
  require 'optparse'
39
39
  require 'ostruct'
40
+ require 'tempfile'
40
41
 
41
42
  begin
42
43
  require 'rdoc/rdoc'
@@ -217,8 +218,6 @@ def prepare_installation
217
218
  opts.parse!
218
219
  end
219
220
 
220
- tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
221
-
222
221
  version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".")
223
222
  libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version)
224
223
 
@@ -289,9 +288,6 @@ def prepare_installation
289
288
  FileUtils.makedirs(sitelibdir)
290
289
  end
291
290
 
292
- tmpdirs << bindir
293
-
294
- InstallOptions.tmp_dirs = tmpdirs.compact
295
291
  InstallOptions.site_dir = sitelibdir
296
292
  InstallOptions.bin_dir = bindir
297
293
  InstallOptions.sbin_dir = sbindir
@@ -384,20 +380,12 @@ end
384
380
  # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
385
381
  # windows, we add an '.rb' extension and let file associations do their stuff.
386
382
  def install_binfile(from, op_file, target)
387
- tmp_dir = nil
388
- InstallOptions.tmp_dirs.each do |t|
389
- if File.directory?(t) and File.writable?(t)
390
- tmp_dir = t
391
- break
392
- end
393
- end
383
+ tmp_file = Tempfile.new('facter-binfile')
394
384
 
395
- fail "Cannot find a temporary directory" unless tmp_dir
396
- tmp_file = File.join(tmp_dir, '_tmp')
397
385
  ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
398
386
 
399
387
  File.open(from) do |ip|
400
- File.open(tmp_file, "w") do |op|
388
+ File.open(tmp_file.path, "w") do |op|
401
389
  ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
402
390
  op.puts "#!#{ruby}"
403
391
  contents = ip.readlines
@@ -422,7 +410,7 @@ def install_binfile(from, op_file, target)
422
410
  end
423
411
 
424
412
  if not installed_wrapper
425
- tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
413
+ tmp_file2 = Tempfile.new('facter-wrapper')
426
414
  cwv = <<-EOS
427
415
  @echo off
428
416
  setlocal
@@ -430,15 +418,15 @@ set RUBY_BIN=%~dp0
430
418
  set RUBY_BIN=%RUBY_BIN:\\=/%
431
419
  "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %*
432
420
  EOS
433
- File.open(tmp_file2, "w") { |cw| cw.puts cwv }
434
- FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
421
+ File.open(tmp_file2.path, "w") { |cw| cw.puts cwv }
422
+ FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
435
423
 
436
- File.unlink(tmp_file2)
424
+ tmp_file2.unlink
437
425
  installed_wrapper = true
438
426
  end
439
427
  end
440
- FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
441
- File.unlink(tmp_file)
428
+ FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :verbose => true)
429
+ tmp_file.unlink
442
430
  end
443
431
 
444
432
  check_prereqs
@@ -25,7 +25,7 @@ module Facter
25
25
  include Comparable
26
26
  include Enumerable
27
27
 
28
- FACTERVERSION = '1.6.5'
28
+ FACTERVERSION = '1.6.6'
29
29
  # = Facter
30
30
  # Functions as a hash of 'facts' you might care about about your
31
31
  # system, such as mac address, IP address, Video card, etc.
@@ -24,8 +24,8 @@ def userdata()
24
24
  end
25
25
  end
26
26
 
27
- if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_ec2_arp?) &&
28
- Facter::Util::EC2.can_connect?
27
+ if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_openstack_mac? ||
28
+ Facter::Util::EC2.has_ec2_arp?) && Facter::Util::EC2.can_connect?
29
29
 
30
30
  metadata
31
31
  userdata
@@ -26,6 +26,12 @@ module Facter::Util::EC2
26
26
  !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:})
27
27
  end
28
28
 
29
+ # Test if this host has a mac address used by OpenStack, which
30
+ # normally starts with 02:16:3E
31
+ def has_openstack_mac?
32
+ !!(Facter.value(:macaddress) =~ %r{^02:16:3[eE]})
33
+ end
34
+
29
35
  # Test if the host has an arp entry in its cache that matches the EC2 arp,
30
36
  # which is normally +fe:ff:ff:ff:ff:ff+.
31
37
  def has_ec2_arp?
@@ -40,7 +46,7 @@ module Facter::Util::EC2
40
46
  arp_table = Facter::Util::Resolution.exec(arp_command)
41
47
  if not arp_table.nil?
42
48
  arp_table.each_line do |line|
43
- return true if line.include?(mac_address)
49
+ return true if line.downcase.include?(mac_address)
44
50
  end
45
51
  end
46
52
  return false
@@ -0,0 +1 @@
1
+ ? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0
@@ -11,11 +11,12 @@ describe "ec2 facts" do
11
11
  describe "when running on ec2" do
12
12
  before :each do
13
13
  # This is an ec2 instance, not a eucalyptus instance
14
- Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(false)
15
- Facter::Util::EC2.expects(:has_ec2_arp?).at_least_once.returns(true)
14
+ Facter::Util::EC2.stubs(:has_euca_mac?).returns(false)
15
+ Facter::Util::EC2.stubs(:has_openstack_mac?).returns(false)
16
+ Facter::Util::EC2.stubs(:has_ec2_arp?).returns(true)
16
17
 
17
18
  # Assume we can connect
18
- Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true)
19
+ Facter::Util::EC2.stubs(:can_connect?).returns(true)
19
20
  end
20
21
 
21
22
  it "should create flat meta-data facts" do
@@ -94,11 +95,40 @@ describe "ec2 facts" do
94
95
  describe "when running on eucalyptus" do
95
96
  before :each do
96
97
  # Return false for ec2, true for eucalyptus
97
- Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true)
98
- Facter::Util::EC2.expects(:has_ec2_arp?).never
98
+ Facter::Util::EC2.stubs(:has_euca_mac?).returns(true)
99
+ Facter::Util::EC2.stubs(:has_openstack_mac?).returns(false)
100
+ Facter::Util::EC2.stubs(:has_ec2_arp?).returns(false)
99
101
 
100
102
  # Assume we can connect
101
- Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true)
103
+ Facter::Util::EC2.stubs(:can_connect?).returns(true)
104
+ end
105
+
106
+ it "should create ec2_user_data fact" do
107
+ # No meta-data
108
+ Object.any_instance.expects(:open).\
109
+ with("#{api_prefix}/2008-02-01/meta-data/").\
110
+ at_least_once.returns(StringIO.new(""))
111
+
112
+ Object.any_instance.expects(:open).\
113
+ with("#{api_prefix}/2008-02-01/user-data/").\
114
+ at_least_once.returns(StringIO.new("test"))
115
+
116
+ # Force a fact load
117
+ Facter.collection.loader.load(:ec2)
118
+
119
+ Facter.fact(:ec2_userdata).value.should == ["test"]
120
+ end
121
+ end
122
+
123
+ describe "when running on openstack" do
124
+ before :each do
125
+ # Return false for ec2, true for eucalyptus
126
+ Facter::Util::EC2.stubs(:has_openstack_mac?).returns(true)
127
+ Facter::Util::EC2.stubs(:has_euca_mac?).returns(false)
128
+ Facter::Util::EC2.stubs(:has_ec2_arp?).returns(false)
129
+
130
+ # Assume we can connect
131
+ Facter::Util::EC2.stubs(:can_connect?).returns(true)
102
132
  end
103
133
 
104
134
  it "should create ec2_user_data fact" do
@@ -121,8 +151,8 @@ describe "ec2 facts" do
121
151
  describe "when api connect test fails" do
122
152
  it "should not populate ec2_userdata" do
123
153
  # Emulate ec2 for now as it matters little to this test
124
- Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true)
125
- Facter::Util::EC2.expects(:has_ec2_arp?).never
154
+ Facter::Util::EC2.stubs(:has_euca_mac?).returns(true)
155
+ Facter::Util::EC2.stubs(:has_ec2_arp?).never
126
156
  Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(false)
127
157
 
128
158
  # The API should never be called at this point
@@ -22,6 +22,13 @@ describe Facter::Util::EC2 do
22
22
  Facter::Util::EC2.has_ec2_arp?.should == true
23
23
  end
24
24
 
25
+ it "should succeed if arp table contains FE:FF:FF:FF:FF:FF" do
26
+ ec2arp = my_fixture_read("centos-arp-ec2.out")
27
+ Facter::Util::Resolution.expects(:exec).with("arp -an").\
28
+ at_least_once.returns(ec2arp)
29
+ Facter::Util::EC2.has_ec2_arp?.should == true
30
+ end
31
+
25
32
  it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do
26
33
  ec2arp = my_fixture_read("linux-arp-not-ec2.out")
27
34
  Facter::Util::Resolution.expects(:exec).with("arp -an").
@@ -68,6 +75,22 @@ describe Facter::Util::EC2 do
68
75
  end
69
76
  end
70
77
 
78
+ describe "is_openstack_mac? method" do
79
+ it "should return true when the mac is an openstack one" do
80
+ Facter.expects(:value).with(:macaddress).\
81
+ at_least_once.returns("02:16:3e:54:89:fd")
82
+
83
+ Facter::Util::EC2.has_openstack_mac?.should == true
84
+ end
85
+
86
+ it "should return false when the mac is not a openstack one" do
87
+ Facter.expects(:value).with(:macaddress).\
88
+ at_least_once.returns("0c:1d:a0:bc:aa:02")
89
+
90
+ Facter::Util::EC2.has_openstack_mac?.should == false
91
+ end
92
+ end
93
+
71
94
  describe "can_connect? method" do
72
95
  it "returns true if api responds" do
73
96
  # Return something upon connecting to the root
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 5
10
- version: 1.6.5
9
+ - 6
10
+ version: 1.6.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Puppet Labs
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-25 00:00:00 Z
18
+ date: 2012-02-23 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description:
21
+ description: You can prove anything with facts!
22
22
  email: info@puppetlabs.com
23
23
  executables:
24
24
  - facter
@@ -165,6 +165,7 @@ files:
165
165
  - spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info
166
166
  - spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info
167
167
  - spec/fixtures/unit/selinux/selinux_sestatus
168
+ - spec/fixtures/unit/util/ec2/centos-arp-ec2.out
168
169
  - spec/fixtures/unit/util/ec2/linux-arp-ec2.out
169
170
  - spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out
170
171
  - spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out