diff options
author | Tom Doherty <tom.doherty@fixnetix.com> | 2017-09-08 16:17:45 +0100 |
---|---|---|
committer | Tom Doherty <tom.doherty@fixnetix.com> | 2017-09-08 16:17:45 +0100 |
commit | d78b719df2a6ef127f7becb9b7b7be25a4260560 (patch) | |
tree | b29c94d1fbc1877e5bb763158d55b947a2605a0c /lib/chef/provider | |
parent | b8ebe375fae24a35deac44b62a020fba6890b506 (diff) | |
download | chef-d78b719df2a6ef127f7becb9b7b7be25a4260560.tar.gz |
Simplify and add unit test for default route
Signed-off-by: Tom Doherty <tom.doherty@fixnetix.com>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/route.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index 56689c8364..222d35181e 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -87,14 +87,13 @@ class Chef # cidr or quad dot mask new_ip = if new_resource.target == "default" - nil + IPAddr.new(new_resource.gateway) elsif new_resource.netmask IPAddr.new("#{new_resource.target}/#{new_resource.netmask}") else IPAddr.new(new_resource.target) end - return unless new_ip # For linux, we use /proc/net/route file to read proc table info return if node[:os] != "linux" @@ -208,14 +207,9 @@ class Chef case action when :add - if target == "default" - command = [ "ip", "route", "replace", target ] - command += [ "via", new_resource.gateway ] if new_resource.gateway - else - command = [ "ip", "route", "replace", target ] - command += [ "via", new_resource.gateway ] if new_resource.gateway - command += [ "dev", new_resource.device ] if new_resource.device - end + command = [ "ip", "route", "replace", target ] + command += [ "via", new_resource.gateway ] if new_resource.gateway + command += [ "dev", new_resource.device ] if new_resource.device when :delete command = [ "ip", "route", "delete", target ] command += [ "via", new_resource.gateway ] if new_resource.gateway |