CORD-1354 fix NetworkSlice and ControllerSite created when they already exists
Change-Id: Ic37464dac40b3e5f92b705f30337ddc77df54ac0
diff --git a/xos/synchronizer/model_policies/model_policy_Site.py b/xos/synchronizer/model_policies/model_policy_Site.py
index f800092..07fe6f3 100644
--- a/xos/synchronizer/model_policies/model_policy_Site.py
+++ b/xos/synchronizer/model_policies/model_policy_Site.py
@@ -5,9 +5,10 @@
# make sure site has a ControllerSite record for each controller
ctrl_sites = ControllerSite.objects.filter(site_id=site.id)
existing_controllers = [cs.controller for cs in ctrl_sites]
+ existing_controller_ids = [c.id for c in existing_controllers]
all_controllers = Controller.objects.all()
for ctrl in all_controllers:
- if ctrl not in existing_controllers:
+ if ctrl.id not in existing_controller_ids:
ctrl_site = ControllerSite(controller=ctrl, site=site)
ctrl_site.save()