facter 2.0.2-x86-mingw32 → 2.1.0-x86-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile +14 -0
- data/ext/project_data.yaml +9 -6
- data/lib/facter/core/execution/base.rb +3 -3
- data/lib/facter/core/suitable.rb +1 -5
- data/lib/facter/dhcp_servers.rb +39 -0
- data/lib/facter/ec2.rb +33 -26
- data/lib/facter/ec2/rest.rb +130 -0
- data/lib/facter/fqdn.rb +2 -0
- data/lib/facter/gce.rb +16 -0
- data/lib/facter/gce/metadata.rb +87 -0
- data/lib/facter/kernelmajversion.rb +8 -0
- data/lib/facter/kernelrelease.rb +8 -0
- data/lib/facter/memory.rb +21 -15
- data/lib/facter/netmask.rb +1 -1
- data/lib/facter/operatingsystem.rb +20 -0
- data/lib/facter/operatingsystemmajrelease.rb +2 -1
- data/lib/facter/operatingsystemrelease.rb +19 -0
- data/lib/facter/osfamily.rb +3 -1
- data/lib/facter/partitions.rb +35 -0
- data/lib/facter/physicalprocessorcount.rb +9 -0
- data/lib/facter/processor.rb +25 -25
- data/lib/facter/util/config.rb +3 -1
- data/lib/facter/util/dhcp_servers.rb +43 -0
- data/lib/facter/util/ec2.rb +5 -0
- data/lib/facter/util/formatter.rb +2 -1
- data/lib/facter/util/ip.rb +1 -1
- data/lib/facter/util/loader.rb +10 -1
- data/lib/facter/util/manufacturer.rb +15 -16
- data/lib/facter/util/memory.rb +12 -12
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/operatingsystem.rb +21 -0
- data/lib/facter/util/partitions.rb +41 -0
- data/lib/facter/util/partitions/linux.rb +65 -0
- data/lib/facter/util/posix.rb +16 -0
- data/lib/facter/util/processor.rb +8 -10
- data/lib/facter/util/resolution.rb +4 -0
- data/lib/facter/util/values.rb +29 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/util/windows_root.rb +2 -32
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +53 -12
- data/spec/fixtures/ifconfig/openbsd_bridge_rules +11 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp +36 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static +24 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp +49 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static +37 -0
- data/spec/fixtures/unit/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/ec2/rest/meta-data/root +20 -0
- data/spec/fixtures/unit/gce/metadata/metadata.json +69 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3 +2 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3-current +3 -0
- data/spec/fixtures/unit/memory/aix-svmon +9 -0
- data/spec/fixtures/unit/memory/aix-swap_l +2 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-multiple +3 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-single +2 -0
- data/spec/fixtures/unit/memory/darwin-vm_stat +13 -0
- data/spec/fixtures/unit/memory/dragonfly-vmstat +3 -0
- data/spec/fixtures/unit/memory/freebsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/linux-proc_meminfo +10 -0
- data/spec/fixtures/unit/memory/openbsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/smartos_zone_swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-prtconf +4 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-multiple +3 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-vmstat +3 -0
- data/spec/fixtures/unit/netmask/ifconfig_aix_7.txt +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/util/manufacturer/smartos_smbios +533 -0
- data/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt +8 -0
- data/spec/fixtures/unit/util/operatingsystem/redhat-7.txt +12 -0
- data/spec/fixtures/unit/util/operatingsystem/sabayon.txt +7 -0
- data/spec/fixtures/unit/util/operatingsystem/wheezy.txt +9 -0
- data/spec/fixtures/unit/util/partitions/partitions/mount +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_container +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container +8 -0
- data/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container +9 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/core/execution/base_spec.rb +3 -5
- data/spec/unit/core/execution/posix_spec.rb +2 -2
- data/spec/unit/core/suitable_spec.rb +10 -0
- data/spec/unit/dhcp_servers_spec.rb +152 -0
- data/spec/unit/ec2/rest_spec.rb +145 -0
- data/spec/unit/ec2_spec.rb +87 -147
- data/spec/unit/fqdn_spec.rb +16 -0
- data/spec/unit/gce/metadata_spec.rb +49 -0
- data/spec/unit/gce_spec.rb +34 -0
- data/spec/unit/interfaces_spec.rb +9 -9
- data/spec/unit/kernelmajversion_spec.rb +14 -9
- data/spec/unit/kernelrelease_spec.rb +16 -0
- data/spec/unit/macaddress_spec.rb +12 -0
- data/spec/unit/memory_spec.rb +53 -122
- data/spec/unit/netmask_spec.rb +11 -0
- data/spec/unit/operatingsystem_spec.rb +19 -0
- data/spec/unit/operatingsystemmajrelease_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +8 -0
- data/spec/unit/osfamily_spec.rb +62 -0
- data/spec/unit/partitions_spec.rb +48 -0
- data/spec/unit/physicalprocessorcount_spec.rb +9 -0
- data/spec/unit/processor_spec.rb +15 -7
- data/spec/unit/util/config_spec.rb +13 -0
- data/spec/unit/util/dhcp_servers_spec.rb +63 -0
- data/spec/unit/util/ec2_spec.rb +4 -0
- data/spec/unit/util/formatter_spec.rb +50 -0
- data/spec/unit/util/loader_spec.rb +4 -4
- data/spec/unit/util/macosx_spec.rb +3 -2
- data/spec/unit/util/manufacturer_spec.rb +44 -0
- data/spec/unit/util/operatingsystem_spec.rb +92 -0
- data/spec/unit/util/partitions/partitions_spec.rb +67 -0
- data/spec/unit/util/partitions_spec.rb +19 -0
- data/spec/unit/util/posix_spec.rb +11 -0
- data/spec/unit/util/values_spec.rb +40 -0
- data/spec/unit/util/virtual_spec.rb +72 -2
- data/spec/unit/virtual_spec.rb +67 -18
- metadata +124 -54
- data/spec/fixtures/unit/util/loader/nosuchfact.rb +0 -1
@@ -4,6 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Resolution:
|
6
6
|
# Takes the first 2 elements of the kernel version as delimited by periods.
|
7
|
+
# Takes the first element of the kernel version on FreeBSD
|
7
8
|
#
|
8
9
|
# Caveats:
|
9
10
|
#
|
@@ -13,3 +14,10 @@ Facter.add("kernelmajversion") do
|
|
13
14
|
Facter.value(:kernelversion).split('.')[0..1].join('.')
|
14
15
|
end
|
15
16
|
end
|
17
|
+
|
18
|
+
Facter.add("kernelmajversion") do
|
19
|
+
confine :kernel => :FreeBSD
|
20
|
+
setcode do
|
21
|
+
Facter.value(:kernelversion).split('.')[0]
|
22
|
+
end
|
23
|
+
end
|
data/lib/facter/kernelrelease.rb
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# Caveats:
|
12
12
|
#
|
13
|
+
require 'facter/util/posix'
|
13
14
|
|
14
15
|
Facter.add(:kernelrelease) do
|
15
16
|
setcode 'uname -r'
|
@@ -20,6 +21,13 @@ Facter.add(:kernelrelease) do
|
|
20
21
|
setcode 'oslevel -s'
|
21
22
|
end
|
22
23
|
|
24
|
+
Facter.add("kernelrelease") do
|
25
|
+
confine :kernel => :openbsd
|
26
|
+
setcode do
|
27
|
+
Facter::Util::POSIX.sysctl("kern.version").split(' ')[1]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
23
31
|
Facter.add(:kernelrelease) do
|
24
32
|
confine :kernel => "hp-ux"
|
25
33
|
setcode do
|
data/lib/facter/memory.rb
CHANGED
@@ -82,15 +82,21 @@ end
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
Facter.add("SwapEncrypted") do
|
86
|
+
confine :kernel => :openbsd
|
87
|
+
setcode do
|
88
|
+
sysctl_encrypted = Facter::Util::POSIX.sysctl("vm.swapencrypt.enable").to_i
|
89
|
+
!(sysctl_encrypted.zero?)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Facter.add("SwapEncrypted") do
|
94
|
+
confine :kernel => :Darwin
|
95
|
+
setcode do
|
96
|
+
swap = Facter::Util::POSIX.sysctl('vm.swapusage')
|
97
|
+
encrypted = false
|
98
|
+
if swap =~ /\(encrypted\)/ then encrypted = true; end
|
99
|
+
encrypted
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
@@ -143,8 +149,8 @@ end
|
|
143
149
|
Facter.add("swapsize_mb") do
|
144
150
|
confine :kernel => :dragonfly
|
145
151
|
setcode do
|
146
|
-
page_size = Facter::
|
147
|
-
swaptotal = Facter::
|
152
|
+
page_size = Facter::Util::POSIX.sysctl("hw.pagesize").to_f
|
153
|
+
swaptotal = Facter::Util::POSIX.sysctl("vm.swap_size").to_f * page_size
|
148
154
|
"%.2f" % [(swaptotal.to_f / 1024.0) / 1024.0]
|
149
155
|
end
|
150
156
|
end
|
@@ -152,10 +158,10 @@ end
|
|
152
158
|
Facter.add("swapfree_mb") do
|
153
159
|
confine :kernel => :dragonfly
|
154
160
|
setcode do
|
155
|
-
page_size = Facter::
|
156
|
-
swaptotal = Facter::
|
157
|
-
swap_anon_use = Facter::
|
158
|
-
swap_cache_use = Facter::
|
161
|
+
page_size = Facter::Util::POSIX.sysctl("hw.pagesize").to_f
|
162
|
+
swaptotal = Facter::Util::POSIX.sysctl("vm.swap_size").to_f * page_size
|
163
|
+
swap_anon_use = Facter::Util::POSIX.sysctl("vm.swap_anon_use").to_f * page_size
|
164
|
+
swap_cache_use = Facter::Util::POSIX.sysctl("vm.swap_cache_use").to_f * page_size
|
159
165
|
swapfree = swaptotal - swap_anon_use - swap_cache_use
|
160
166
|
"%.2f" % [(swapfree.to_f / 1024.0) / 1024.0]
|
161
167
|
end
|
data/lib/facter/netmask.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
require 'facter/util/netmask'
|
17
17
|
|
18
18
|
Facter.add("netmask") do
|
19
|
-
confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly ]
|
19
|
+
confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly, :AIX ]
|
20
20
|
setcode do
|
21
21
|
Facter::NetMask.get_netmask
|
22
22
|
end
|
@@ -11,6 +11,8 @@
|
|
11
11
|
# Caveats:
|
12
12
|
#
|
13
13
|
|
14
|
+
require 'facter/util/operatingsystem'
|
15
|
+
|
14
16
|
Facter.add(:operatingsystem) do
|
15
17
|
confine :kernel => :sunos
|
16
18
|
setcode do
|
@@ -31,11 +33,27 @@ Facter.add(:operatingsystem) do
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
Facter.add(:operatingsystem) do
|
37
|
+
# Cumulus Linux is a variant of Debian so this resolution needs to come
|
38
|
+
# before the Debian resolution.
|
39
|
+
has_weight(10)
|
40
|
+
confine :kernel => :linux
|
41
|
+
|
42
|
+
setcode do
|
43
|
+
release_info = Facter::Util::Operatingsystem.os_release
|
44
|
+
if release_info['NAME'] == "Cumulus Linux"
|
45
|
+
'CumulusLinux'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
34
50
|
Facter.add(:operatingsystem) do
|
35
51
|
confine :kernel => :linux
|
36
52
|
setcode do
|
37
53
|
if Facter.value(:lsbdistid) == "Ubuntu"
|
38
54
|
"Ubuntu"
|
55
|
+
elsif Facter.value(:lsbdistid) == "LinuxMint"
|
56
|
+
"LinuxMint"
|
39
57
|
elsif FileTest.exists?("/etc/debian_version")
|
40
58
|
"Debian"
|
41
59
|
elsif FileTest.exists?("/etc/openwrt_release")
|
@@ -44,6 +62,8 @@ Facter.add(:operatingsystem) do
|
|
44
62
|
"Gentoo"
|
45
63
|
elsif FileTest.exists?("/etc/fedora-release")
|
46
64
|
"Fedora"
|
65
|
+
elsif FileTest.exists?("/etc/mageia-release")
|
66
|
+
"Mageia"
|
47
67
|
elsif FileTest.exists?("/etc/mandriva-release")
|
48
68
|
"Mandriva"
|
49
69
|
elsif FileTest.exists?("/etc/mandrake-release")
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# Caveats:
|
18
18
|
#
|
19
19
|
|
20
|
+
require 'facter/util/operatingsystem'
|
20
21
|
require 'facter/util/file_read'
|
21
22
|
|
22
23
|
Facter.add(:operatingsystemrelease) do
|
@@ -71,6 +72,24 @@ Facter.add(:operatingsystemrelease) do
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
75
|
+
Facter.add(:operatingsystemrelease) do
|
76
|
+
confine :operatingsystem => 'LinuxMint'
|
77
|
+
setcode do
|
78
|
+
if release = Facter::Util::FileRead.read('/etc/linuxmint/info')
|
79
|
+
if match = release.match(/RELEASE\=(\d+)/)
|
80
|
+
match[1]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Facter.add(:operatingsystemrelease) do
|
87
|
+
confine :operatingsystem => 'CumulusLinux'
|
88
|
+
setcode do
|
89
|
+
Facter::Util::Operatingsystem.os_release['VERSION_ID']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
74
93
|
Facter.add(:operatingsystemrelease) do
|
75
94
|
confine :operatingsystem => %w{SLES SLED OpenSuSE}
|
76
95
|
setcode do
|
data/lib/facter/osfamily.rb
CHANGED
@@ -18,7 +18,7 @@ Facter.add(:osfamily) do
|
|
18
18
|
case Facter.value(:operatingsystem)
|
19
19
|
when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer"
|
20
20
|
"RedHat"
|
21
|
-
when "Ubuntu", "Debian"
|
21
|
+
when "LinuxMint", "Ubuntu", "Debian", "CumulusLinux"
|
22
22
|
"Debian"
|
23
23
|
when "SLES", "SLED", "OpenSuSE", "SuSE"
|
24
24
|
"Suse"
|
@@ -28,6 +28,8 @@ Facter.add(:osfamily) do
|
|
28
28
|
"Gentoo"
|
29
29
|
when "Archlinux"
|
30
30
|
"Archlinux"
|
31
|
+
when "Mageia", "Mandriva", "Mandrake"
|
32
|
+
"Mandrake"
|
31
33
|
else
|
32
34
|
Facter.value("kernel")
|
33
35
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Fact: partitions
|
2
|
+
#
|
3
|
+
# Purpose:
|
4
|
+
# Return the details of the disk partitions
|
5
|
+
#
|
6
|
+
# Resolution:
|
7
|
+
# Parse the contents of /sys/block/<device>/size to receive the size (multiplying by 512 to correct for blocks-to-bytes)
|
8
|
+
#
|
9
|
+
# Caveats:
|
10
|
+
# Only supports Linux 2.6+ at this time, due to the reliance on sysfs
|
11
|
+
#
|
12
|
+
# Author: Chris Portman <chris@portman.net.au>
|
13
|
+
|
14
|
+
require 'facter'
|
15
|
+
require 'facter/util/partitions'
|
16
|
+
|
17
|
+
Facter.add(:partitions) do
|
18
|
+
confine do
|
19
|
+
Facter::Util::Partitions.available? ? true : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
setcode do
|
23
|
+
partitions = {}
|
24
|
+
Facter::Util::Partitions.list.each do |part|
|
25
|
+
details = {}
|
26
|
+
details['uuid'] = Facter::Util::Partitions.uuid(part)
|
27
|
+
details['size'] = Facter::Util::Partitions.size(part)
|
28
|
+
details['mount'] = Facter::Util::Partitions.mount(part)
|
29
|
+
details['filesystem'] = Facter::Util::Partitions.filesystem(part)
|
30
|
+
details.reject! {|k,v| v.nil? || v.to_s.empty? }
|
31
|
+
partitions[part] = details
|
32
|
+
end
|
33
|
+
partitions
|
34
|
+
end
|
35
|
+
end
|
@@ -9,6 +9,8 @@
|
|
9
9
|
#
|
10
10
|
# Caveats:
|
11
11
|
#
|
12
|
+
require 'facter/util/posix'
|
13
|
+
|
12
14
|
Facter.add('physicalprocessorcount') do
|
13
15
|
confine :kernel => :linux
|
14
16
|
|
@@ -80,3 +82,10 @@ Facter.add('physicalprocessorcount') do
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
85
|
+
|
86
|
+
Facter.add('physicalprocessorcount') do
|
87
|
+
confine :kernel => :openbsd
|
88
|
+
setcode do
|
89
|
+
Facter::Util::POSIX.sysctl("hw.ncpufound")
|
90
|
+
end
|
91
|
+
end
|
data/lib/facter/processor.rb
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
# On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor.
|
8
8
|
# On AIX, parse the output of 'lsdev' for its processor section.
|
9
9
|
# On Solaris, parse the output of 'kstat' for each processor.
|
10
|
-
# On OpenBSD, use
|
11
|
-
# count.
|
10
|
+
# On OpenBSD, use the sysctl variables 'hw.model' and 'hw.ncpu'
|
11
|
+
# for the CPU model and the CPU count respectively.
|
12
12
|
#
|
13
13
|
# Caveats:
|
14
14
|
#
|
@@ -21,6 +21,7 @@
|
|
21
21
|
|
22
22
|
require 'thread'
|
23
23
|
require 'facter/util/processor'
|
24
|
+
require 'facter/util/posix'
|
24
25
|
|
25
26
|
# We have to enumerate these outside a Facter.add block to get the processorN
|
26
27
|
# descriptions iteratively (but we need them inside the Facter.add block above
|
@@ -88,34 +89,29 @@ Facter.add("ProcessorCount") do
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
Facter.add("Processor") do
|
92
|
-
confine :kernel => :openbsd
|
93
|
-
setcode "uname -p"
|
94
|
-
end
|
95
|
-
|
96
92
|
Facter.add("ProcessorCount") do
|
97
93
|
confine :kernel => :Darwin
|
98
|
-
setcode
|
94
|
+
setcode do
|
95
|
+
Facter::Util::POSIX.sysctl("hw.ncpu")
|
96
|
+
end
|
99
97
|
end
|
100
98
|
|
101
99
|
if Facter.value(:kernel) == "windows"
|
102
100
|
processor_list = []
|
103
101
|
|
104
|
-
|
105
|
-
require 'facter/util/wmi'
|
102
|
+
require 'facter/util/wmi'
|
106
103
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
104
|
+
# get each physical processor
|
105
|
+
Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc|
|
106
|
+
# not supported before 2008
|
107
|
+
if proc.respond_to?(:NumberOfLogicalProcessors)
|
108
|
+
processor_num = proc.NumberOfLogicalProcessors
|
109
|
+
else
|
110
|
+
processor_num = 1
|
111
|
+
end
|
115
112
|
|
116
|
-
|
117
|
-
|
118
|
-
end
|
113
|
+
processor_num.times do |i|
|
114
|
+
processor_list << proc.Name.squeeze(" ")
|
119
115
|
end
|
120
116
|
end
|
121
117
|
|
@@ -137,13 +133,17 @@ if Facter.value(:kernel) == "windows"
|
|
137
133
|
end
|
138
134
|
|
139
135
|
Facter.add("Processor") do
|
140
|
-
confine :kernel => [:dragonfly,:freebsd]
|
141
|
-
setcode
|
136
|
+
confine :kernel => [:dragonfly,:freebsd,:openbsd]
|
137
|
+
setcode do
|
138
|
+
Facter::Util::POSIX.sysctl("hw.model")
|
139
|
+
end
|
142
140
|
end
|
143
141
|
|
144
142
|
Facter.add("ProcessorCount") do
|
145
143
|
confine :kernel => [:dragonfly,:freebsd,:openbsd]
|
146
|
-
setcode
|
144
|
+
setcode do
|
145
|
+
Facter::Util::POSIX.sysctl("hw.ncpu")
|
146
|
+
end
|
147
147
|
end
|
148
148
|
|
149
149
|
Facter.add("ProcessorCount") do
|
@@ -153,7 +153,7 @@ Facter.add("ProcessorCount") do
|
|
153
153
|
(major_version, minor_version) = kernelrelease.split(".").map { |str| str.to_i }
|
154
154
|
result = nil
|
155
155
|
|
156
|
-
if (major_version
|
156
|
+
if (major_version < 5) or (major_version == 5 and minor_version < 8) then
|
157
157
|
if kstat = Facter::Core::Execution.exec("/usr/bin/kstat cpu_info")
|
158
158
|
result = kstat.scan(/\bcore_id\b\s+\d+/).uniq.length
|
159
159
|
end
|
data/lib/facter/util/config.rb
CHANGED
@@ -45,8 +45,10 @@ module Facter::Util::Config
|
|
45
45
|
else
|
46
46
|
@external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
|
47
47
|
end
|
48
|
+
elsif ENV['HOME']
|
49
|
+
@external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))]
|
48
50
|
else
|
49
|
-
@external_facts_dirs = [
|
51
|
+
@external_facts_dirs = []
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'facter/util/file_read'
|
2
|
+
|
3
|
+
module Facter::Util::DHCPServers
|
4
|
+
def self.gateway_device
|
5
|
+
interface = nil
|
6
|
+
if routes = Facter::Util::FileRead.read('/proc/net/route')
|
7
|
+
routes.each_line do |line|
|
8
|
+
device, destination = line.split(' ')
|
9
|
+
if destination == '00000000'
|
10
|
+
interface = device
|
11
|
+
break
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
interface
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.devices
|
19
|
+
if Facter::Core::Execution.which('nmcli')
|
20
|
+
Facter::Core::Execution.exec("nmcli d").split("\n").select {|d| d =~ /\sconnected/i }.collect{ |line| line.split[0] }
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.device_dhcp_server(device)
|
27
|
+
if Facter::Core::Execution.which('nmcli')
|
28
|
+
version = self.nmcli_version
|
29
|
+
# If the version is >= 0.9.9, use show instead of list
|
30
|
+
if version && version[0] > 0 || version[1] > 9 || (version[1] == 9 && version[2] >= 9)
|
31
|
+
Facter::Core::Execution.exec("nmcli -f all d show #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
|
32
|
+
else
|
33
|
+
Facter::Core::Execution.exec("nmcli -f all d list iface #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.nmcli_version
|
39
|
+
if version = Facter::Core::Execution.exec("nmcli --version")
|
40
|
+
version.scan(/version\s(\d+)\.?(\d+)?\.?(\d+)?\.?(\d+)?/).flatten.map(&:to_i)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/facter/util/ec2.rb
CHANGED
@@ -11,6 +11,7 @@ module Facter::Util::EC2
|
|
11
11
|
# The +wait_sec+ parameter provides you with an adjustable timeout.
|
12
12
|
#
|
13
13
|
def can_connect?(wait_sec=2)
|
14
|
+
Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
|
14
15
|
url = "http://169.254.169.254:80/"
|
15
16
|
Timeout::timeout(wait_sec) {open(url)}
|
16
17
|
return true
|
@@ -23,6 +24,7 @@ module Facter::Util::EC2
|
|
23
24
|
# Test if this host has a mac address used by Eucalyptus clouds, which
|
24
25
|
# normally is +d0:0d+.
|
25
26
|
def has_euca_mac?
|
27
|
+
Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
|
26
28
|
!!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:})
|
27
29
|
end
|
28
30
|
|
@@ -30,12 +32,14 @@ module Facter::Util::EC2
|
|
30
32
|
# normally starts with FA:16:3E (older versions of OpenStack
|
31
33
|
# may generate mac addresses starting with 02:16:3E)
|
32
34
|
def has_openstack_mac?
|
35
|
+
Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
|
33
36
|
!!(Facter.value(:macaddress) =~ %r{^(02|[fF][aA]):16:3[eE]})
|
34
37
|
end
|
35
38
|
|
36
39
|
# Test if the host has an arp entry in its cache that matches the EC2 arp,
|
37
40
|
# which is normally +fe:ff:ff:ff:ff:ff+.
|
38
41
|
def has_ec2_arp?
|
42
|
+
Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
|
39
43
|
kernel = Facter.value(:kernel)
|
40
44
|
|
41
45
|
mac_address_re = case kernel
|
@@ -73,6 +77,7 @@ module Facter::Util::EC2
|
|
73
77
|
#
|
74
78
|
# @return [String] containing the response body or `nil`
|
75
79
|
def self.userdata(version="latest")
|
80
|
+
Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
|
76
81
|
uri = "http://169.254.169.254/#{version}/user-data/"
|
77
82
|
begin
|
78
83
|
read_uri(uri)
|