CORD-1762 delete vsg tenant when its last provided link is deleted
Change-Id: I8cf839764d301798d869eff9441e805f5e73e4d8
(cherry picked from commit 88f0c2f42d5e6572871ec54ca04b51e141fd4b70)
diff --git a/xos/synchronizer/model_policies/model_policy_vsgtenant.py b/xos/synchronizer/model_policies/model_policy_vsgtenant.py
index 86f6257..b65defc 100644
--- a/xos/synchronizer/model_policies/model_policy_vsgtenant.py
+++ b/xos/synchronizer/model_policies/model_policy_vsgtenant.py
@@ -25,6 +25,12 @@
return self.handle_update(tenant)
def handle_update(self, tenant):
+ if (tenant.link_deleted_count>0) and (not tenant.provided_links.exists()):
+ # if the last provided_link has just gone away, then self-destruct
+ self.logger.info("The last provided link has been deleted -- self-destructing.");
+ tenant.delete()
+ return
+
self.manage_container(tenant)
self.manage_address_service_instance(tenant)
self.cleanup_orphans(tenant)