From b44e3be8c5295fc88c7f71aa42ec9214911092ed Mon Sep 17 00:00:00 2001 From: Clement Contini Date: Mon, 19 Sep 2016 14:16:59 -0400 Subject: [PATCH] remove the IP from the databag if it is not used --- .../patches/debian/config/opt/cloud/bin/cs_forwardingrules.py | 4 ++++ systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs_forwardingrules.py b/systemvm/patches/debian/config/opt/cloud/bin/cs_forwardingrules.py index e30c012f10df..a5cb3e565319 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs_forwardingrules.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs_forwardingrules.py @@ -64,6 +64,10 @@ def merge(dbag, rules): print "removing index %s" % str(index) if not index == -1: del dbag[source_ip][index] + # If all forwarding rules have been deleted + # remove IP from databag + if dbag[source_ip] == []: + del dbag[source_ip] return dbag diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py b/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py index efcf311296fa..cc8c17a6b460 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py @@ -38,7 +38,8 @@ def merge(dbag, ip): ip['nw_type'] = 'public' if ip['nw_type'] == 'control': dbag['eth' + str(ip['nic_dev_id'])] = [ip] - else: + # if ip['add'] is false, the IP will be removed from the databag + elif ip['add']: dbag.setdefault('eth' + str(ip['nic_dev_id']), []).append(ip) return dbag