summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2019-07-19 14:58:17 +0530
committerdheerajd-msys <dheeraj.dubey@msystechnologies.com>2019-08-06 11:14:52 +0530
commit2ea154bae21b19e32b12a699b33844d7825fd2ab (patch)
treece5369977f72af441e3d4f5fadf7be24271323fc
parentfc07ead366d5ef3acd9f7fe3dd36503e5a3ed1c5 (diff)
downloadchef-2ea154bae21b19e32b12a699b33844d7825fd2ab.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.rb2
-rw-r--r--spec/unit/provider/ifconfig_spec.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 93db827e97..a3b63a5490 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -111,7 +111,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 5b1256300e..38561d6e49 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -94,6 +94,17 @@ describe Chef::Provider::Ifconfig do
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