diff options
author | Scott Hain <shain@chef.io> | 2017-11-16 12:38:24 -0800 |
---|---|---|
committer | Scott Hain <shain@chef.io> | 2017-12-11 14:31:05 -0800 |
commit | b44f8b792296028f1d3cb2dc7fe6dcc4164c8403 (patch) | |
tree | 658f8819026080de8d76972e66ee7a2462e10379 | |
parent | 40f2d2c4d585711aaab404989cfffc6e280a9be4 (diff) | |
download | chef-b44f8b792296028f1d3cb2dc7fe6dcc4164c8403.tar.gz |
Don't run ifconfig tests on RHEL7, as it is not part of the base OS
Signed-off-by: Scott Hain <shain@chef.io>
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 11 | ||||
-rw-r--r-- | spec/functional/resource/ifconfig_spec.rb | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 1618346be8..e171a17337 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -72,8 +72,9 @@ class Chef end end - case @ifconfig_version - when "1.60" + if @ifconfig_version.nil? + raise "net-tools not found - this is required for ifconfig" + elsif @ifconfig_version.to_f < 2.0 @status = shell_out("ifconfig") @status.stdout.each_line do |line| if !line[0..9].strip.empty? @@ -86,10 +87,10 @@ class Chef @interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/ @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/ end - + next unless @interfaces.key?(new_resource.device) @interface = @interfaces.fetch(new_resource.device) - + current_resource.target(new_resource.target) current_resource.device(new_resource.device) current_resource.inet_addr(@interface["inet_addr"]) @@ -99,7 +100,7 @@ class Chef current_resource.mtu(@interface["mtu"]) current_resource.metric(@interface["metric"]) end - when "2.10" + elsif @ifconfig_version.to_f >= 2.0 @status = shell_out("ifconfig") @status.stdout.each_line do |line| addr_regex = /^(\w+):?(\d*):?\ .+$/ diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index acd922e75c..fbb8995d52 100644 --- a/spec/functional/resource/ifconfig_spec.rb +++ b/spec/functional/resource/ifconfig_spec.rb @@ -20,7 +20,7 @@ require "functional/resource/base" require "chef/mixin/shell_out" # run this test only for following platforms. -include_flag = !(%w{rhel amazon debian aix}.include?(ohai[:platform_family])) +include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7)) describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do # This test does not work in travis because there is no eth0 |