summaryrefslogtreecommitdiff
path: root/lib/chef/provider/route.rb
diff options
context:
space:
mode:
authorTom Doherty <tom.doherty@fixnetix.com>2017-09-08 16:17:45 +0100
committerBryan McLellan <btm@loftninjas.org>2017-09-11 21:42:36 -0400
commit127b58c1494fe17d02f5d6e26d4306a574e80853 (patch)
tree398ab7d17d47f5fbb593a94035ebba0ed47eae01 /lib/chef/provider/route.rb
parent5783702cedfff48e3eab8a9d271f6f2340b34e2a (diff)
downloadchef-127b58c1494fe17d02f5d6e26d4306a574e80853.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/route.rb')
-rw-r--r--lib/chef/provider/route.rb14
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