[SEBA-110] Validation location
Change-Id: Idd155c05fa4cac5eb0733576c5c0fae74925e1ef
diff --git a/xos/synchronizer/steps/sync_att_workflow_driver_service_instance.py b/xos/synchronizer/steps/sync_att_workflow_driver_service_instance.py
index d2fdeeb..1726e50 100644
--- a/xos/synchronizer/steps/sync_att_workflow_driver_service_instance.py
+++ b/xos/synchronizer/steps/sync_att_workflow_driver_service_instance.py
@@ -14,7 +14,7 @@
import json
from synchronizers.new_base.syncstep import SyncStep, model_accessor
-from synchronizers.new_base.modelaccessor import AttWorkflowDriverServiceInstance, AttWorkflowDriverWhiteListEntry
+from synchronizers.new_base.modelaccessor import AttWorkflowDriverServiceInstance, AttWorkflowDriverWhiteListEntry, ONUDevice
from xosconfig import Config
from multistructlog import create_logger
@@ -25,7 +25,7 @@
provides = [AttWorkflowDriverServiceInstance]
observes = AttWorkflowDriverServiceInstance
- def validate_in_external_oss(self, si):
+ def validate_onu(self, si):
# This is where you may want to call your OSS Database to verify if this ONU can be activated
oss_service = si.owner.leaf_model
@@ -34,30 +34,30 @@
matching_entries = AttWorkflowDriverWhiteListEntry.objects.filter(owner_id=oss_service.id,
serial_number=si.serial_number)
- return len(matching_entries)>0
+ # check that it's in the whitelist
+ if len(matching_entries) == 0:
+ log.warn("ONU disable as not in whitelist", object=str(si), serial_number=si.serial_number, **si.tologdict())
+ return False
- def get_suscriber_c_tag(self, serial_number):
- # If it's up to your OSS to generate c_tags, fetch them here
- # otherwise XOS will generate one for your subscriber
- return None
+ whitelisted = matching_entries[0]
+ pon_port = ONUDevice.objects.get().pon_port
+ if pon_port.port_no != whitelisted.pon_port_id or si.of_dpid != whitelisted.device_id:
+ log.warn("ONU disable as location don't match", object=str(si), serial_number=si.serial_number,
+ **si.tologdict())
+ return False
- def sync_record(self, o):
- log.info("synching AttWorkflowDriverServiceInstance", object=str(o), **o.tologdict())
+ return True
- if not self.validate_in_external_oss(o):
- log.error("ONU with serial number %s is not valid in the OSS Database" % o.serial_number)
- o.valid = "invalid"
+ def sync_record(self, si):
+ log.info("synching AttWorkflowDriverServiceInstance", object=str(si), **si.tologdict())
+
+ if not self.validate_onu(si):
+ log.error("ONU with serial number %s is not valid in the OSS Database" % si.serial_number)
+ si.valid = "invalid"
else:
- if self.get_suscriber_c_tag(o.serial_number):
- self.c_tag = self.get_suscriber_c_tag(o.serial_number)
+ si.valid = "valid"
- o.valid = "valid"
-
- # Set no_sync=True to prevent the syncstep from running again, and set alway_update_timestamp=True to cause
- # the model_policy to run again.
- # TODO(smbaker): Revisit this after fixing this issue in the core.
- o.no_sync = True
- o.save(update_fields=["valid", "no_sync", "updated"], always_update_timestamp=True)
+ si.save()
def delete_record(self, o):
pass