ohai 0.6.12.rc.1 → 0.6.12.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai/plugins/ec2.rb +4 -3
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/platform.rb +2 -2
- data/lib/ohai/plugins/network.rb +16 -3
- data/lib/ohai/version.rb +1 -1
- data/spec/ohai/plugins/linux/network_spec.rb +5 -3
- data/spec/ohai/plugins/linux/platform_spec.rb +4 -4
- metadata +22 -55
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -30,9 +30,10 @@ extend Ohai::Mixin::Ec2Metadata
|
|
30
30
|
def has_ec2_mac?
|
31
31
|
network[:interfaces].values.each do |iface|
|
32
32
|
unless iface[:arp].nil?
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
if iface[:arp].value?("fe:ff:ff:ff:ff:ff")
|
34
|
+
Ohai::Log.debug("has_ec2_mac? == true")
|
35
|
+
return true
|
36
|
+
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
Ohai::Log.debug("has_ec2_mac? == false")
|
@@ -80,9 +80,9 @@ end
|
|
80
80
|
case platform
|
81
81
|
when /debian/, /ubuntu/, /mint/
|
82
82
|
platform_family "debian"
|
83
|
-
when /fedora
|
83
|
+
when /fedora/
|
84
84
|
platform_family "fedora"
|
85
|
-
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/
|
85
|
+
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/
|
86
86
|
platform_family "rhel"
|
87
87
|
when /suse/
|
88
88
|
platform_family "suse"
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require 'ipaddress'
|
20
|
+
|
19
21
|
provides "network", "counters/network"
|
20
22
|
|
21
23
|
network Mash.new unless network
|
@@ -26,22 +28,33 @@ counters[:network] = Mash.new unless counters[:network]
|
|
26
28
|
require_plugin "hostname"
|
27
29
|
require_plugin "#{os}::network"
|
28
30
|
|
29
|
-
def find_ip_and_mac(addresses)
|
31
|
+
def find_ip_and_mac(addresses, match = nil)
|
30
32
|
ip = nil; mac = nil
|
31
33
|
addresses.keys.each do |addr|
|
32
|
-
|
34
|
+
if match.nil?
|
35
|
+
ip = addr if addresses[addr]["family"].eql?("inet")
|
36
|
+
else
|
37
|
+
ip = addr if addresses[addr]["family"].eql?("inet") && network_contains_address(match, addr, addresses[addr][:netmask])
|
38
|
+
end
|
33
39
|
mac = addr if addresses[addr]["family"].eql?("lladdr")
|
34
40
|
break if (ip and mac)
|
35
41
|
end
|
42
|
+
Ohai::Log.debug("Found IPv4 address #{ip} with MAC #{mac} #{match.nil? ? '' : 'matching address ' + match}")
|
36
43
|
[ip, mac]
|
37
44
|
end
|
38
45
|
|
46
|
+
def network_contains_address(address_to_match, network_ip, network_mask)
|
47
|
+
network = IPAddress "#{network_ip}/#{network_mask}"
|
48
|
+
host = IPAddress address_to_match
|
49
|
+
network.include?(host)
|
50
|
+
end
|
51
|
+
|
39
52
|
# If we have a default interface that has addresses, populate the short-cut attributes
|
40
53
|
if network[:default_interface] and
|
41
54
|
network["interfaces"][network[:default_interface]] and
|
42
55
|
network["interfaces"][network[:default_interface]]["addresses"]
|
43
56
|
Ohai::Log.debug("Using default interface for default ip and mac address")
|
44
|
-
im = find_ip_and_mac(network["interfaces"][network[:default_interface]]["addresses"])
|
57
|
+
im = find_ip_and_mac(network["interfaces"][network[:default_interface]]["addresses"], network[:default_gateway])
|
45
58
|
ipaddress im.shift
|
46
59
|
macaddress im.shift
|
47
60
|
else
|
data/lib/ohai/version.rb
CHANGED
@@ -51,6 +51,8 @@ ENDIFCONFIG
|
|
51
51
|
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
|
52
52
|
link/ether 12:31:3d:02:be:a2 brd ff:ff:ff:ff:ff:ff
|
53
53
|
inet 10.116.201.76/24 brd 10.116.201.255 scope global eth0
|
54
|
+
inet 10.116.201.75/32 scope global eth0
|
55
|
+
inet 10.116.201.74/24 scope global secondary eth0
|
54
56
|
inet6 fe80::1031:3dff:fe02:bea2/64 scope link
|
55
57
|
valid_lft forever preferred_lft forever
|
56
58
|
IP_ADDR
|
@@ -122,7 +124,7 @@ IP_ROUTE
|
|
122
124
|
@ohai.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil)
|
123
125
|
@ohai.stub!(:popen4).with("ip neighbor show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil)
|
124
126
|
@ohai.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil)
|
125
|
-
@ohai.stub!(:popen4).with("ip
|
127
|
+
@ohai.stub!(:popen4).with("ip -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil)
|
126
128
|
@ohai._require_plugin("network")
|
127
129
|
@ohai._require_plugin("linux::network")
|
128
130
|
end
|
@@ -219,7 +221,7 @@ IP_ROUTE
|
|
219
221
|
@ohai.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil)
|
220
222
|
@ohai.stub!(:popen4).with("ip neighbor show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil)
|
221
223
|
@ohai.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil)
|
222
|
-
@ohai.stub!(:popen4).with("ip
|
224
|
+
@ohai.stub!(:popen4).with("ip -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil)
|
223
225
|
@ohai._require_plugin("network")
|
224
226
|
@ohai._require_plugin("linux::network")
|
225
227
|
end
|
@@ -265,7 +267,7 @@ IP_ROUTE
|
|
265
267
|
@ohai.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil)
|
266
268
|
@ohai.stub!(:popen4).with("ip neighbor show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil)
|
267
269
|
@ohai.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil)
|
268
|
-
@ohai.stub!(:popen4).with("ip
|
270
|
+
@ohai.stub!(:popen4).with("ip -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil)
|
269
271
|
@ohai._require_plugin("network")
|
270
272
|
@ohai._require_plugin("linux::network")
|
271
273
|
end
|
@@ -86,12 +86,12 @@ describe Ohai::System, "Linux plugin platform" do
|
|
86
86
|
@ohai[:platform_family].should == "rhel"
|
87
87
|
end
|
88
88
|
|
89
|
-
it "should set platform to amazon and platform_family to
|
89
|
+
it "should set platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
|
90
90
|
@ohai[:lsb][:id] = "AmazonAMI"
|
91
91
|
@ohai[:lsb][:release] = "2011.09"
|
92
92
|
@ohai._require_plugin("linux::platform")
|
93
93
|
@ohai[:platform].should == "amazon"
|
94
|
-
@ohai[:platform_family].should == "
|
94
|
+
@ohai[:platform_family].should == "rhel"
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should set platform to scientific when [:lsb][:id] contains ScientificSL" do
|
@@ -196,10 +196,10 @@ describe Ohai::System, "Linux plugin platform" do
|
|
196
196
|
@ohai[:platform_family].should == "rhel"
|
197
197
|
end
|
198
198
|
|
199
|
-
it "should set the platform_family to
|
199
|
+
it "should set the platform_family to rhel if the LSB name is amazon-ish" do
|
200
200
|
@ohai[:lsb][:id] = "Amazon"
|
201
201
|
@ohai._require_plugin("linux::platform")
|
202
|
-
@ohai[:platform_family].should == "
|
202
|
+
@ohai[:platform_family].should == "rhel"
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should set the platform_family to fedora if the LSB name is fedora-ish" do
|
metadata
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15424023
|
5
4
|
prerelease: 7
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 12
|
10
|
-
- rc
|
11
|
-
- 1
|
12
|
-
version: 0.6.12.rc.1
|
5
|
+
version: 0.6.12.rc.2
|
13
6
|
platform: ruby
|
14
7
|
authors:
|
15
8
|
- Adam Jacob
|
@@ -17,36 +10,28 @@ autorequire:
|
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
12
|
|
20
|
-
date: 2012-02
|
13
|
+
date: 2012-03-02 00:00:00 Z
|
21
14
|
dependencies:
|
22
15
|
- !ruby/object:Gem::Dependency
|
23
|
-
name:
|
16
|
+
name: systemu
|
24
17
|
prerelease: false
|
25
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
19
|
none: false
|
27
20
|
requirements:
|
28
21
|
- - ">="
|
29
22
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
|
-
segments:
|
32
|
-
- 0
|
33
23
|
version: "0"
|
34
24
|
type: :runtime
|
35
25
|
version_requirements: *id001
|
36
26
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
27
|
+
name: yajl-ruby
|
38
28
|
prerelease: false
|
39
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
30
|
none: false
|
41
31
|
requirements:
|
42
|
-
- -
|
32
|
+
- - ">="
|
43
33
|
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 2
|
48
|
-
- 0
|
49
|
-
version: 2.2.0
|
34
|
+
version: "0"
|
50
35
|
type: :runtime
|
51
36
|
version_requirements: *id002
|
52
37
|
- !ruby/object:Gem::Dependency
|
@@ -57,9 +42,6 @@ dependencies:
|
|
57
42
|
requirements:
|
58
43
|
- - ">="
|
59
44
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 3
|
61
|
-
segments:
|
62
|
-
- 0
|
63
45
|
version: "0"
|
64
46
|
type: :runtime
|
65
47
|
version_requirements: *id003
|
@@ -71,9 +53,6 @@ dependencies:
|
|
71
53
|
requirements:
|
72
54
|
- - ">="
|
73
55
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
56
|
version: "0"
|
78
57
|
type: :runtime
|
79
58
|
version_requirements: *id004
|
@@ -85,68 +64,64 @@ dependencies:
|
|
85
64
|
requirements:
|
86
65
|
- - ">="
|
87
66
|
- !ruby/object:Gem::Version
|
88
|
-
hash: 3
|
89
|
-
segments:
|
90
|
-
- 0
|
91
67
|
version: "0"
|
92
68
|
type: :runtime
|
93
69
|
version_requirements: *id005
|
94
70
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
71
|
+
name: ipaddress
|
96
72
|
prerelease: false
|
97
73
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
74
|
none: false
|
99
75
|
requirements:
|
100
76
|
- - ">="
|
101
77
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 3
|
103
|
-
segments:
|
104
|
-
- 0
|
105
78
|
version: "0"
|
106
|
-
type: :
|
79
|
+
type: :runtime
|
107
80
|
version_requirements: *id006
|
108
81
|
- !ruby/object:Gem::Dependency
|
109
|
-
name: rspec-
|
82
|
+
name: rspec-core
|
110
83
|
prerelease: false
|
111
84
|
requirement: &id007 !ruby/object:Gem::Requirement
|
112
85
|
none: false
|
113
86
|
requirements:
|
114
87
|
- - ">="
|
115
88
|
- !ruby/object:Gem::Version
|
116
|
-
hash: 3
|
117
|
-
segments:
|
118
|
-
- 0
|
119
89
|
version: "0"
|
120
90
|
type: :development
|
121
91
|
version_requirements: *id007
|
122
92
|
- !ruby/object:Gem::Dependency
|
123
|
-
name: rspec-
|
93
|
+
name: rspec-expectations
|
124
94
|
prerelease: false
|
125
95
|
requirement: &id008 !ruby/object:Gem::Requirement
|
126
96
|
none: false
|
127
97
|
requirements:
|
128
98
|
- - ">="
|
129
99
|
- !ruby/object:Gem::Version
|
130
|
-
hash: 3
|
131
|
-
segments:
|
132
|
-
- 0
|
133
100
|
version: "0"
|
134
101
|
type: :development
|
135
102
|
version_requirements: *id008
|
136
103
|
- !ruby/object:Gem::Dependency
|
137
|
-
name:
|
104
|
+
name: rspec-mocks
|
138
105
|
prerelease: false
|
139
106
|
requirement: &id009 !ruby/object:Gem::Requirement
|
140
107
|
none: false
|
141
108
|
requirements:
|
142
109
|
- - ">="
|
143
110
|
- !ruby/object:Gem::Version
|
144
|
-
hash: 3
|
145
|
-
segments:
|
146
|
-
- 0
|
147
111
|
version: "0"
|
148
112
|
type: :development
|
149
113
|
version_requirements: *id009
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: rspec_junit_formatter
|
116
|
+
prerelease: false
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: "0"
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id010
|
150
125
|
description: Ohai profiles your system and emits JSON
|
151
126
|
email: adam@opscode.com
|
152
127
|
executables:
|
@@ -374,20 +349,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
374
349
|
requirements:
|
375
350
|
- - ">="
|
376
351
|
- !ruby/object:Gem::Version
|
377
|
-
hash: 3
|
378
|
-
segments:
|
379
|
-
- 0
|
380
352
|
version: "0"
|
381
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
382
354
|
none: false
|
383
355
|
requirements:
|
384
356
|
- - ">"
|
385
357
|
- !ruby/object:Gem::Version
|
386
|
-
hash: 25
|
387
|
-
segments:
|
388
|
-
- 1
|
389
|
-
- 3
|
390
|
-
- 1
|
391
358
|
version: 1.3.1
|
392
359
|
requirements: []
|
393
360
|
|