diff options
author | dheerajd-msys <dheeraj.dubey@msystechnologies.com> | 2019-07-19 14:58:17 +0530 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2019-10-02 11:00:13 -0700 |
commit | 17a56576cee5284521a5b45157824ee4a936d708 (patch) | |
tree | 917c297e5fd4d4b9e0fb7638ae38b24c42fe3e8b | |
parent | 7aef4109b71fafa97193f4a762dac225f2d8288f (diff) | |
download | chef-17a56576cee5284521a5b45157824ee4a936d708.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 070a4686ba..585ae73f3d 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -110,7 +110,7 @@ class Chef # TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 @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 |