summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Duffield <tom@chef.io>2017-01-31 18:48:23 -0600
committerGitHub <noreply@github.com>2017-01-31 18:48:23 -0600
commita65c8244a32b1e19dfd919f9a51711a994646d3a (patch)
treecb071bc94bcaa83cf23c5a8a5fec1931f7c89eb6
parentb3ae36cb4759a1ee16368b78558b69c553e650d8 (diff)
parent3ef8b02143c251180f7bf6212550c1ad3c44ef55 (diff)
downloadchef-a65c8244a32b1e19dfd919f9a51711a994646d3a.tar.gz
Merge pull request #5772 from chef/tduffield/COOL-635/netmask-eth0
Use CIDR notation rather than netmask in route-eth0 file
-rw-r--r--lib/chef/provider/route.rb2
-rw-r--r--spec/unit/provider/route_spec.rb8
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index f2b7b33419..5e20fdf11e 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -219,7 +219,7 @@ class Chef
case action
when :add
content << (options[:target]).to_s
- content << "/#{options[:netmask]}" if options[:netmask]
+ content << "/#{MASK[options[:netmask].to_s]}" if options[:netmask]
content << " via #{options[:gateway]}" if options[:gateway]
content << "\n"
end
diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb
index 7058d76590..03d1ad2477 100644
--- a/spec/unit/provider/route_spec.rb
+++ b/spec/unit/provider/route_spec.rb
@@ -230,13 +230,19 @@ describe Chef::Provider::Route do
@run_context.resource_collection << Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1")
@run_context.resource_collection << Chef::Resource::Route.new("192.168.2.0/24 via 192.168.0.1")
@run_context.resource_collection << Chef::Resource::Route.new("192.168.3.0/24 via 192.168.0.1")
+ @run_context.resource_collection << Chef::Resource::Route.new("Complex Route").tap do |r|
+ r.target "192.168.4.0"
+ r.gateway "192.168.0.1"
+ r.netmask "255.255.255.0"
+ end
@provider.action = :add
@provider.generate_config
- expect(route_file.string.split("\n").size).to eq(3)
+ expect(route_file.string.split("\n").size).to eq(4)
expect(route_file.string).to match(/^192\.168\.1\.0\/24 via 192\.168\.0\.1$/)
expect(route_file.string).to match(/^192\.168\.2\.0\/24 via 192\.168\.0\.1$/)
expect(route_file.string).to match(/^192\.168\.3\.0\/24 via 192\.168\.0\.1$/)
+ expect(route_file.string).to match(/^192\.168\.4\.0\/24 via 192\.168\.0\.1$/)
end
end
end