From 92fd19b14bd8c2ec301280e006f2cd492a61a7af Mon Sep 17 00:00:00 2001 From: Sachin Bansal Date: Sat, 2 Apr 2016 20:18:12 -0700 Subject: [PATCH] If any RI is deleted during reinit, drop them from the parent VN object During reinit, we examine whether each RI is supposed to be deleted. After we delete an RI, we should delete it from parent object local copy otherwise when we reinitialize the VN object, it will incorrectly resurrect the deleted RI. Change-Id: I21fd133ee79a4b121190c7feb6cee3ba0d1b1b37 Closes-Bug: 1564669 --- src/config/schema-transformer/to_bgp.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/config/schema-transformer/to_bgp.py b/src/config/schema-transformer/to_bgp.py index 6ab1d2b86a5..c4f20091b88 100644 --- a/src/config/schema-transformer/to_bgp.py +++ b/src/config/schema-transformer/to_bgp.py @@ -350,10 +350,12 @@ def reinit(self): vn_id_list = [vn.uuid for vn in vn_list] ri_dict = {} service_ri_dict = {} + ri_deleted = {} for ri in DBBaseST.list_vnc_obj('routing_instance'): delete = False if ri.parent_uuid not in vn_id_list: delete = True + ri_deleted.setdefault(ri.parent_uuid, []).append(ri.uuid) else: # if the RI was for a service chain and service chain no # longer exists, delete the RI @@ -421,6 +423,11 @@ def reinit(self): gevent.sleep(0.001) RouteTargetST.reinit() for vn in vn_list: + if vn.uuid in ri_deleted: + vn_ri_list = vn.get_routing_instances() or [] + new_vn_ri_list = [vn_ri for vn_ri in vn_ri_list + if vn_ri['uuid'] not in ri_deleted[vn.uuid]] + vn.routing_instances = new_vn_ri_list VirtualNetworkST.locate(vn.get_fq_name_str(), vn, vn_acl_dict) for ri_name, ri_obj in ri_dict.items(): RoutingInstanceST.locate(ri_name, ri_obj)