finished cleanup_unique tool
diff --git a/xos/tools/cleanup_unique.py b/xos/tools/cleanup_unique.py
index 0ee0c7a..07a2d4e 100644
--- a/xos/tools/cleanup_unique.py
+++ b/xos/tools/cleanup_unique.py
@@ -8,38 +8,80 @@
from cord.models import *
django.setup()
+for obj in ControllerNetwork.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+for obj in ControllerSite.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+
+for obj in NetworkSlice.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+
+for obj in NetworkSliver.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+
+for obj in DeploymentPrivilege.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+
+for obj in SiteDeployment.deleted_objects.all():
+ print "Purging deleted object", obj
+ obj.delete(purge=True)
+
+seen=[]
for obj in ControllerNetwork.objects.all():
+ seen.append(obj.id)
conflicts = ControllerNetwork.objects.filter(network=obj.network, controller=obj.controller)
for conflict in conflicts:
- if conflict.id != obj.id:
- print "Purging", conflict
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
conflict.delete(purge=True)
+seen=[]
for obj in NetworkSlice.objects.all():
+ seen.append(obj.id)
conflicts = NetworkSlice.objects.filter(network=obj.network, slice=obj.slice)
for conflict in conflicts:
- if conflict.id != obj.id:
- print "Purging", conflict
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
conflict.delete(purge=True)
+seen=[]
for obj in NetworkSliver.objects.all():
+ seen.append(obj.id)
conflicts = NetworkSliver.objects.filter(network=obj.network, sliver=obj.sliver)
for conflict in conflicts:
- if conflict.id != obj.id:
- print "Purging", conflict
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
conflict.delete(purge=True)
+seen=[]
for obj in DeploymentPrivilege.objects.all():
+ seen.append(obj.id)
conflicts = DeploymentPrivilege.objects.filter(user=obj.user, deployment=obj.deployment, role=obj.role)
for conflict in conflicts:
- if conflict.id != obj.id:
- print "Purging", conflict
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
conflict.delete(purge=True)
+seen=[]
for obj in SiteDeployment.objects.all():
+ seen.append(obj.id)
conflicts = SiteDeployment.objects.filter(site=obj.site, deployment=obj.deployment, controller=obj.controller)
for conflict in conflicts:
- if conflict.id != obj.id:
- print "Purging", conflict
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
+ conflict.delete(purge=True)
+
+seen=[]
+for obj in ControllerSite.objects.all():
+ seen.append(obj.id)
+ conflicts = ControllerSite.objects.filter(site=obj.site, controller=obj.controller)
+ for conflict in conflicts:
+ if conflict.id not in seen:
+ print "Purging", conflict, conflict.id, "due to duplicate of", obj.id
conflict.delete(purge=True)