facter 2.4.4-universal-darwin → 2.4.5-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/lib/facter/core/execution/posix.rb +2 -2
  2. data/lib/facter/gid.rb +1 -1
  3. data/lib/facter/ipaddress.rb +5 -14
  4. data/lib/facter/ipaddress6.rb +3 -2
  5. data/lib/facter/macaddress.rb +3 -8
  6. data/lib/facter/netmask.rb +9 -1
  7. data/lib/facter/processors/os.rb +1 -1
  8. data/lib/facter/util/ip.rb +17 -0
  9. data/lib/facter/util/netmask.rb +0 -6
  10. data/lib/facter/util/virtual.rb +2 -2
  11. data/lib/facter/version.rb +1 -1
  12. data/spec/fixtures/ifconfig/net_route_all_with_multiple_interfaces +2 -0
  13. data/spec/fixtures/ifconfig/net_route_net_tools_1.60.txt +3 -0
  14. data/spec/fixtures/unit/ipaddress/net_route_multiple_127_addresses.txt +3 -0
  15. data/spec/fixtures/unit/ipaddress/net_route_net_tools_1.60.txt +3 -0
  16. data/spec/fixtures/unit/ipaddress/net_route_non_english_locale.txt +3 -0
  17. data/spec/fixtures/unit/ipaddress/net_route_ubuntu_1204.txt +3 -0
  18. data/spec/fixtures/unit/netmask/{darwin_10_8_5.txt → ifconfig_darwin_10_8_5.txt} +0 -0
  19. data/spec/fixtures/unit/netmask/net_route_multiple_127_addresses.txt +3 -0
  20. data/spec/fixtures/unit/netmask/net_route_net_tools_1.60.txt +3 -0
  21. data/spec/fixtures/unit/netmask/net_route_non_english_locale.txt +3 -0
  22. data/spec/fixtures/unit/netmask/net_route_ubuntu_1204.txt +3 -0
  23. data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container_with_systemd_slices +10 -0
  24. data/spec/unit/core/execution/posix_spec.rb +10 -0
  25. data/spec/unit/gid_spec.rb +9 -0
  26. data/spec/unit/ipaddress6_spec.rb +16 -4
  27. data/spec/unit/ipaddress_spec.rb +12 -12
  28. data/spec/unit/macaddress_spec.rb +6 -1
  29. data/spec/unit/netmask_spec.rb +17 -4
  30. data/spec/unit/processors/os_spec.rb +2 -0
  31. data/spec/unit/util/virtual_spec.rb +11 -0
  32. metadata +26 -4
@@ -11,11 +11,11 @@ class Facter::Core::Execution::Posix < Facter::Core::Execution::Base
11
11
 
12
12
  def which(bin)
13
13
  if absolute_path?(bin)
14
- return bin if File.executable?(bin)
14
+ return bin if File.executable?(bin) and File.file?(bin)
15
15
  else
16
16
  search_paths.each do |dir|
17
17
  dest = File.join(dir, bin)
18
- return dest if File.executable?(dest)
18
+ return dest if File.executable?(dest) and File.file?(dest)
19
19
  end
20
20
  end
21
21
  nil
@@ -10,7 +10,7 @@
10
10
 
11
11
  Facter.add(:gid) do
12
12
  confine do
13
- Facter::Core::Execution.which('id') && Facter.value(:kernel) != "SunOS"
13
+ Facter::Core::Execution.which('id') && !["SunOS", "windows"].include?(Facter.value(:kernel))
14
14
  end
15
15
  setcode { Facter::Core::Execution.exec('id -ng') }
16
16
  end
@@ -3,7 +3,9 @@
3
3
  # Purpose: Return the main IP address for a host.
4
4
  #
5
5
  # Resolution:
6
- # On the Unixes does an ifconfig, and returns the first non 127.0.0.0/8
6
+ # On Linux and AIX, it examines the routing table and uses the IP address
7
+ # of the default interface.
8
+ # On other Unixes does an ifconfig, and returns the first non 127.0.0.0/8
7
9
  # subnetted IP it finds.
8
10
  # On Windows, it attempts to use the socket library and resolve the machine's
9
11
  # hostname via DNS.
@@ -27,19 +29,8 @@ require 'facter/util/ip'
27
29
  Facter.add(:ipaddress) do
28
30
  confine :kernel => :linux
29
31
  setcode do
30
- ip = nil
31
- output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
32
- if output
33
- regexp = /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
34
- output.split("\n").each do |line|
35
- match = regexp.match(line)
36
- if match and not /^127\./.match(match[1])
37
- ip = match[1]
38
- break
39
- end
40
- end
41
- end
42
- ip
32
+ iface = Facter::Util::IP.linux_default_iface
33
+ Facter.value("ipaddress_#{iface}")
43
34
  end
44
35
  end
45
36
 
@@ -37,11 +37,12 @@ def get_address_after_token(output, token, return_first=false)
37
37
  ip
38
38
  end
39
39
 
40
+
40
41
  Facter.add(:ipaddress6) do
41
42
  confine :kernel => :linux
42
43
  setcode do
43
- output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
44
- get_address_after_token(output, 'inet6(?: addr:)?')
44
+ iface = Facter::Util::IP.linux_default_iface
45
+ Facter.value("ipaddress6_#{iface}")
45
46
  end
46
47
  end
47
48
 
@@ -12,15 +12,10 @@ require 'facter/util/macaddress'
12
12
  require 'facter/util/ip'
13
13
 
14
14
  Facter.add(:macaddress) do
15
- confine :kernel => 'Linux'
15
+ confine :kernel => :linux
16
16
  setcode do
17
- ether = []
18
- output = Facter::Util::IP.exec_ifconfig(["-a","2>/dev/null"])
19
-
20
- String(output).each_line do |s|
21
- ether.push($1) if s =~ /(?:ether|HWaddr) ((\w{1,2}:){5,}\w{1,2})/
22
- end
23
- Facter::Util::Macaddress.standardize(ether[0])
17
+ iface = Facter::Util::IP.linux_default_iface
18
+ Facter.value("macaddress_#{iface}")
24
19
  end
25
20
  end
26
21
 
@@ -16,8 +16,16 @@
16
16
  #
17
17
  require 'facter/util/netmask'
18
18
 
19
+ Facter.add(:netmask) do
20
+ confine :kernel => :linux
21
+ setcode do
22
+ iface = Facter::Util::IP.linux_default_iface
23
+ Facter.value("netmask_#{iface}")
24
+ end
25
+ end
26
+
19
27
  Facter.add("netmask") do
20
- confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly, :AIX ]
28
+ confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly, :AIX ]
21
29
  setcode do
22
30
  Facter::NetMask.get_netmask
23
31
  end
@@ -112,7 +112,7 @@ module Facter
112
112
  # get each physical processor
113
113
  Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc|
114
114
  # not supported before 2008
115
- if proc.respond_to?(:NumberOfLogicalProcessors)
115
+ if proc.ole_respond_to?(:NumberOfLogicalProcessors)
116
116
  processor_num = proc.NumberOfLogicalProcessors
117
117
  else
118
118
  processor_num = 1
@@ -337,4 +337,21 @@ module Facter::Util::IP
337
337
  network = ip.mask(subnet.to_s).to_s
338
338
  end
339
339
  end
340
+
341
+ def self.read_proc_net_route
342
+ File.read("/proc/net/route")
343
+ end
344
+
345
+ def self.linux_default_iface
346
+ routes = read_proc_net_route
347
+ iface = nil
348
+ routes.split("\n").each do |line|
349
+ parts = line.split
350
+ if parts[1] == "00000000"
351
+ iface = alphafy(parts[0])
352
+ break
353
+ end
354
+ end
355
+ iface
356
+ end
340
357
  end
@@ -5,12 +5,6 @@ module Facter::NetMask
5
5
 
6
6
  ops = nil
7
7
  case Facter.value(:kernel)
8
- when 'Linux'
9
- ops = {
10
- :ifconfig_opts => ['2>/dev/null'],
11
- :regex => %r{#{Facter.value(:ipaddress)}.*?(?:Mask:|netmask)\s*(#{ipregex})}x,
12
- :munge => nil,
13
- }
14
8
  when 'SunOS'
15
9
  ops = {
16
10
  :ifconfig_opts => ['-a'],
@@ -162,7 +162,7 @@ module Facter::Util::Virtual
162
162
  path = Pathname.new('/proc/1/cgroup')
163
163
  return false unless path.readable?
164
164
  begin
165
- in_lxc = path.readlines.any? {|l| l.split(":")[2].to_s.start_with? '/lxc/' }
165
+ in_lxc = path.readlines.any? {|l| l.split(":")[2].to_s.include? '/lxc' }
166
166
  rescue Errno::EPERM => exc
167
167
  # If we get "operation not permitted" here, it probably means we are
168
168
  # running OpenVZ. We are not running LXC anyway, so...
@@ -179,7 +179,7 @@ module Facter::Util::Virtual
179
179
  path = Pathname.new('/proc/1/cgroup')
180
180
  return false unless path.readable?
181
181
  begin
182
- in_docker = path.readlines.any? {|l| l.split(":")[2].to_s.start_with? '/docker/' }
182
+ in_docker = path.readlines.any? {|l| l.split(":")[2].to_s.include? '/docker' }
183
183
  rescue Errno::EPERM => exc
184
184
  # This can fail under OpenVZ, just like in .lxc?
185
185
  return false
@@ -1,6 +1,6 @@
1
1
  module Facter
2
2
  if not defined? FACTERVERSION then
3
- FACTERVERSION = '2.4.4'
3
+ FACTERVERSION = '2.4.5'
4
4
  end
5
5
 
6
6
  # Returns the running version of Facter.
@@ -0,0 +1,2 @@
1
+ eth0 00000000 01D1FC83 0003 0 0 100 00000000 0 0 0
2
+ eth0 01D1FC83 00000000 0001 0 0 100 00FFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ em1 00000000 99D1FC83 0003 0 0 100 00000000 0 0 0
3
+ em1 99D1FC83 99D1FC83 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ venet0:1 00000000 1400DE0A 0003 0 0 100 00000000 0 0 0
3
+ venet0:1 1400DE0A 1400DE0A 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ em1 00000000 99D1FC83 0003 0 0 100 00000000 0 0 0
3
+ em1 99D1FC83 99D1FC83 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ wlan0 00000000 5301A8C0 0003 0 0 100 00000000 0 0 0
3
+ wlan0 5301A8C0 5301A8C0 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ eth0 00000000 6E50570A 0003 0 0 100 00000000 0 0 0
3
+ eth0 6E50570A 6E50570A 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ venet0:1 00000000 1400DE0A 0003 0 0 100 00000000 0 0 0
3
+ venet0:1 1400DE0A 1400DE0A 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ em1 00000000 99D1FC83 0003 0 0 100 00000000 0 0 0
3
+ em1 99D1FC83 99D1FC83 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ wlan0 00000000 5301A8C0 0003 0 0 100 00000000 0 0 0
3
+ wlan0 5301A8C0 5301A8C0 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,3 @@
1
+ Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2
+ eth0 00000000 6E50570A 0003 0 0 100 00000000 0 0 0
3
+ eth0 6E50570A 6E50570A 0007 0 0 100 FFFFFFFF 0 0 0
@@ -0,0 +1,10 @@
1
+ 10:hugetlb:/
2
+ 9:perf_event:/
3
+ 8:blkio:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
4
+ 7:net_cls:/
5
+ 6:freezer:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
6
+ 5:devices:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
7
+ 4:memory:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
8
+ 3:cpuacct,cpu:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
9
+ 2:cpuset:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
10
+ 1:name=systemd:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope
@@ -16,6 +16,7 @@ describe Facter::Core::Execution::Posix, :unless => Facter::Util::Config.is_wind
16
16
 
17
17
  context "and provided with an absolute path" do
18
18
  it "should return the binary if executable" do
19
+ File.expects(:file?).with('/opt/foo').returns true
19
20
  File.expects(:executable?).with('/opt/foo').returns true
20
21
  subject.which('/opt/foo').should == '/opt/foo'
21
22
  end
@@ -24,12 +25,21 @@ describe Facter::Core::Execution::Posix, :unless => Facter::Util::Config.is_wind
24
25
  File.expects(:executable?).with('/opt/foo').returns false
25
26
  subject.which('/opt/foo').should be_nil
26
27
  end
28
+
29
+ it "should return nil if the binary is not a file" do
30
+ File.expects(:file?).with('/opt/foo').returns false
31
+ File.expects(:executable?).with('/opt/foo').returns true
32
+ subject.which('/opt/foo').should be_nil
33
+ end
27
34
  end
28
35
 
29
36
  context "and not provided with an absolute path" do
30
37
  it "should return the absolute path if found" do
38
+ File.expects(:file?).with('/bin/foo').never
31
39
  File.expects(:executable?).with('/bin/foo').returns false
40
+ File.expects(:file?).with('/sbin/foo').returns true
32
41
  File.expects(:executable?).with('/sbin/foo').returns true
42
+ File.expects(:file?).with('/usr/sbin/foo').never
33
43
  File.expects(:executable?).with('/usr/sbin/foo').never
34
44
  subject.which('foo').should == '/sbin/foo'
35
45
  end
@@ -39,4 +39,13 @@ describe "gid fact" do
39
39
  Facter.fact(:gid).value.should == nil
40
40
  end
41
41
  end
42
+
43
+ describe "on windows systems" do
44
+ it "is not supported" do
45
+ Facter.fact(:kernel).stubs(:value).returns("windows")
46
+ Facter::Core::Execution.expects(:which).with('id').returns(true)
47
+
48
+ Facter.fact(:gid).value.should == nil
49
+ end
50
+ end
42
51
  end
@@ -26,8 +26,11 @@ describe "The IPv6 address fact" do
26
26
  it "should return ipaddress6 information for Linux" do
27
27
  Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
28
28
  Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
29
- Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
29
+ Facter::Util::IP.stubs(:exec_ifconfig).
30
30
  returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces'))
31
+ routes = ifconfig_fixture('net_route_all_with_multiple_interfaces')
32
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
33
+ Facter.collection.internal_loader.load(:interfaces)
31
34
 
32
35
  Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
33
36
  end
@@ -35,8 +38,11 @@ describe "The IPv6 address fact" do
35
38
  it "should return ipaddress6 information for Linux with recent net-tools" do
36
39
  Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
37
40
  Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
38
- Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
41
+ Facter::Util::IP.stubs(:exec_ifconfig).
39
42
  returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt'))
43
+ routes = ifconfig_fixture('net_route_net_tools_1.60.txt')
44
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
45
+ Facter.collection.internal_loader.load(:interfaces)
40
46
 
41
47
  Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
42
48
  end
@@ -44,8 +50,11 @@ describe "The IPv6 address fact" do
44
50
  it "should return ipaddress6 with fe80 in any other octet than the first for Linux" do
45
51
  Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
46
52
  Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
47
- Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
53
+ Facter::Util::IP.stubs(:exec_ifconfig).
48
54
  returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces_and_fe80'))
55
+ routes = ifconfig_fixture('net_route_all_with_multiple_interfaces')
56
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
57
+ Facter.collection.internal_loader.load(:interfaces)
49
58
 
50
59
  Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:fe80:2201"
51
60
  end
@@ -53,8 +62,11 @@ describe "The IPv6 address fact" do
53
62
  it "should not return ipaddress6 link-local address for Linux" do
54
63
  Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
55
64
  Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
56
- Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
65
+ Facter::Util::IP.stubs(:exec_ifconfig).
57
66
  returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces_and_no_public_ipv6'))
67
+ routes = ifconfig_fixture('net_route_all_with_multiple_interfaces')
68
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
69
+ Facter.collection.internal_loader.load(:interfaces)
58
70
 
59
71
  Facter.value(:ipaddress6).should be_false
60
72
  end
@@ -4,10 +4,6 @@ require 'spec_helper'
4
4
  require 'facter/util/ip'
5
5
 
6
6
  describe "ipaddress fact" do
7
- before do
8
- Facter.collection.internal_loader.load(:ipaddress)
9
- end
10
-
11
7
  context 'using `ifconfig`' do
12
8
  before :each do
13
9
  Facter.fact(:hostname).stubs(:value)
@@ -18,25 +14,29 @@ describe "ipaddress fact" do
18
14
  Facter.fact(:kernel).stubs(:value).returns("Linux")
19
15
  end
20
16
 
17
+ after :each do
18
+ Facter.collection.flush
19
+ end
20
+
21
21
  def expect_ifconfig_parse(address, fixture)
22
- Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
22
+ Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read("ifconfig_#{fixture}"))
23
+ routes = my_fixture_read("net_route_#{fixture}")
24
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
25
+ Facter.collection.internal_loader.load(:interfaces)
26
+ Facter.collection.internal_loader.load(:ipaddress)
23
27
  Facter.fact(:ipaddress).value.should == address
24
28
  end
25
29
 
26
30
  it "parses correctly on Ubuntu 12.04" do
27
- expect_ifconfig_parse "10.87.80.110", "ifconfig_ubuntu_1204.txt"
31
+ expect_ifconfig_parse "10.87.80.110", "ubuntu_1204.txt"
28
32
  end
29
33
 
30
34
  it "parses correctly on Fedora 17" do
31
- expect_ifconfig_parse "131.252.209.153", "ifconfig_net_tools_1.60.txt"
32
- end
33
-
34
- it "parses a real address over multiple loopback addresses" do
35
- expect_ifconfig_parse "10.0.222.20", "ifconfig_multiple_127_addresses.txt"
35
+ expect_ifconfig_parse "131.252.209.153", "net_tools_1.60.txt"
36
36
  end
37
37
 
38
38
  it "parses nothing with a non-english locale" do
39
- expect_ifconfig_parse nil, "ifconfig_non_english_locale.txt"
39
+ expect_ifconfig_parse nil, "non_english_locale.txt"
40
40
  end
41
41
  end
42
42
  end
@@ -23,8 +23,11 @@ describe "macaddress fact" do
23
23
  end
24
24
 
25
25
  it "should return the macaddress of the first interface" do
26
- Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]).
26
+ Facter::Util::IP.stubs(:exec_ifconfig).
27
27
  returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces'))
28
+ routes = ifconfig_fixture("net_route_all_with_multiple_interfaces")
29
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
30
+ Facter.collection.internal_loader.load(:interfaces)
28
31
 
29
32
  Facter.value(:macaddress).should == "00:12:3f:be:22:01"
30
33
  end
@@ -32,6 +35,7 @@ describe "macaddress fact" do
32
35
  it "should return nil when no macaddress can be found" do
33
36
  Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]).
34
37
  returns(ifconfig_fixture('linux_ifconfig_no_mac'))
38
+ Facter::Util::IP.stubs(:read_proc_net_route).returns("")
35
39
 
36
40
  proc { Facter.value(:macaddress) }.should_not raise_error
37
41
  Facter.value(:macaddress).should be_nil
@@ -41,6 +45,7 @@ describe "macaddress fact" do
41
45
  it "should return nil when no interface has a real macaddress" do
42
46
  Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]).
43
47
  returns(ifconfig_fixture('linux_ifconfig_venet'))
48
+ Facter::Util::IP.stubs(:read_proc_net_route).returns("")
44
49
 
45
50
  proc { Facter.value(:macaddress) }.should_not raise_error
46
51
  Facter.value(:macaddress).should be_nil
@@ -6,8 +6,21 @@ require 'facter/util/ip'
6
6
 
7
7
  shared_examples_for "netmask from ifconfig output" do |platform, address, fixture|
8
8
  it "correctly on #{platform}" do
9
- Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
9
+ Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read("ifconfig_#{fixture}"))
10
10
  Facter.collection.internal_loader.load(:netmask)
11
+ begin
12
+ routes = my_fixture_read("net_route_#{fixture}")
13
+ Facter::Util::IP.stubs(:read_proc_net_route).returns(routes)
14
+ rescue RuntimeError
15
+ # We want to try to load proc/net/route fixtures, but skip if
16
+ # they don't exist for non-linux platforms. Ideally we'd get an
17
+ # IOError here, but the fixture machinery here is dumb and
18
+ # converts this to a RuntimeError. Hopefully anything that would
19
+ # error here would also cause the actual test to fail, so I'm
20
+ # not going to worry too hard.
21
+ end
22
+ Facter.collection.internal_loader.load(:interfaces)
23
+ Facter.collection.internal_loader.load(:ipaddress)
11
24
 
12
25
  Facter.fact(:netmask).value.should eq(address)
13
26
  end
@@ -21,10 +34,10 @@ describe "The netmask fact" do
21
34
 
22
35
  example_behavior_for "netmask from ifconfig output",
23
36
  "Archlinux (net-tools 1.60)", "255.255.255.0",
24
- "ifconfig_net_tools_1.60.txt"
37
+ "net_tools_1.60.txt"
25
38
  example_behavior_for "netmask from ifconfig output",
26
39
  "Ubuntu 12.04", "255.255.255.255",
27
- "ifconfig_ubuntu_1204.txt"
40
+ "ubuntu_1204.txt"
28
41
  end
29
42
 
30
43
  context "on AIX" do
@@ -34,7 +47,7 @@ describe "The netmask fact" do
34
47
 
35
48
  example_behavior_for "netmask from ifconfig output",
36
49
  "AIX 7", "255.255.255.0",
37
- "ifconfig_aix_7.txt"
50
+ "aix_7.txt"
38
51
 
39
52
  end
40
53
 
@@ -221,6 +221,7 @@ describe Facter::Processors::Windows do
221
221
  before :each do
222
222
  proc = stubs 'proc'
223
223
  proc.stubs(:Name).returns("Intel(R) Celeron(R) processor")
224
+ proc.stubs(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(false)
224
225
  load(Array.new(2, proc))
225
226
  end
226
227
 
@@ -235,6 +236,7 @@ describe Facter::Processors::Windows do
235
236
  before :each do
236
237
  proc = stubs 'proc'
237
238
  proc.stubs(:NumberOfLogicalProcessors).returns(2)
239
+ proc.stubs(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(true)
238
240
  proc.stubs(:Name).returns("Intel(R) Celeron(R) processor")
239
241
  load(Array.new(2, proc))
240
242
  end
@@ -368,6 +368,17 @@ describe Facter::Util::Virtual do
368
368
  end
369
369
  end
370
370
 
371
+ context '/proc/1/cgroup has at least one hierarchy with docker underneath a systemd slice parent' do
372
+ before :each do
373
+ fakepath = Pathname.new(File.join(fixture_path, 'in_a_docker_container_with_systemd_slices'))
374
+ Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath)
375
+ end
376
+
377
+ it 'is true' do
378
+ subject.should be_true
379
+ end
380
+ end
381
+
371
382
  context '/proc/1/cgroup has no hierarchies rooted in /docker/' do
372
383
  before :each do
373
384
  fakepath = Pathname.new(File.join(fixture_path, 'not_in_a_container'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.5
5
5
  prerelease:
6
6
  platform: universal-darwin
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-19 00:00:00.000000000 Z
12
+ date: 2016-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: CFPropertyList
@@ -217,6 +217,7 @@ files:
217
217
  - spec/fixtures/cpuinfo/two_multicore-grep
218
218
  - spec/fixtures/virtual/proc_1_cgroup/in_a_container
219
219
  - spec/fixtures/virtual/proc_1_cgroup/not_in_a_container
220
+ - spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container_with_systemd_slices
220
221
  - spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container
221
222
  - spec/fixtures/virtual/proc_self_status/vserver_2_1/guest
222
223
  - spec/fixtures/virtual/proc_self_status/vserver_2_1/host
@@ -235,8 +236,12 @@ files:
235
236
  - spec/fixtures/processorcount/solaris-psrinfo
236
237
  - spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt
237
238
  - spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt
239
+ - spec/fixtures/unit/netmask/net_route_ubuntu_1204.txt
240
+ - spec/fixtures/unit/netmask/net_route_multiple_127_addresses.txt
238
241
  - spec/fixtures/unit/netmask/ifconfig_aix_7.txt
239
- - spec/fixtures/unit/netmask/darwin_10_8_5.txt
242
+ - spec/fixtures/unit/netmask/net_route_non_english_locale.txt
243
+ - spec/fixtures/unit/netmask/net_route_net_tools_1.60.txt
244
+ - spec/fixtures/unit/netmask/ifconfig_darwin_10_8_5.txt
240
245
  - spec/fixtures/unit/selinux/selinux_sestatus2
241
246
  - spec/fixtures/unit/selinux/selinux_sestatus
242
247
  - spec/fixtures/unit/filesystems/linux
@@ -314,8 +319,12 @@ files:
314
319
  - spec/fixtures/unit/ec2/rest/meta-data/root
315
320
  - spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
316
321
  - spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
322
+ - spec/fixtures/unit/ipaddress/net_route_ubuntu_1204.txt
323
+ - spec/fixtures/unit/ipaddress/net_route_multiple_127_addresses.txt
317
324
  - spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt
325
+ - spec/fixtures/unit/ipaddress/net_route_non_english_locale.txt
318
326
  - spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt
327
+ - spec/fixtures/unit/ipaddress/net_route_net_tools_1.60.txt
319
328
  - spec/fixtures/unit/processors/os/darwin-system-profiler
320
329
  - spec/fixtures/unit/zfs_version/zfs_new
321
330
  - spec/fixtures/unit/zfs_version/solaris_11
@@ -360,6 +369,7 @@ files:
360
369
  - spec/fixtures/unit/zpool_version/freebsd_8.2
361
370
  - spec/fixtures/unit/zpool_version/solaris_10
362
371
  - spec/fixtures/ifconfig/open_solaris_b132
372
+ - spec/fixtures/ifconfig/net_route_all_with_multiple_interfaces
363
373
  - spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt
364
374
  - spec/fixtures/ifconfig/freebsd_6_0
365
375
  - spec/fixtures/ifconfig/linux_ifconfig_venet
@@ -383,6 +393,7 @@ files:
383
393
  - spec/fixtures/ifconfig/darwin_10_3_0_en0
384
394
  - spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces
385
395
  - spec/fixtures/ifconfig/open_solaris_10
396
+ - spec/fixtures/ifconfig/net_route_net_tools_1.60.txt
386
397
  - spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en1
387
398
  - spec/fixtures/ifconfig/darwin_10_6_6_dualstack
388
399
  - spec/fixtures/ifconfig/ubuntu_7_04_eth0
@@ -565,6 +576,7 @@ test_files:
565
576
  - spec/fixtures/cpuinfo/two_multicore-grep
566
577
  - spec/fixtures/virtual/proc_1_cgroup/in_a_container
567
578
  - spec/fixtures/virtual/proc_1_cgroup/not_in_a_container
579
+ - spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container_with_systemd_slices
568
580
  - spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container
569
581
  - spec/fixtures/virtual/proc_self_status/vserver_2_1/guest
570
582
  - spec/fixtures/virtual/proc_self_status/vserver_2_1/host
@@ -583,8 +595,12 @@ test_files:
583
595
  - spec/fixtures/processorcount/solaris-psrinfo
584
596
  - spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt
585
597
  - spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt
598
+ - spec/fixtures/unit/netmask/net_route_ubuntu_1204.txt
599
+ - spec/fixtures/unit/netmask/net_route_multiple_127_addresses.txt
586
600
  - spec/fixtures/unit/netmask/ifconfig_aix_7.txt
587
- - spec/fixtures/unit/netmask/darwin_10_8_5.txt
601
+ - spec/fixtures/unit/netmask/net_route_non_english_locale.txt
602
+ - spec/fixtures/unit/netmask/net_route_net_tools_1.60.txt
603
+ - spec/fixtures/unit/netmask/ifconfig_darwin_10_8_5.txt
588
604
  - spec/fixtures/unit/selinux/selinux_sestatus2
589
605
  - spec/fixtures/unit/selinux/selinux_sestatus
590
606
  - spec/fixtures/unit/filesystems/linux
@@ -662,8 +678,12 @@ test_files:
662
678
  - spec/fixtures/unit/ec2/rest/meta-data/root
663
679
  - spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
664
680
  - spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
681
+ - spec/fixtures/unit/ipaddress/net_route_ubuntu_1204.txt
682
+ - spec/fixtures/unit/ipaddress/net_route_multiple_127_addresses.txt
665
683
  - spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt
684
+ - spec/fixtures/unit/ipaddress/net_route_non_english_locale.txt
666
685
  - spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt
686
+ - spec/fixtures/unit/ipaddress/net_route_net_tools_1.60.txt
667
687
  - spec/fixtures/unit/processors/os/darwin-system-profiler
668
688
  - spec/fixtures/unit/zfs_version/zfs_new
669
689
  - spec/fixtures/unit/zfs_version/solaris_11
@@ -708,6 +728,7 @@ test_files:
708
728
  - spec/fixtures/unit/zpool_version/freebsd_8.2
709
729
  - spec/fixtures/unit/zpool_version/solaris_10
710
730
  - spec/fixtures/ifconfig/open_solaris_b132
731
+ - spec/fixtures/ifconfig/net_route_all_with_multiple_interfaces
711
732
  - spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt
712
733
  - spec/fixtures/ifconfig/freebsd_6_0
713
734
  - spec/fixtures/ifconfig/linux_ifconfig_venet
@@ -731,6 +752,7 @@ test_files:
731
752
  - spec/fixtures/ifconfig/darwin_10_3_0_en0
732
753
  - spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces
733
754
  - spec/fixtures/ifconfig/open_solaris_10
755
+ - spec/fixtures/ifconfig/net_route_net_tools_1.60.txt
734
756
  - spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en1
735
757
  - spec/fixtures/ifconfig/darwin_10_6_6_dualstack
736
758
  - spec/fixtures/ifconfig/ubuntu_7_04_eth0