facter 1.7.1 → 1.7.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/Rakefile +3 -3
- data/ext/build_defaults.yaml +2 -2
- data/lib/facter/domain.rb +13 -8
- data/lib/facter/ipaddress.rb +7 -3
- data/lib/facter/util/file_read.rb +4 -0
- data/lib/facter/util/ip.rb +1 -1
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/resolution.rb +1 -1
- data/lib/facter/util/virtual.rb +5 -2
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +94 -107
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em1 +10 -0
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo +8 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt +20 -0
- data/spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries +0 -0
- data/spec/shared_formats/parses.rb +3 -0
- data/spec/unit/domain_spec.rb +139 -104
- data/spec/unit/interfaces_spec.rb +26 -0
- data/spec/unit/ipaddress_spec.rb +4 -0
- data/spec/unit/netmask_spec.rb +29 -0
- data/spec/unit/util/resolution_spec.rb +1 -1
- data/spec/unit/util/virtual_spec.rb +9 -0
- data/spec/unit/virtual_spec.rb +7 -0
- metadata +23 -5
data/Rakefile
CHANGED
@@ -6,7 +6,10 @@ require 'facter/version'
|
|
6
6
|
|
7
7
|
$LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
|
8
8
|
|
9
|
+
require 'rake'
|
10
|
+
|
9
11
|
begin
|
12
|
+
load File.join(File.dirname(__FILE__), 'ext', 'packaging', 'packaging.rake')
|
10
13
|
require 'rubygems'
|
11
14
|
require 'rspec'
|
12
15
|
require 'rspec/core/rake_task'
|
@@ -14,10 +17,7 @@ begin
|
|
14
17
|
rescue LoadError
|
15
18
|
end
|
16
19
|
|
17
|
-
require 'rake'
|
18
|
-
|
19
20
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
20
|
-
Dir['ext/packaging/tasks/**/*'].sort.each { |t| load t }
|
21
21
|
|
22
22
|
build_defs_file = 'ext/build_defaults.yaml'
|
23
23
|
if File.exist?(build_defs_file)
|
data/ext/build_defaults.yaml
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
|
3
3
|
packaging_repo: 'packaging'
|
4
4
|
default_cow: 'base-squeeze-i386.cow'
|
5
|
-
cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-
|
5
|
+
cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-raring-i386.cow base-raring-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow'
|
6
6
|
pbuild_conf: '/etc/pbuilderrc'
|
7
7
|
packager: 'puppetlabs'
|
8
8
|
gpg_name: 'info@puppetlabs.com'
|
9
9
|
gpg_key: '4BD6EC30'
|
10
10
|
sign_tar: FALSE
|
11
11
|
# a space separated list of mock configs
|
12
|
-
final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-fedora-
|
12
|
+
final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-fedora-17-i386 pl-fedora-17-x86_64 pl-fedora-18-i386 pl-fedora-18-x86_64'
|
13
13
|
yum_host: 'burji.puppetlabs.com'
|
14
14
|
yum_repo_path: '/opt/repository/yum/'
|
15
15
|
build_gem: TRUE
|
data/lib/facter/domain.rb
CHANGED
@@ -23,21 +23,26 @@ Facter.add(:domain) do
|
|
23
23
|
# Get the domain from various sources; the order of these
|
24
24
|
# steps is important
|
25
25
|
|
26
|
-
# In some OS 'hostname -f' will change the hostname to '-f'
|
27
|
-
# We know that Solaris and HP-UX exhibit this behavior
|
28
|
-
# On good OS, 'hostname -f' will return the FQDN which is preferable
|
29
|
-
# Due to dangerous behavior of 'hostname -f' on old OS, we will explicitly opt-in
|
26
|
+
# In some OS 'hostname -f' will change the hostname to '-f'
|
27
|
+
# We know that Solaris and HP-UX exhibit this behavior
|
28
|
+
# On good OS, 'hostname -f' will return the FQDN which is preferable
|
29
|
+
# Due to dangerous behavior of 'hostname -f' on old OS, we will explicitly opt-in
|
30
30
|
# 'hostname -f' --hkenney May 9, 2012
|
31
|
-
|
31
|
+
basic_hostname = 'hostname 2> /dev/null'
|
32
|
+
full_hostname = 'hostname -f 2> /dev/null'
|
32
33
|
can_do_hostname_f = Regexp.union /Linux/i, /FreeBSD/i, /Darwin/i
|
33
|
-
hostname_command = 'hostname -f' if Facter.value(:kernel) =~ can_do_hostname_f
|
34
34
|
|
35
|
-
|
35
|
+
hostname_command = if Facter.value(:kernel) =~ can_do_hostname_f
|
36
|
+
full_hostname
|
37
|
+
else
|
38
|
+
basic_hostname
|
39
|
+
end
|
40
|
+
|
36
41
|
if name = Facter::Util::Resolution.exec(hostname_command) \
|
37
42
|
and name =~ /.*?\.(.+$)/
|
38
43
|
|
39
44
|
return_value = $1
|
40
|
-
elsif domain = Facter::Util::Resolution.exec('dnsdomainname') \
|
45
|
+
elsif domain = Facter::Util::Resolution.exec('dnsdomainname 2> /dev/null') \
|
41
46
|
and domain =~ /.+/
|
42
47
|
|
43
48
|
return_value = domain
|
data/lib/facter/ipaddress.rb
CHANGED
@@ -28,10 +28,14 @@ Facter.add(:ipaddress) do
|
|
28
28
|
confine :kernel => :linux
|
29
29
|
setcode do
|
30
30
|
ip = nil
|
31
|
-
|
31
|
+
output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
|
32
|
+
if output
|
32
33
|
regexp = /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
33
|
-
|
34
|
-
match
|
34
|
+
output.split("\n").each do |line|
|
35
|
+
match = regexp.match(line)
|
36
|
+
if match
|
37
|
+
break match[1] unless /^127/.match(match[1])
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
data/lib/facter/util/ip.rb
CHANGED
@@ -8,7 +8,7 @@ module Facter::Util::IP
|
|
8
8
|
:ipaddress => /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
|
9
9
|
:ipaddress6 => /inet6 (?:addr: )?((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
|
10
10
|
:macaddress => /(?:ether|HWaddr)\s+((\w{1,2}:){5,}\w{1,2})/,
|
11
|
-
:netmask => /Mask
|
11
|
+
:netmask => /(?:Mask:|netmask )([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
|
12
12
|
:mtu => /MTU:(\d+)/
|
13
13
|
},
|
14
14
|
:bsd => {
|
data/lib/facter/util/netmask.rb
CHANGED
@@ -8,7 +8,7 @@ module Facter::NetMask
|
|
8
8
|
when 'Linux'
|
9
9
|
ops = {
|
10
10
|
:ifconfig_opts => ['2>/dev/null'],
|
11
|
-
:regex => %r{
|
11
|
+
:regex => %r{#{Facter.ipaddress}.*?(?:Mask:|netmask)\s*(#{ipregex})}x,
|
12
12
|
:munge => nil,
|
13
13
|
}
|
14
14
|
when 'SunOS'
|
@@ -169,7 +169,7 @@ class Facter::Util::Resolution
|
|
169
169
|
|
170
170
|
begin
|
171
171
|
out = %x{#{code}}.chomp
|
172
|
-
Facter.warnonce
|
172
|
+
Facter.warnonce "Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass \"cmd /c your_builtin\" as a command (command responsible for this message was \"#{code}\")" unless expanded_code
|
173
173
|
rescue Errno::ENOENT => detail
|
174
174
|
# command not found on Windows
|
175
175
|
return nil
|
data/lib/facter/util/virtual.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'facter/util/file_read'
|
2
|
+
|
1
3
|
module Facter::Util::Virtual
|
2
4
|
##
|
3
5
|
# virt_what is a delegating helper method intended to make it easier to stub
|
@@ -63,7 +65,8 @@ module Facter::Util::Virtual
|
|
63
65
|
return false unless FileTest.exists?("/proc/self/status")
|
64
66
|
txt = File.open("/proc/self/status", "rb").read
|
65
67
|
if txt.respond_to?(:encode!)
|
66
|
-
txt.encode!('UTF-
|
68
|
+
txt.encode!('UTF-16', 'UTF-8', :invalid => :replace)
|
69
|
+
txt.encode!('UTF-8', 'UTF-16')
|
67
70
|
end
|
68
71
|
return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/
|
69
72
|
return false
|
@@ -142,7 +145,7 @@ module Facter::Util::Virtual
|
|
142
145
|
# @return [String] or nil if the path does not exist
|
143
146
|
def self.read_sysfs_dmi_entries(path="/sys/firmware/dmi/entries/1-0/raw")
|
144
147
|
if File.exists?(path)
|
145
|
-
|
148
|
+
Facter::Util::FileRead.read_binary(path)
|
146
149
|
end
|
147
150
|
end
|
148
151
|
end
|
data/lib/facter/version.rb
CHANGED
data/lib/facter/virtual.rb
CHANGED
@@ -44,129 +44,116 @@ Facter.add("virtual") do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
47
|
Facter.add("virtual") do
|
49
|
-
confine :kernel =>
|
50
|
-
|
51
|
-
result = "physical"
|
48
|
+
confine :kernel => ["FreeBSD", "GNU/kFreeBSD"]
|
52
49
|
|
53
50
|
setcode do
|
51
|
+
"jail" if Facter::Util::Virtual.jail?
|
52
|
+
end
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
if Facter.value(:kernel)=="HP-UX"
|
60
|
-
result = "hpvm" if Facter::Util::Virtual.hpvm?
|
61
|
-
end
|
62
|
-
|
63
|
-
if Facter.value(:architecture)=="s390x"
|
64
|
-
result = "zlinux" if Facter::Util::Virtual.zlinux?
|
65
|
-
end
|
66
|
-
|
67
|
-
if Facter::Util::Virtual.openvz?
|
68
|
-
result = Facter::Util::Virtual.openvz_type()
|
69
|
-
end
|
55
|
+
Facter.add("virtual") do
|
56
|
+
confine :kernel => 'SunOS'
|
70
57
|
|
71
|
-
|
72
|
-
|
58
|
+
setcode do
|
59
|
+
next "zone" if Facter::Util::Virtual.zone?
|
60
|
+
|
61
|
+
resolver = Facter::Util::Resolution.new('prtdiag')
|
62
|
+
resolver.timeout = 6
|
63
|
+
resolver.setcode('prtdiag')
|
64
|
+
output = resolver.value
|
65
|
+
if output
|
66
|
+
lines = output.split("\n")
|
67
|
+
next "parallels" if lines.any? {|l| l =~ /Parallels/ }
|
68
|
+
next "vmware" if lines.any? {|l| l =~ /VM[wW]are/ }
|
69
|
+
next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ }
|
70
|
+
next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ }
|
73
71
|
end
|
72
|
+
end
|
73
|
+
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
result = "xen0"
|
78
|
-
elsif FileTest.exists?("/proc/xen")
|
79
|
-
result = "xenu"
|
80
|
-
end
|
81
|
-
end
|
75
|
+
Facter.add("virtual") do
|
76
|
+
confine :kernel => 'HP-UX'
|
82
77
|
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
setcode do
|
79
|
+
"hpvm" if Facter::Util::Virtual.hpvm?
|
80
|
+
end
|
81
|
+
end
|
86
82
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
83
|
+
Facter.add("virtual") do
|
84
|
+
confine :architecture => 's390x'
|
90
85
|
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
setcode do
|
87
|
+
"zlinux" if Facter::Util::Virtual.zlinux?
|
88
|
+
end
|
89
|
+
end
|
94
90
|
|
95
|
-
|
96
|
-
|
97
|
-
end
|
91
|
+
Facter.add("virtual") do
|
92
|
+
confine :kernel => 'OpenBSD'
|
98
93
|
|
99
|
-
|
100
|
-
|
94
|
+
setcode do
|
95
|
+
output = Facter::Util::Resolution.exec('sysctl -n hw.product 2>/dev/null')
|
96
|
+
if output
|
97
|
+
lines = output.split("\n")
|
98
|
+
next "parallels" if lines.any? {|l| l =~ /Parallels/ }
|
99
|
+
next "vmware" if lines.any? {|l| l =~ /VMware/ }
|
100
|
+
next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ }
|
101
|
+
next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ }
|
101
102
|
end
|
103
|
+
end
|
104
|
+
end
|
102
105
|
|
103
|
-
|
104
|
-
|
105
|
-
if not output.nil?
|
106
|
-
output.each_line do |p|
|
107
|
-
# --- look for the vmware video card to determine if it is virtual => vmware.
|
108
|
-
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
|
109
|
-
result = "vmware" if p =~ /VM[wW]are/
|
110
|
-
# --- look for virtualbox video card to determine if it is virtual => virtualbox.
|
111
|
-
# --- 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
|
112
|
-
result = "virtualbox" if p =~ /VirtualBox/
|
113
|
-
# --- look for pci vendor id used by Parallels video card
|
114
|
-
# --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
|
115
|
-
result = "parallels" if p =~ /1ab8:|[Pp]arallels/
|
116
|
-
# --- look for pci vendor id used by Xen HVM device
|
117
|
-
# --- 00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)
|
118
|
-
result = "xenhvm" if p =~ /XenSource/
|
119
|
-
# --- look for Hyper-V video card
|
120
|
-
# --- 00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA
|
121
|
-
result = "hyperv" if p =~ /Microsoft Corporation Hyper-V/
|
122
|
-
# --- look for gmetrics for GCE
|
123
|
-
# --- 00:05.0 Class 8007: Google, Inc. Device 6442
|
124
|
-
result = "gce" if p =~ /Class 8007: Google, Inc/
|
125
|
-
end
|
126
|
-
else
|
127
|
-
output = Facter::Util::Resolution.exec('dmidecode')
|
128
|
-
if not output.nil?
|
129
|
-
output.each_line do |pd|
|
130
|
-
result = "parallels" if pd =~ /Parallels/
|
131
|
-
result = "vmware" if pd =~ /VMware/
|
132
|
-
result = "virtualbox" if pd =~ /VirtualBox/
|
133
|
-
result = "xenhvm" if pd =~ /HVM domU/
|
134
|
-
result = "hyperv" if pd =~ /Product Name: Virtual Machine/
|
135
|
-
result = "rhev" if pd =~ /Product Name: RHEV Hypervisor/
|
136
|
-
result = "ovirt" if pd =~ /Product Name: oVirt Node/
|
137
|
-
end
|
138
|
-
elsif Facter.value(:kernel) == 'SunOS'
|
139
|
-
res = Facter::Util::Resolution.new('prtdiag')
|
140
|
-
res.timeout = 6
|
141
|
-
res.setcode('prtdiag')
|
142
|
-
output = res.value
|
143
|
-
if not output.nil?
|
144
|
-
output.each_line do |pd|
|
145
|
-
result = "parallels" if pd =~ /Parallels/
|
146
|
-
result = "vmware" if pd =~ /VMware/
|
147
|
-
result = "virtualbox" if pd =~ /VirtualBox/
|
148
|
-
result = "xenhvm" if pd =~ /HVM domU/
|
149
|
-
end
|
150
|
-
end
|
151
|
-
elsif Facter.value(:kernel) == 'OpenBSD'
|
152
|
-
output = Facter::Util::Resolution.exec('sysctl -n hw.product 2>/dev/null')
|
153
|
-
if not output.nil?
|
154
|
-
output.each_line do |pd|
|
155
|
-
result = "parallels" if pd =~ /Parallels/
|
156
|
-
result = "vmware" if pd =~ /VMware/
|
157
|
-
result = "virtualbox" if pd =~ /VirtualBox/
|
158
|
-
result = "xenhvm" if pd =~ /HVM domU/
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
106
|
+
Facter.add("virtual") do
|
107
|
+
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX GNU/kFreeBSD}
|
163
108
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
109
|
+
setcode do
|
110
|
+
next Facter::Util::Virtual.openvz_type if Facter::Util::Virtual.openvz?
|
111
|
+
next Facter::Util::Virtual.vserver_type if Facter::Util::Virtual.vserver?
|
168
112
|
|
169
|
-
|
113
|
+
if Facter::Util::Virtual.xen?
|
114
|
+
next "xen0" if FileTest.exists?("/dev/xen/evtchn")
|
115
|
+
next "xenu" if FileTest.exists?("/proc/xen")
|
116
|
+
end
|
117
|
+
|
118
|
+
next "virtualbox" if Facter::Util::Virtual.virtualbox?
|
119
|
+
next Facter::Util::Virtual.kvm_type if Facter::Util::Virtual.kvm?
|
120
|
+
next "rhev" if Facter::Util::Virtual.rhev?
|
121
|
+
next "ovirt" if Facter::Util::Virtual.ovirt?
|
122
|
+
|
123
|
+
# Parse lspci
|
124
|
+
output = Facter::Util::Virtual.lspci
|
125
|
+
if output
|
126
|
+
lines = output.split("\n")
|
127
|
+
next "vmware" if lines.any? {|l| l =~ /VM[wW]are/ }
|
128
|
+
next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ }
|
129
|
+
next "parallels" if lines.any? {|l| l =~ /1ab8:|[Pp]arallels/ }
|
130
|
+
next "xenhvm" if lines.any? {|l| l =~ /XenSource/ }
|
131
|
+
next "hyperv" if lines.any? {|l| l =~ /Microsoft Corporation Hyper-V/ }
|
132
|
+
next "gce" if lines.any? {|l| l =~ /Class 8007: Google, Inc/ }
|
133
|
+
end
|
134
|
+
|
135
|
+
# Parse dmidecode
|
136
|
+
output = Facter::Util::Resolution.exec('dmidecode')
|
137
|
+
if output
|
138
|
+
lines = output.split("\n")
|
139
|
+
next "parallels" if lines.any? {|l| l =~ /Parallels/ }
|
140
|
+
next "vmware" if lines.any? {|l| l =~ /VMware/ }
|
141
|
+
next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ }
|
142
|
+
next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ }
|
143
|
+
next "hyperv" if lines.any? {|l| l =~ /Product Name: Virtual Machine/ }
|
144
|
+
next "rhev" if lines.any? {|l| l =~ /Product Name: RHEV Hypervisor/ }
|
145
|
+
next "ovirt" if lines.any? {|l| l =~ /Product Name: oVirt Node/ }
|
146
|
+
end
|
147
|
+
|
148
|
+
# Sample output of vmware -v `VMware Server 1.0.5 build-80187`
|
149
|
+
output = Facter::Util::Resolution.exec("vmware -v")
|
150
|
+
if output
|
151
|
+
mdata = output.match /(\S+)\s+(\S+)/
|
152
|
+
next "#{mdata[1]}_#{mdata[2]}".downcase if mdata
|
153
|
+
end
|
154
|
+
|
155
|
+
# Default to 'physical'
|
156
|
+
next 'physical'
|
170
157
|
end
|
171
158
|
end
|
172
159
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
2
|
+
inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255
|
3
|
+
inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0<global>
|
4
|
+
inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20<link>
|
5
|
+
ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet)
|
6
|
+
RX packets 27222144 bytes 31247414760 (29.1 GiB)
|
7
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
8
|
+
TX packets 10259038 bytes 7784519352 (7.2 GiB)
|
9
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
10
|
+
device interrupt 20 memory 0xd2600000-d2620000
|
11
|
+
|
12
|
+
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
|
13
|
+
inet 127.0.0.1 netmask 255.0.0.0
|
14
|
+
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
15
|
+
loop txqueuelen 0 (Local Loopback)
|
16
|
+
RX packets 257371 bytes 37104110 (35.3 MiB)
|
17
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
18
|
+
TX packets 257371 bytes 37104110 (35.3 MiB)
|
19
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@@ -0,0 +1,10 @@
|
|
1
|
+
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
2
|
+
inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255
|
3
|
+
inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0<global>
|
4
|
+
inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20<link>
|
5
|
+
ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet)
|
6
|
+
RX packets 27222144 bytes 31247414760 (29.1 GiB)
|
7
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
8
|
+
TX packets 10259038 bytes 7784519352 (7.2 GiB)
|
9
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
10
|
+
device interrupt 20 memory 0xd2600000-d2620000
|
@@ -0,0 +1,8 @@
|
|
1
|
+
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
|
2
|
+
inet 127.0.0.1 netmask 255.0.0.0
|
3
|
+
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
4
|
+
loop txqueuelen 0 (Local Loopback)
|
5
|
+
RX packets 257371 bytes 37104110 (35.3 MiB)
|
6
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
7
|
+
TX packets 257371 bytes 37104110 (35.3 MiB)
|
8
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
lo Link encap:Local Loopback
|
2
|
+
inet addr:127.0.0.1 Mask:255.0.0.0
|
3
|
+
inet6 addr: ::1/128 Scope:Host
|
4
|
+
UP LOOPBACK RUNNING MTU:16436 Metric:1
|
5
|
+
RX packets:9031461 errors:0 dropped:0 overruns:0 frame:0
|
6
|
+
TX packets:9031461 errors:0 dropped:0 overruns:0 carrier:0
|
7
|
+
collisions:0 txqueuelen:0
|
8
|
+
RX bytes:3205490447 (2.9 GiB) TX bytes:3205490447 (2.9 GiB)
|
9
|
+
|
10
|
+
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
|
11
|
+
inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255
|
12
|
+
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
|
13
|
+
RX packets:38161277 errors:0 dropped:0 overruns:0 frame:0
|
14
|
+
TX packets:24601924 errors:0 dropped:0 overruns:0 carrier:0
|
15
|
+
collisions:0 txqueuelen:0
|
16
|
+
RX bytes:3847964603 (3.5 GiB) TX bytes:5770630041 (5.3 GiB)
|
17
|
+
|
18
|
+
venet0:1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
|
19
|
+
inet addr:10.0.222.20 P-t-P:10.0.222.20 Bcast:10.0.222.20 Mask:255.255.255.255
|
20
|
+
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
|
@@ -0,0 +1,19 @@
|
|
1
|
+
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
2
|
+
inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255
|
3
|
+
inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0<global>
|
4
|
+
inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20<link>
|
5
|
+
ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet)
|
6
|
+
RX packets 27222144 bytes 31247414760 (29.1 GiB)
|
7
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
8
|
+
TX packets 10259038 bytes 7784519352 (7.2 GiB)
|
9
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
10
|
+
device interrupt 20 memory 0xd2600000-d2620000
|
11
|
+
|
12
|
+
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
|
13
|
+
inet 127.0.0.1 netmask 255.0.0.0
|
14
|
+
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
15
|
+
loop txqueuelen 0 (Local Loopback)
|
16
|
+
RX packets 257371 bytes 37104110 (35.3 MiB)
|
17
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
18
|
+
TX packets 257371 bytes 37104110 (35.3 MiB)
|
19
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
eth0 Link encap:Ethernet HWaddr 42:01:0a:57:50:6e
|
2
|
+
inet addr:10.87.80.110 Bcast:10.87.80.110 Mask:255.255.255.255
|
3
|
+
UP BROADCAST RUNNING MULTICAST MTU:1460 Metric:1
|
4
|
+
RX packets:1609444 errors:0 dropped:0 overruns:0 frame:0
|
5
|
+
TX packets:1479569 errors:0 dropped:0 overruns:0 carrier:0
|
6
|
+
collisions:0 txqueuelen:1000
|
7
|
+
RX bytes:673812693 (673.8 MB) TX bytes:221186872 (221.1 MB)
|
8
|
+
|
9
|
+
lo Link encap:Local Loopback
|
10
|
+
inet addr:127.0.0.1 Mask:255.0.0.0
|
11
|
+
UP LOOPBACK RUNNING MTU:16436 Metric:1
|
12
|
+
RX packets:5435415 errors:0 dropped:0 overruns:0 frame:0
|
13
|
+
TX packets:5435415 errors:0 dropped:0 overruns:0 carrier:0
|
14
|
+
collisions:0 txqueuelen:0
|
15
|
+
RX bytes:734540224 (734.5 MB) TX bytes:734540224 (734.5 MB)
|
16
|
+
|
Binary file
|
data/spec/unit/domain_spec.rb
CHANGED
@@ -1,97 +1,101 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'stringio'
|
4
5
|
|
5
6
|
describe "Domain name facts" do
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
:
|
10
|
-
:
|
11
|
-
|
12
|
-
|
8
|
+
def resolv_conf_contains(*lines)
|
9
|
+
file_handle = StringIO.new(lines.join("\n"))
|
10
|
+
FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(true)
|
11
|
+
File.stubs(:open).with("/etc/resolv.conf").yields(file_handle)
|
12
|
+
end
|
13
|
+
|
14
|
+
[
|
15
|
+
{ :kernel => "Linux", :hostname_command => "hostname -f 2> /dev/null" },
|
16
|
+
{ :kernel => "SunOS", :hostname_command => "hostname 2> /dev/null" },
|
17
|
+
{ :kernel => "Darwin", :hostname_command => "hostname -f 2> /dev/null" },
|
18
|
+
{ :kernel => "FreeBSD", :hostname_command => "hostname -f 2> /dev/null" },
|
19
|
+
{ :kernel => "HP-UX", :hostname_command => "hostname 2> /dev/null" },
|
20
|
+
].each do |scenario|
|
21
|
+
|
22
|
+
describe "on #{scenario[:kernel]}" do
|
23
|
+
let(:hostname_command) { scenario[:hostname_command] }
|
24
|
+
let(:dnsdomain_command) { "dnsdomainname 2> /dev/null" }
|
25
|
+
|
26
|
+
def the_hostname_is(value)
|
27
|
+
Facter::Util::Resolution.stubs(:exec).with(hostname_command).returns(value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def the_dnsdomainname_is(value)
|
31
|
+
Facter::Util::Resolution.stubs(:exec).with(dnsdomain_command).returns(value)
|
32
|
+
end
|
13
33
|
|
14
|
-
describe "on #{key}" do
|
15
34
|
before do
|
16
|
-
Facter.fact(:kernel).stubs(:value).returns(
|
17
|
-
FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(true)
|
35
|
+
Facter.fact(:kernel).stubs(:value).returns(scenario[:kernel])
|
18
36
|
end
|
19
|
-
|
20
|
-
let :hostname_command do
|
21
|
-
nested_hash[:hostname_command]
|
22
|
-
end
|
23
|
-
|
37
|
+
|
24
38
|
it "should use the hostname binary" do
|
25
|
-
|
39
|
+
the_hostname_is("test.example.com")
|
40
|
+
|
26
41
|
Facter.fact(:domain).value.should == "example.com"
|
27
42
|
end
|
28
|
-
|
43
|
+
|
29
44
|
it "should fall back to the dnsdomainname binary" do
|
30
|
-
|
31
|
-
|
45
|
+
the_hostname_is("myhost")
|
46
|
+
the_dnsdomainname_is("example.com")
|
47
|
+
|
32
48
|
Facter.fact(:domain).value.should == "example.com"
|
33
49
|
end
|
34
|
-
|
35
|
-
|
50
|
+
|
36
51
|
it "should fall back to /etc/resolv.conf" do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
it "should attempt to resolve facts in a specific order" do
|
44
|
-
seq = sequence('domain')
|
45
|
-
Facter::Util::Resolution.stubs(:exec).with(hostname_command).in_sequence(seq).at_least_once
|
46
|
-
Facter::Util::Resolution.stubs(:exec).with("dnsdomainname").in_sequence(seq).at_least_once
|
47
|
-
File.expects(:open).with('/etc/resolv.conf').in_sequence(seq).at_least_once
|
48
|
-
Facter.fact(:domain).value
|
52
|
+
the_hostname_is("myhost")
|
53
|
+
the_dnsdomainname_is("")
|
54
|
+
|
55
|
+
resolv_conf_contains("domain testing.com")
|
56
|
+
|
57
|
+
Facter.fact(:domain).value.should == "testing.com"
|
49
58
|
end
|
50
|
-
|
51
|
-
describe "Top level domain" do
|
59
|
+
|
60
|
+
describe "Top level domain" do
|
52
61
|
it "should find the domain name" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
62
|
+
the_hostname_is("ns01.tld")
|
63
|
+
|
64
|
+
Facter.fact(:domain).value.should == "tld"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
60
68
|
describe "when using /etc/resolv.conf" do
|
61
69
|
before do
|
62
|
-
|
63
|
-
|
64
|
-
@mock_file = mock()
|
65
|
-
File.stubs(:open).with("/etc/resolv.conf").yields(@mock_file)
|
70
|
+
the_hostname_is("")
|
71
|
+
the_dnsdomainname_is("")
|
66
72
|
end
|
67
|
-
|
73
|
+
|
68
74
|
it "should use the domain field over the search field" do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
resolv_conf_contains(
|
76
|
+
"nameserver 4.2.2.1",
|
77
|
+
"search example.org",
|
78
|
+
"domain example.com"
|
79
|
+
)
|
80
|
+
|
75
81
|
Facter.fact(:domain).value.should == 'example.com'
|
76
82
|
end
|
77
83
|
|
78
84
|
it "should fall back to the search field" do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
85
|
+
resolv_conf_contains(
|
86
|
+
"nameserver 4.2.2.1",
|
87
|
+
"search example.org"
|
88
|
+
)
|
89
|
+
|
84
90
|
Facter.fact(:domain).value.should == 'example.org'
|
85
91
|
end
|
86
|
-
|
92
|
+
|
87
93
|
it "should use the first domain in the search field" do
|
88
|
-
|
89
|
-
|
90
|
-
]
|
91
|
-
@mock_file.expects(:each).multiple_yields(*lines)
|
94
|
+
resolv_conf_contains("search example.org example.net")
|
95
|
+
|
92
96
|
Facter.fact(:domain).value.should == 'example.org'
|
93
97
|
end
|
94
|
-
|
98
|
+
|
95
99
|
# Test permutations of domain and search, where 'domain' can be a value of
|
96
100
|
# the search keyword and the domain keyword
|
97
101
|
# and also where 'search' can be a value of the search keyword and the
|
@@ -107,29 +111,27 @@ describe "Domain name facts" do
|
|
107
111
|
# Why someone would have their machines named 'www.domain' or 'www.search', I
|
108
112
|
# don't know, but we'll at least handle it properly
|
109
113
|
[
|
110
|
-
["domain domain", "domain"],
|
111
|
-
["domain search", "search"],
|
112
|
-
["search domain", "domain"],
|
113
|
-
["search search", "search"],
|
114
|
-
["search domain notdomain", "domain"],
|
115
|
-
[["#search notdomain","search search"], "search"],
|
116
|
-
[["# search notdomain","search search"], "search"],
|
117
|
-
[["#domain notdomain","domain domain"], "domain"],
|
118
|
-
[["# domain notdomain","domain domain"], "domain"],
|
114
|
+
[["domain domain"], "domain"],
|
115
|
+
[["domain search"], "search"],
|
116
|
+
[["search domain"], "domain"],
|
117
|
+
[["search search"], "search"],
|
118
|
+
[["search domain notdomain"], "domain"],
|
119
|
+
[["#search notdomain", "search search"], "search"],
|
120
|
+
[["# search notdomain", "search search"], "search"],
|
121
|
+
[["#domain notdomain", "domain domain"], "domain"],
|
122
|
+
[["# domain notdomain", "domain domain"], "domain"],
|
119
123
|
].each do |tuple|
|
120
|
-
|
124
|
+
conf = tuple[0]
|
121
125
|
expect = tuple[1]
|
122
|
-
it "should return #{expect} from \"#{
|
123
|
-
|
124
|
-
|
125
|
-
].flatten
|
126
|
-
@mock_file.expects(:each).multiple_yields(*lines)
|
126
|
+
it "should return #{expect} from \"#{conf}\"" do
|
127
|
+
resolv_conf_contains(*conf)
|
128
|
+
|
127
129
|
Facter.fact(:domain).value.should == expect
|
128
130
|
end
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
132
|
-
end
|
134
|
+
end
|
133
135
|
|
134
136
|
describe "on Windows" do
|
135
137
|
before(:each) do
|
@@ -173,35 +175,35 @@ describe "Domain name facts" do
|
|
173
175
|
end
|
174
176
|
end
|
175
177
|
|
176
|
-
describe "with trailing dots" do
|
177
|
-
describe "on Windows" do
|
178
|
+
describe "with trailing dots" do
|
179
|
+
describe "on Windows" do
|
178
180
|
before do
|
179
181
|
Facter.fact(:kernel).stubs(:value).returns("windows")
|
180
182
|
require 'facter/util/registry'
|
181
183
|
require 'facter/util/wmi'
|
182
184
|
end
|
183
|
-
|
185
|
+
|
184
186
|
[{:registry => 'testdomain.', :wmi => '', :expect => 'testdomain'},
|
185
187
|
{:registry => '', :wmi => 'testdomain.', :expect => 'testdomain'},
|
186
188
|
].each do |scenario|
|
187
189
|
|
188
|
-
describe "scenarios" do
|
190
|
+
describe "scenarios" do
|
189
191
|
before(:each) do
|
190
192
|
Facter::Util::Registry.stubs(:hklm_read).returns(scenario[:registry])
|
191
193
|
nic = stubs 'nic'
|
192
194
|
nic.stubs(:DNSDomain).returns(scenario[:wmi])
|
193
195
|
Facter::Util::WMI.stubs(:execquery).with("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").returns([nic])
|
194
196
|
end
|
195
|
-
|
197
|
+
|
196
198
|
it "should return #{scenario[:expect]}" do
|
197
199
|
Facter.fact(:domain).value.should == scenario[:expect]
|
198
200
|
end
|
199
|
-
|
201
|
+
|
200
202
|
it "should remove trailing dots" do
|
201
203
|
Facter.fact(:domain).value.should_not =~ /\.$/
|
202
204
|
end
|
203
|
-
end
|
204
|
-
end
|
205
|
+
end
|
206
|
+
end
|
205
207
|
end
|
206
208
|
|
207
209
|
describe "on everything else" do
|
@@ -210,24 +212,57 @@ describe "Domain name facts" do
|
|
210
212
|
FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(true)
|
211
213
|
end
|
212
214
|
|
213
|
-
[
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
215
|
+
[
|
216
|
+
{
|
217
|
+
:scenario => 'when there is only a hostname',
|
218
|
+
:hostname => 'host.testdomain.',
|
219
|
+
:dnsdomainname => '',
|
220
|
+
:resolve_domain => '',
|
221
|
+
:resolve_search => '',
|
222
|
+
:expect => 'testdomain'
|
223
|
+
},
|
224
|
+
{
|
225
|
+
:scenario => 'when there is only a domain name',
|
226
|
+
:hostname => '',
|
227
|
+
:dnsdomainname => 'testdomain.',
|
228
|
+
:resolve_domain => '',
|
229
|
+
:resolve_search => '',
|
230
|
+
:expect => 'testdomain'
|
231
|
+
},
|
232
|
+
{
|
233
|
+
:scenario => 'when there is only a resolve domain',
|
234
|
+
:hostname => '',
|
235
|
+
:dnsdomainname => '',
|
236
|
+
:resolve_domain => 'testdomain.',
|
237
|
+
:resolve_search => '',
|
238
|
+
:expect => 'testdomain'
|
239
|
+
},
|
240
|
+
{
|
241
|
+
:scenario => 'when there is only a resolve search',
|
242
|
+
:hostname => '',
|
243
|
+
:dnsdomainname => '',
|
244
|
+
:resolve_domain => '',
|
245
|
+
:resolve_search => 'testdomain.',
|
246
|
+
:expect => 'testdomain'
|
247
|
+
},
|
248
|
+
{
|
249
|
+
:scenario => 'when there is no information available',
|
250
|
+
:hostname => '',
|
251
|
+
:dnsdomainname => '',
|
252
|
+
:resolve_domain => '',
|
253
|
+
:resolve_search => '',
|
254
|
+
:expect => nil
|
255
|
+
}
|
218
256
|
].each do |scenario|
|
219
257
|
|
220
|
-
describe
|
221
|
-
before(:each) do
|
222
|
-
Facter::Util::Resolution.stubs(:exec).with("hostname -f").returns(scenario[:hostname])
|
223
|
-
Facter::Util::Resolution.stubs(:exec).with("dnsdomainname").returns(scenario[:dnsdomainname])
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
"domain #{scenario[:resolve_domain]}",
|
229
|
-
]
|
230
|
-
@mock_file.stubs(:each).multiple_yields(*lines)
|
258
|
+
describe scenario[:scenario] do
|
259
|
+
before(:each) do
|
260
|
+
Facter::Util::Resolution.stubs(:exec).with("hostname -f 2> /dev/null").returns(scenario[:hostname])
|
261
|
+
Facter::Util::Resolution.stubs(:exec).with("dnsdomainname 2> /dev/null").returns(scenario[:dnsdomainname])
|
262
|
+
resolv_conf_contains(
|
263
|
+
"search #{scenario[:resolve_search]}",
|
264
|
+
"domain #{scenario[:resolve_domain]}"
|
265
|
+
)
|
231
266
|
end
|
232
267
|
|
233
268
|
it "should remove trailing dots" do
|
@@ -238,7 +273,7 @@ describe "Domain name facts" do
|
|
238
273
|
Facter.fact(:domain).value.should == scenario[:expect]
|
239
274
|
end
|
240
275
|
end
|
241
|
-
end
|
276
|
+
end
|
242
277
|
end
|
243
278
|
end
|
244
279
|
end
|
@@ -1,8 +1,21 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'shared_formats/parses'
|
4
5
|
require 'facter/util/ip'
|
5
6
|
|
7
|
+
shared_examples_for "netmask_* from ifconfig output" do |platform, interface, address, fixture|
|
8
|
+
it "correctly on #{platform} interface #{interface}" do
|
9
|
+
Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
|
10
|
+
Facter::Util::IP.stubs(:get_output_for_interface_and_label).
|
11
|
+
returns(my_fixture_read("#{fixture}.#{interface}"))
|
12
|
+
Facter.collection.internal_loader.load(:interfaces)
|
13
|
+
|
14
|
+
fact = Facter.fact("netmask_#{interface}".intern)
|
15
|
+
fact.value.should eq(address)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
describe "Per Interface IP facts" do
|
7
20
|
it "should replace the ':' in an interface list with '_'" do
|
8
21
|
# So we look supported
|
@@ -19,3 +32,16 @@ describe "Per Interface IP facts" do
|
|
19
32
|
Facter.fact(:interfaces).value.should == %{Local_Area_Connection,Loopback__Pseudo_Interface____1_}
|
20
33
|
end
|
21
34
|
end
|
35
|
+
|
36
|
+
describe "Netmask handling on Linux" do
|
37
|
+
before :each do
|
38
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
39
|
+
end
|
40
|
+
|
41
|
+
example_behavior_for "netmask_* from ifconfig output",
|
42
|
+
"Archlinux (net-tools 1.60)", "em1",
|
43
|
+
"255.255.255.0", "ifconfig_net_tools_1.60.txt"
|
44
|
+
example_behavior_for "netmask_* from ifconfig output",
|
45
|
+
"Archlinux (net-tools 1.60)", "lo",
|
46
|
+
"255.0.0.0", "ifconfig_net_tools_1.60.txt"
|
47
|
+
end
|
data/spec/unit/ipaddress_spec.rb
CHANGED
@@ -28,5 +28,9 @@ describe "The ipaddress fact" do
|
|
28
28
|
"Ubuntu 12.04", "10.87.80.110", "ifconfig_ubuntu_1204.txt"
|
29
29
|
example_behavior_for "ifconfig output",
|
30
30
|
"Fedora 17", "131.252.209.153", "ifconfig_net_tools_1.60.txt"
|
31
|
+
example_behavior_for "ifconfig output",
|
32
|
+
"Linux with multiple loopback addresses",
|
33
|
+
"10.0.222.20",
|
34
|
+
"ifconfig_multiple_127_addresses.txt"
|
31
35
|
end
|
32
36
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'shared_formats/parses'
|
5
|
+
require 'facter/util/ip'
|
6
|
+
|
7
|
+
shared_examples_for "netmask from ifconfig output" do |platform, address, fixture|
|
8
|
+
it "correctly on #{platform}" do
|
9
|
+
Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
|
10
|
+
Facter.collection.internal_loader.load(:netmask)
|
11
|
+
|
12
|
+
Facter.fact(:netmask).value.should eq(address)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "netmask fact" do
|
17
|
+
before :each do
|
18
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
19
|
+
end
|
20
|
+
|
21
|
+
context "on Linux" do
|
22
|
+
example_behavior_for "netmask from ifconfig output",
|
23
|
+
"Archlinux (net-tools 1.60)", "255.255.255.0",
|
24
|
+
"ifconfig_net_tools_1.60.txt"
|
25
|
+
example_behavior_for "netmask from ifconfig output",
|
26
|
+
"Ubuntu 12.04", "255.255.255.255",
|
27
|
+
"ifconfig_ubuntu_1204.txt"
|
28
|
+
end
|
29
|
+
end
|
@@ -685,7 +685,7 @@ describe Facter::Util::Resolution do
|
|
685
685
|
it "should try to run the command and return output of a shell-builtin" do
|
686
686
|
Facter::Util::Resolution.expects(:expand_command).with(%q{echo foo}).returns nil
|
687
687
|
Facter::Util::Resolution.expects(:`).with(%q{echo foo}).returns 'foo'
|
688
|
-
Facter.expects(:warnonce).with
|
688
|
+
Facter.expects(:warnonce).with 'Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command (command responsible for this message was "echo foo")'
|
689
689
|
Facter::Util::Resolution.exec(%q{echo foo}).should == 'foo'
|
690
690
|
end
|
691
691
|
it "should try to run the command and return nil if not shell-builtin" do
|
@@ -147,6 +147,15 @@ describe Facter::Util::Virtual do
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
it "reads dmi entries as ascii data" do
|
151
|
+
entries_file = my_fixture('invalid_unicode_dmi_entries')
|
152
|
+
expected_contents = 'Virtual'
|
153
|
+
|
154
|
+
entries = Facter::Util::Virtual.read_sysfs_dmi_entries(entries_file)
|
155
|
+
|
156
|
+
entries.should =~ /#{expected_contents}/
|
157
|
+
end
|
158
|
+
|
150
159
|
it "should identify vserver_host when /proc/virtual exists" do
|
151
160
|
Facter::Util::Virtual.expects(:vserver?).returns(true)
|
152
161
|
FileTest.stubs(:exists?).with("/proc/virtual").returns(true)
|
data/spec/unit/virtual_spec.rb
CHANGED
@@ -205,6 +205,12 @@ describe "Virtual fact" do
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|
208
|
+
|
209
|
+
it "(#20236) is vmware when dmidecode contains vmware and lspci returns insufficient information" do
|
210
|
+
Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("garbage\ninformation\n")
|
211
|
+
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
|
212
|
+
Facter.fact(:virtual).value.should eq("vmware")
|
213
|
+
end
|
208
214
|
end
|
209
215
|
|
210
216
|
describe "on Solaris" do
|
@@ -272,6 +278,7 @@ describe "Virtual fact" do
|
|
272
278
|
require 'facter/util/wmi'
|
273
279
|
before do
|
274
280
|
Facter.fact(:kernel).stubs(:value).returns("windows")
|
281
|
+
Facter.fact(:architecture).stubs(:value).returns("x64")
|
275
282
|
end
|
276
283
|
|
277
284
|
it "should be kvm with KVM model name from Win32_ComputerSystem" do
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
5
|
-
prerelease:
|
4
|
+
version: 1.7.2.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Puppet Labs
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: You can prove anything with facts!
|
15
15
|
email: info@puppetlabs.com
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out
|
200
200
|
- spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out
|
201
201
|
- spec/fixtures/unit/util/ec2/linux-arp-ec2.out
|
202
|
+
- spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries
|
202
203
|
- spec/fixtures/unit/util/virtual/solaris10_proc_self_status1
|
203
204
|
- spec/fixtures/unit/util/loader/nosuchfact.rb
|
204
205
|
- spec/fixtures/unit/util/processor/solaris-i86pc
|
@@ -245,8 +246,12 @@ files:
|
|
245
246
|
- spec/fixtures/unit/util/uptime/kstat_boot_time
|
246
247
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd
|
247
248
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin
|
249
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo
|
250
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt
|
251
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em1
|
248
252
|
- spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
|
249
253
|
- spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
|
254
|
+
- spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt
|
250
255
|
- spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt
|
251
256
|
- spec/fixtures/unit/zfs_version/freebsd_9.0
|
252
257
|
- spec/fixtures/unit/zfs_version/freebsd_8.2
|
@@ -254,6 +259,8 @@ files:
|
|
254
259
|
- spec/fixtures/unit/zfs_version/solaris_10
|
255
260
|
- spec/fixtures/unit/zfs_version/linux-fuse_0.6.9
|
256
261
|
- spec/fixtures/unit/filesystems/linux
|
262
|
+
- spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt
|
263
|
+
- spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt
|
257
264
|
- spec/fixtures/unit/zpool_version/freebsd_9.0
|
258
265
|
- spec/fixtures/unit/zpool_version/freebsd_8.2
|
259
266
|
- spec/fixtures/unit/zpool_version/solaris_11
|
@@ -299,6 +306,7 @@ files:
|
|
299
306
|
- spec/fixtures/netstat/darwin_9_8_0
|
300
307
|
- spec/fixtures/netstat/open_solaris_b132
|
301
308
|
- spec/fixtures/netstat/ubuntu_7_04
|
309
|
+
- spec/shared_formats/parses.rb
|
302
310
|
- spec/unit/util/parser_spec.rb
|
303
311
|
- spec/unit/util/virtual_spec.rb
|
304
312
|
- spec/unit/util/monkey_patches_spec.rb
|
@@ -347,6 +355,7 @@ files:
|
|
347
355
|
- spec/unit/interfaces_spec.rb
|
348
356
|
- spec/unit/zpool_version_spec.rb
|
349
357
|
- spec/unit/memory_spec.rb
|
358
|
+
- spec/unit/netmask_spec.rb
|
350
359
|
- spec/unit/lsbdistid_spec.rb
|
351
360
|
- spec/unit/zonename_spec.rb
|
352
361
|
- spec/unit/uniqueid_spec.rb
|
@@ -382,9 +391,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
382
391
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
392
|
none: false
|
384
393
|
requirements:
|
385
|
-
- - ! '
|
394
|
+
- - ! '>'
|
386
395
|
- !ruby/object:Gem::Version
|
387
|
-
version:
|
396
|
+
version: 1.3.1
|
388
397
|
requirements: []
|
389
398
|
rubyforge_project:
|
390
399
|
rubygems_version: 1.8.23
|
@@ -437,6 +446,7 @@ test_files:
|
|
437
446
|
- spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out
|
438
447
|
- spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out
|
439
448
|
- spec/fixtures/unit/util/ec2/linux-arp-ec2.out
|
449
|
+
- spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries
|
440
450
|
- spec/fixtures/unit/util/virtual/solaris10_proc_self_status1
|
441
451
|
- spec/fixtures/unit/util/loader/nosuchfact.rb
|
442
452
|
- spec/fixtures/unit/util/processor/solaris-i86pc
|
@@ -483,8 +493,12 @@ test_files:
|
|
483
493
|
- spec/fixtures/unit/util/uptime/kstat_boot_time
|
484
494
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd
|
485
495
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin
|
496
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo
|
497
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt
|
498
|
+
- spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em1
|
486
499
|
- spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
|
487
500
|
- spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
|
501
|
+
- spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt
|
488
502
|
- spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt
|
489
503
|
- spec/fixtures/unit/zfs_version/freebsd_9.0
|
490
504
|
- spec/fixtures/unit/zfs_version/freebsd_8.2
|
@@ -492,6 +506,8 @@ test_files:
|
|
492
506
|
- spec/fixtures/unit/zfs_version/solaris_10
|
493
507
|
- spec/fixtures/unit/zfs_version/linux-fuse_0.6.9
|
494
508
|
- spec/fixtures/unit/filesystems/linux
|
509
|
+
- spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt
|
510
|
+
- spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt
|
495
511
|
- spec/fixtures/unit/zpool_version/freebsd_9.0
|
496
512
|
- spec/fixtures/unit/zpool_version/freebsd_8.2
|
497
513
|
- spec/fixtures/unit/zpool_version/solaris_11
|
@@ -537,6 +553,7 @@ test_files:
|
|
537
553
|
- spec/fixtures/netstat/darwin_9_8_0
|
538
554
|
- spec/fixtures/netstat/open_solaris_b132
|
539
555
|
- spec/fixtures/netstat/ubuntu_7_04
|
556
|
+
- spec/shared_formats/parses.rb
|
540
557
|
- spec/unit/util/parser_spec.rb
|
541
558
|
- spec/unit/util/virtual_spec.rb
|
542
559
|
- spec/unit/util/monkey_patches_spec.rb
|
@@ -585,6 +602,7 @@ test_files:
|
|
585
602
|
- spec/unit/interfaces_spec.rb
|
586
603
|
- spec/unit/zpool_version_spec.rb
|
587
604
|
- spec/unit/memory_spec.rb
|
605
|
+
- spec/unit/netmask_spec.rb
|
588
606
|
- spec/unit/lsbdistid_spec.rb
|
589
607
|
- spec/unit/zonename_spec.rb
|
590
608
|
- spec/unit/uniqueid_spec.rb
|