summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Hain <shain@chef.io>2017-11-17 11:21:19 -0800
committerScott Hain <shain@chef.io>2017-11-17 11:21:19 -0800
commitedf5c9c8e69975841ccda623bf43fdb2b418135d (patch)
tree37328b01919d61a1faad04bd76f96017ced9da83
parentef54ad304c62e4e456a412f95c5acf55ffed2874 (diff)
downloadchef-edf5c9c8e69975841ccda623bf43fdb2b418135d.tar.gz
Updated with examples for versions of ifconfigshain/fix_centos_rhel_test
Signed-off-by: Scott Hain <shain@chef.io>
-rw-r--r--lib/chef/provider/ifconfig.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 65a65b276f..cdca0db10b 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -69,6 +69,16 @@ class Chef
if @ifconfig_version.nil?
raise "net-tools not found - this is required for ifconfig"
elsif @ifconfig_version.to_f < 2.0
+ # Example output for 1.60 is as follows: (sanitized but format intact)
+ # eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
+ # inet addr:192.168.1.1 Bcast:192.168.0.1 Mask:255.255.248.0
+ # inet6 addr: 0000::00:0000:0000:0000/64 Scope:Link
+ # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
+ # RX packets:65158911 errors:0 dropped:0 overruns:0 frame:0
+ # TX packets:41723949 errors:0 dropped:0 overruns:0 carrier:0
+ # collisions:0 txqueuelen:1000
+ # RX bytes:42664658792 (39.7 GiB) TX bytes:52722603938 (49.1 GiB)
+ # Interrupt:30
@status = shell_out("ifconfig")
@status.stdout.each_line do |line|
if !line[0..9].strip.empty?
@@ -95,6 +105,15 @@ class Chef
current_resource.metric(@interface["metric"])
end
elsif @ifconfig_version.to_f >= 2.0
+ # Example output for 2.10-alpha is as follows: (sanitized but format intact)
+ # eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
+ # inet 192.168.1.1 netmask 255.255.240.0 broadcast 192.168.0.1
+ # inet6 0000::0000:000:0000:0000 prefixlen 64 scopeid 0x20<link>
+ # ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
+ # RX packets 2383836 bytes 1642630840 (1.5 GiB)
+ # RX errors 0 dropped 0 overruns 0 frame 0
+ # TX packets 1244218 bytes 977339327 (932.0 MiB)
+ # TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
@status = shell_out("ifconfig")
@status.stdout.each_line do |line|
addr_regex = /^(\w+):?(\d*):?\ .+$/
@@ -114,6 +133,7 @@ class Chef
@interfaces[@int_name]["inet_addr"] = (line =~ /inet (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet/ && @interfaces[@int_name]["inet_addr"].nil?
@interfaces[@int_name]["bcast"] = (line =~ /broadcast (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /broadcast/ && @interfaces[@int_name]["bcast"].nil?
@interfaces[@int_name]["mask"] = (line =~ /netmask (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /netmask/ && @interfaces[@int_name]["mask"].nil?
+ @interfaces[@int_name]["hwaddr"] = (line =~ /ether (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /ether/ && @interfaces[@int_name]["hwaddr"].nil?
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/ && @interfaces[@int_name]["metric"].nil?
end