From 4d3f6b2e474a72415346d40a1fa389e915a178f1 Mon Sep 17 00:00:00 2001 From: Marcel Weinberg Date: Wed, 26 Oct 2016 19:49:25 +0200 Subject: [PATCH 1/2] regex match from the beginning to the end of the string in nic_deactivate --- src/vnm_mad/remotes/lib/security_groups_iptables.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vnm_mad/remotes/lib/security_groups_iptables.rb b/src/vnm_mad/remotes/lib/security_groups_iptables.rb index 558b80e559..2c998f9766 100644 --- a/src/vnm_mad/remotes/lib/security_groups_iptables.rb +++ b/src/vnm_mad/remotes/lib/security_groups_iptables.rb @@ -328,7 +328,7 @@ module SGIPTables remove_chains = [] iptables_s.lines.each do |line| - if line.match(/^-N #{chain}/) + if line.match(/^-N #{chain}$/) remove_chains << line.split[1] end end @@ -336,7 +336,7 @@ module SGIPTables remove_chains.each {|c| commands.add :iptables, "-X #{c}" } ipset_list.lines.each do |line| - if line.match(/^#{chain}/) + if line.match(/^#{chain}$/) set = line.strip commands.add :ipset, "destroy #{set}" end From c8cf25aa88c096e845618f54638241c8133dea72 Mon Sep 17 00:00:00 2001 From: Marcel Weinberg Date: Mon, 31 Oct 2016 10:01:26 +0100 Subject: [PATCH 2/2] extended regex to match the chains in deactivate_nic --- src/vnm_mad/remotes/lib/security_groups_iptables.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vnm_mad/remotes/lib/security_groups_iptables.rb b/src/vnm_mad/remotes/lib/security_groups_iptables.rb index 2c998f9766..6eb921d0f0 100644 --- a/src/vnm_mad/remotes/lib/security_groups_iptables.rb +++ b/src/vnm_mad/remotes/lib/security_groups_iptables.rb @@ -328,7 +328,7 @@ module SGIPTables remove_chains = [] iptables_s.lines.each do |line| - if line.match(/^-N #{chain}$/) + if line.match(/^-N #{chain}(-|$)/) remove_chains << line.split[1] end end @@ -336,7 +336,7 @@ module SGIPTables remove_chains.each {|c| commands.add :iptables, "-X #{c}" } ipset_list.lines.each do |line| - if line.match(/^#{chain}$/) + if line.match(/^#{chain}(-|$)/) set = line.strip commands.add :ipset, "destroy #{set}" end