diff options
author | tomdoherty <31742246+tomdoherty@users.noreply.github.com> | 2018-04-13 16:15:10 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2018-04-13 16:15:10 +0100 |
commit | e09b9b3d3a6602407ab2dff44333d1c0a8d25d17 (patch) | |
tree | f616db041ec3be99e1f10ea2538d5edd0f946767 | |
parent | 84657b2e7ef92ac81d98e265db4305dfb6b5aab3 (diff) | |
download | chef-e09b9b3d3a6602407ab2dff44333d1c0a8d25d17.tar.gz |
Add support for route metric (#7140)
Signed-off-by: Tom Doherty <tom.doherty@fixnetix.com>
-rw-r--r-- | lib/chef/provider/route.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/route.rb | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index c00d6a1932..ed1f1f4c4d 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -174,7 +174,7 @@ class Chef conf[dev] = "" if conf[dev].nil? case @action when :add - conf[dev] << config_file_contents(:add, comment: resource.comment, target: resource.target, netmask: resource.netmask, gateway: resource.gateway) if resource.action == [:add] + conf[dev] << config_file_contents(:add, comment: resource.comment, target: resource.target, metric: resource.metric, netmask: resource.netmask, gateway: resource.gateway) if resource.action == [:add] when :delete # need to do this for the case when the last route on an int # is removed @@ -219,6 +219,7 @@ class Chef command = [ "ip", "route", "replace", target ] command += [ "via", new_resource.gateway ] if new_resource.gateway command += [ "dev", new_resource.device ] if new_resource.device + command += [ "metric", new_resource.metric ] if new_resource.metric when :delete command = [ "ip", "route", "delete", target ] command += [ "via", new_resource.gateway ] if new_resource.gateway @@ -235,6 +236,7 @@ class Chef content << (options[:target]).to_s content << "/#{MASK[options[:netmask].to_s]}" if options[:netmask] content << " via #{options[:gateway]}" if options[:gateway] + content << " metric #{options[:metric]}" if options[:metric] content << "\n" end diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb index ecec56f69a..b64dcf26c6 100644 --- a/lib/chef/resource/route.rb +++ b/lib/chef/resource/route.rb @@ -29,6 +29,7 @@ class Chef property :target, String, identity: true, name_property: true property :comment, [String, nil] + property :metric, [Integer, nil] property :netmask, [String, nil] property :gateway, [String, nil] property :device, [String, nil], desired_state: false # Has a partial default in the provider of eth0. @@ -40,7 +41,6 @@ class Chef property :hostname, [String, nil], desired_state: false property :domainname, [String, nil], desired_state: false property :domain, [String, nil], desired_state: false - property :metric, [Integer, nil], desired_state: false end end end |