[SEBA-200] Deleting an OLT that was never sync'ed
Change-Id: I6e319c3d4cc93b8718f98a0c2dc1cc7a36260b1e
diff --git a/xos/synchronizer/steps/sync_olt_device.py b/xos/synchronizer/steps/sync_olt_device.py
index b65dfef..81a9288 100644
--- a/xos/synchronizer/steps/sync_olt_device.py
+++ b/xos/synchronizer/steps/sync_olt_device.py
@@ -142,8 +142,10 @@
voltha = Helpers.get_voltha_info(model.volt_service)
- if not model.device_id:
- log.error("OLTDevice %s has no device_id" % model.name)
+ if not model.device_id or model.backend_code == 2:
+ # NOTE if the device was not synchronized, just remove it from the data model
+ log.warning("OLTDevice %s has no device_id, it was never saved in VOLTHA" % model.name)
+ return
else:
# Disable the OLT device
request = requests.post("%s:%d/api/v1/devices/%s/disable" % (voltha['url'], voltha['port'], model.device_id))