Added delete for non-sync'd objects. Resolves #9 and #82
diff --git a/xos/model_policy.py b/xos/model_policy.py
index 9333adc..19c281a 100644
--- a/xos/model_policy.py
+++ b/xos/model_policy.py
@@ -90,6 +90,9 @@
logging.error('Object %r is defective'%instance)
bad_instances.append(instance)
+def noop(o,p):
+ pass
+
def run_policy():
from core.models import Sliver,Slice,Controller,Network,User,SlicePrivilege,Site,SitePrivilege,Image,ControllerSlice,ControllerUser,ControllerSite
while (True):
@@ -110,6 +113,16 @@
for o in deleted_objects:
execute_model_policy(o, True)
+ # Reap non-sync'd models here
+ reaped = [Slice]
+
+ for m in reaped:
+ dobjs = m.deleted_objects.all()
+ for d in dobjs:
+ deps = walk_inv_deps(noop, d)
+ if (not deps):
+ print 'Purging object %r'%d
+ d.delete(purge=True)
if (time.time()-start<1):
time.sleep(1)