[SEBA-367] olt,onu synchronization fix
Change-Id: If7a5709537bda3b634e8aa1f710ce619886e26f7
diff --git a/xos/synchronizer/pull_steps/pull_onus.py b/xos/synchronizer/pull_steps/pull_onus.py
index da85248..6920f5c 100644
--- a/xos/synchronizer/pull_steps/pull_onus.py
+++ b/xos/synchronizer/pull_steps/pull_onus.py
@@ -51,16 +51,24 @@
if r.status_code != 200:
log.warn("It was not possible to fetch devices from VOLTHA")
- # keeping only ONUs
- devices = [d for d in r.json()["items"] if "onu" in d["type"]]
+ # [SEBA-367] Handling blank response received from Voltha, Scenario occurs when voltha api is called while vcore service is re-starting
- log.debug("received devices", onus=devices)
+ elif r.text:
+ # keeping only ONUs
+ devices = [d for d in r.json()["items"] if "onu" in d["type"]]
- # TODO
- # [ ] delete ONUS as ONUDevice.objects.all() - updated ONUs
+ log.debug("received devices", onus=devices)
- onus_in_voltha = self.create_or_update_onus(devices)
+ # TODO
+ # [ ] delete ONUS as ONUDevice.objects.all() - updated ONUs
+ onus_in_voltha = self.create_or_update_onus(devices)
+ else:
+ log.debug("[ONU pull step] Blank response received")
+
+ except (ValueError, TypeError), e:
+ log.warn("[ONU pull step] Invalid Json received in response from VOLTHA", reason=e)
+ return
except ConnectionError, e:
log.warn("It was not possible to connect to VOLTHA", reason=e)
return