[SEBA-423] Make admin_state purely declarative
Change-Id: I82c6951eba8f2a82a9bb58f672724879b44c1873
diff --git a/xos/synchronizer/pull_steps/pull_onus.py b/xos/synchronizer/pull_steps/pull_onus.py
index 4f66304..c94e956 100644
--- a/xos/synchronizer/pull_steps/pull_onus.py
+++ b/xos/synchronizer/pull_steps/pull_onus.py
@@ -78,17 +78,12 @@
model = ONUDevice.objects.filter(serial_number=onu["serial_number"])[0]
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)
- # if we are not updating the device we still need to pull ports
- self.fetch_onu_ports(model)
- continue
-
except IndexError:
model = ONUDevice()
model.serial_number = onu["serial_number"]
+ model.admin_state = onu["admin_state"]
- log.debug("ONUDevice is new, creating it", serial_number=onu["serial_number"])
+ log.debug("ONUDevice is new, creating it", serial_number=onu["serial_number"], admin_state=onu["admin_state"])
try:
olt = OLTDevice.objects.get(device_id=onu["parent_id"])
@@ -107,7 +102,6 @@
model.device_type = onu["type"]
model.device_id = onu["id"]
- model.admin_state = onu["admin_state"]
model.oper_status = onu["oper_status"]
model.connect_status = onu["connect_status"]
model.reason = onu["reason"]
@@ -116,7 +110,7 @@
model.pon_port = pon_port
model.pon_port_id = pon_port.id
- model.save()
+ model.save_changed_fields()
self.fetch_onu_ports(model)
@@ -200,7 +194,7 @@
model.admin_state = port["admin_state"]
model.oper_status = port["oper_status"]
- model.save()
+ model.save_changed_fields()
update_ports.append(model)
return update_ports
@@ -222,6 +216,6 @@
model.admin_state = port["admin_state"]
model.oper_status = port["oper_status"]
- model.save()
+ model.save_changed_fields()
update_ports.append(model)
return update_ports