Adding delay in OLT deletion
Change-Id: I461597855424c17d4635f10da82abe68a4d9009f
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
index 4f64e57..270ba1a 100644
--- a/Dockerfile.synchronizer
+++ b/Dockerfile.synchronizer
@@ -16,7 +16,7 @@
# xosproject/volt-synchronizer
-FROM xosproject/xos-synchronizer-base:master
+FROM xosproject/xos-synchronizer-base:2.1.4
COPY xos/synchronizer /opt/xos/synchronizers/volt
COPY VERSION /opt/xos/synchronizers/volt/
diff --git a/xos/synchronizer/model_policies/test_model_policy_voltserviceinstance.py b/xos/synchronizer/model_policies/test_model_policy_voltserviceinstance.py
index bfddb64..e6fb171 100644
--- a/xos/synchronizer/model_policies/test_model_policy_voltserviceinstance.py
+++ b/xos/synchronizer/model_policies/test_model_policy_voltserviceinstance.py
@@ -46,7 +46,7 @@
sys.path.append(xos_dir)
sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
- config = os.path.join(test_path, "test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, 'synchronizer-config-schema.yaml')
diff --git a/xos/synchronizer/pull_steps/pull_olts.py b/xos/synchronizer/pull_steps/pull_olts.py
index 9c02466..0f3c199 100644
--- a/xos/synchronizer/pull_steps/pull_olts.py
+++ b/xos/synchronizer/pull_steps/pull_olts.py
@@ -74,7 +74,7 @@
# keeping only OLTs
devices = [d for d in r.json()["items"] if "olt" in d["type"]]
- log.debug("[OLT pull step] received devices", olts=devices)
+ log.trace("[OLT pull step] received devices", olts=devices)
olts_in_voltha = self.create_or_update_olts(devices)
@@ -101,7 +101,7 @@
model = OLTDevice.objects.filter(device_type=olt["type"], host=host, port=port)[0]
- log.debug("[OLT pull step] OLTDevice already exists, updating it", device_type=olt["type"], host=host, port=port)
+ log.trace("[OLT pull step] OLTDevice already exists, updating it", device_type=olt["type"], host=host, port=port)
if model.enacted < model.updated:
log.debug("[OLT pull step] Skipping pull on OLTDevice %s as enacted < updated" % model.name, name=model.name, id=model.id, enacted=model.enacted, updated=model.updated)
@@ -152,11 +152,11 @@
r = requests.get("%s:%s/api/v1/devices/%s/ports" % (voltha_url, voltha_port, olt.device_id))
if r.status_code != 200:
- log.debug("[OLT pull step] It was not possible to fetch ports from VOLTHA for device %s" % olt.device_id)
+ log.warn("[OLT pull step] It was not possible to fetch ports from VOLTHA for device %s" % olt.device_id)
ports = r.json()['items']
- log.debug("[OLT pull step] received ports", ports=ports, olt=olt.device_id)
+ log.trace("[OLT pull step] received ports", ports=ports, olt=olt.device_id)
self.create_or_update_ports(ports, olt)
@@ -182,7 +182,7 @@
for port in pon_ports:
try:
model = PONPort.objects.filter(port_no=port["port_no"], olt_device_id=olt.id)[0]
- log.debug("[OLT pull step] PONPort already exists, updating it", port_no=port["port_no"], olt_device_id=olt.id)
+ log.trace("[OLT pull step] PONPort already exists, updating it", port_no=port["port_no"], olt_device_id=olt.id)
except IndexError:
model = PONPort()
model.port_no = port["port_no"]
@@ -203,7 +203,7 @@
try:
model = NNIPort.objects.filter(port_no=port["port_no"], olt_device_id=olt.id)[0]
model.xos_managed = False
- log.debug("[OLT pull step] NNIPort already exists, updating it", port_no=port["port_no"], olt_device_id=olt.id)
+ log.trace("[OLT pull step] NNIPort already exists, updating it", port_no=port["port_no"], olt_device_id=olt.id)
except IndexError:
model = NNIPort()
model.port_no = port["port_no"]
diff --git a/xos/synchronizer/pull_steps/pull_onus.py b/xos/synchronizer/pull_steps/pull_onus.py
index 8ad59cb..4c7c344 100644
--- a/xos/synchronizer/pull_steps/pull_onus.py
+++ b/xos/synchronizer/pull_steps/pull_onus.py
@@ -49,19 +49,16 @@
r = requests.get("%s:%s/api/v1/devices" % (voltha_url, voltha_port))
if r.status_code != 200:
- log.debug("It was not possible to fetch devices from VOLTHA")
+ 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"]]
- log.debug("received devices", onus=devices)
+ log.trace("received devices", onus=devices)
# TODO
# [ ] delete ONUS as ONUDevice.objects.all() - updated ONUs
- if r.status_code != 200:
- log.debug("It was not possible to fetch devices from VOLTHA")
-
onus_in_voltha = self.create_or_update_onus(devices)
except ConnectionError, e:
@@ -79,7 +76,7 @@
try:
model = ONUDevice.objects.filter(serial_number=onu["serial_number"])[0]
- log.debug("ONUDevice already exists, updating it", serial_number=onu["serial_number"])
+ log.trace("ONUDevice already exists, updating it", serial_number=onu["serial_number"])
if model.enacted < model.updated:
log.debug("Skipping pull on ONUDevice %s as enacted < updated" % model.serial_number, serial_number=model.serial_number, id=model.id, enacted=model.enacted, updated=model.updated)
@@ -125,11 +122,11 @@
r = requests.get("%s:%s/api/v1/devices/%s/ports" % (voltha_url, voltha_port, onu.device_id))
if r.status_code != 200:
- log.debug("It was not possible to fetch ports from VOLTHA for ONUDevice %s" % onu.device_id)
+ log.warn("It was not possible to fetch ports from VOLTHA for ONUDevice %s" % onu.device_id)
ports = r.json()['items']
- log.debug("received ports", ports=ports, onu=onu.device_id)
+ log.trace("received ports", ports=ports, onu=onu.device_id)
self.create_or_update_ports(ports, onu)
@@ -159,10 +156,10 @@
r = requests.get("%s:%s/api/v1/logical_devices/%s/ports" % (voltha_url, voltha_port, logical_device_id))
if r.status_code != 200:
- log.debug("It was not possible to fetch ports from VOLTHA for logical_device %s" % logical_device_id)
+ log.warn("It was not possible to fetch ports from VOLTHA for logical_device %s" % logical_device_id)
logical_ports = r.json()['items']
- log.debug("logical device ports for ONUDevice %s" % onu.device_id, logical_ports=logical_ports)
+ log.trace("logical device ports for ONUDevice %s" % onu.device_id, logical_ports=logical_ports)
ports = [p['ofp_port']['port_no'] for p in logical_ports if p['device_id'] == onu.device_id]
# log.debug("Port_id for port %s on ONUDevice %s: %s" % (port['label'], onu.device_id, ports), logical_ports=logical_ports)
@@ -182,7 +179,7 @@
port_no = self.get_onu_port_id(port, onu)
try:
model = UNIPort.objects.filter(port_no=port_no, onu_device_id=onu.id)[0]
- log.debug("UNIPort already exists, updating it", port_no=port_no, onu_device_id=onu.id)
+ log.trace("UNIPort already exists, updating it", port_no=port_no, onu_device_id=onu.id)
except IndexError:
model = UNIPort()
model.port_no = port_no
@@ -203,7 +200,7 @@
try:
model = PONONUPort.objects.filter(port_no=port["port_no"], onu_device_id=onu.id)[0]
model.xos_managed = False
- log.debug("PONONUPort already exists, updating it", port_no=port["port_no"], onu_device_id=onu.id)
+ log.trace("PONONUPort already exists, updating it", port_no=port["port_no"], onu_device_id=onu.id)
except IndexError:
model = PONONUPort()
model.port_no = port["port_no"]
diff --git a/xos/synchronizer/pull_steps/test_pull_olts.py b/xos/synchronizer/pull_steps/test_pull_olts.py
index 0e8d262..fd09a1f 100644
--- a/xos/synchronizer/pull_steps/test_pull_olts.py
+++ b/xos/synchronizer/pull_steps/test_pull_olts.py
@@ -51,7 +51,7 @@
# Setting up the config module
from xosconfig import Config
- config = os.path.join(test_path, "../model_policies/test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
diff --git a/xos/synchronizer/pull_steps/test_pull_onus.py b/xos/synchronizer/pull_steps/test_pull_onus.py
index c888639..a1fb763 100644
--- a/xos/synchronizer/pull_steps/test_pull_onus.py
+++ b/xos/synchronizer/pull_steps/test_pull_onus.py
@@ -51,7 +51,7 @@
# Setting up the config module
from xosconfig import Config
- config = os.path.join(test_path, "../model_policies/test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
diff --git a/xos/synchronizer/steps/sync_olt_device.py b/xos/synchronizer/steps/sync_olt_device.py
index 81a9288..241e507 100644
--- a/xos/synchronizer/steps/sync_olt_device.py
+++ b/xos/synchronizer/steps/sync_olt_device.py
@@ -154,6 +154,12 @@
log.error("Failed to disable OLT device in VOLTHA: %s - %s" % (model.name, model.device_id), rest_response=request.text, rest_status_code=request.status_code)
raise Exception("Failed to disable OLT device in VOLTHA")
+ # NOTE [teo] wait some time after the disable to let VOLTHA doing its things
+ i = 0
+ for i in list(reversed(range(10))):
+ sleep(1)
+ log.info("Deleting the OLT in %s seconds" % i)
+
# Delete the OLT device
request = requests.delete("%s:%d/api/v1/devices/%s/delete" % (voltha['url'], voltha['port'], model.device_id))
diff --git a/xos/synchronizer/steps/test_sync_olt_device.py b/xos/synchronizer/steps/test_sync_olt_device.py
index 0df502f..6fdf546 100644
--- a/xos/synchronizer/steps/test_sync_olt_device.py
+++ b/xos/synchronizer/steps/test_sync_olt_device.py
@@ -67,7 +67,7 @@
# Setting up the config module
from xosconfig import Config
- config = os.path.join(test_path, "../model_policies/test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END setting up the config module
diff --git a/xos/synchronizer/steps/test_sync_onu_device.py b/xos/synchronizer/steps/test_sync_onu_device.py
index 329774a..abd72f7 100644
--- a/xos/synchronizer/steps/test_sync_onu_device.py
+++ b/xos/synchronizer/steps/test_sync_onu_device.py
@@ -49,7 +49,7 @@
# Setting up the config module
from xosconfig import Config
- config = os.path.join(test_path, "../model_policies/test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
diff --git a/xos/synchronizer/steps/test_sync_volt_service_instance.py b/xos/synchronizer/steps/test_sync_volt_service_instance.py
index efc946d..c247178 100644
--- a/xos/synchronizer/steps/test_sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -51,7 +51,7 @@
# Setting up the config module
from xosconfig import Config
- config = os.path.join(test_path, "../model_policies/test_config.yaml")
+ config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
diff --git a/xos/synchronizer/model_policies/test_config.yaml b/xos/synchronizer/test_config.yaml
similarity index 100%
rename from xos/synchronizer/model_policies/test_config.yaml
rename to xos/synchronizer/test_config.yaml