diff options
author | dheerajd-msys <dheeraj.dubey@msystechnologies.com> | 2019-07-19 14:58:17 +0530 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2019-10-09 10:48:34 -0700 |
commit | 4746690b98172c89abc2b6836e0aac1d039306dd (patch) | |
tree | 043090da0003d30926fe81fd34bda96e7f10e163 | |
parent | d5774afabda0f09df359d0126617358e51f8349e (diff) | |
download | chef-4746690b98172c89abc2b6836e0aac1d039306dd.tar.gz |
fix regex matching interface name with dash
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/ifconfig_spec.rb | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 1575127c25..607f1fa47b 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -112,7 +112,7 @@ class Chef # Permalink for addr_regex : https://rubular.com/r/JrykUpfjRnYeQD @status = shell_out("ifconfig") @status.stdout.each_line do |line| - addr_regex = /^((\w|-)+):?(\d*):?\ .+$/ + addr_regex = /^(\w+)(-?):?(\d*):?\ .+$/ if line =~ addr_regex if line.match(addr_regex).nil? @int_name = "nil" diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 8c63a3e46e..b25c8f70ca 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -94,6 +94,17 @@ EOS expect(@new_resource).not_to be_updated end + it "should add a bridge interface" do + allow(@provider).to receive(:load_current_resource) + @new_resource.device "br-1234" + command = "ifconfig br-1234 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500" + expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" ")) + expect(@provider).to receive(:generate_config) + + @provider.run_action(:add) + expect(@new_resource).to be_updated + end + # We are not testing this case with the assumption that anyone writing the cookbook would not make a typo == lo # it "should add a blank command if the #{@new_resource.device} == lo" do # end |