Support for Voltha 2.x with only 1 UNI per ONU
With this patch only one UNI per ONU is supported.
The UNI has to be the one with portname (in ONOS) that ends with '-1'.
All the other ports with related events coming from ONOS on the Kafka
topic onu.events are not considered.
Change-Id: I8c250a9a30e53cfbdf41c9810917c92dd95bcbad
diff --git a/VERSION b/VERSION
index 3eefcb9..336c367 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+1.1.0-dev
diff --git a/xos/synchronizer/event_steps/onu_event.py b/xos/synchronizer/event_steps/onu_event.py
index 9f342df..16d0c0c 100755
--- a/xos/synchronizer/event_steps/onu_event.py
+++ b/xos/synchronizer/event_steps/onu_event.py
@@ -31,6 +31,11 @@
def process_event(self, event):
value = json.loads(event.value)
self.log.info("onu.events: received event", value=value)
+ # This is needed to be compatible with both Voltha 1.7 and Voltha 2.x
+ # It supposes to have only 1 subscriber per ONU and the subscriber is connected to the first port
+ if "-" in value["serialNumber"] and not value["serialNumber"].endswith("-1"):
+ self.log.info("Skip event, only consider [serialNumber]-1 events")
+ return
dt_si = DtHelpers.find_or_create_dt_si(self.model_accessor, self.log, value)
if value["status"] == "activated":
diff --git a/xos/synchronizer/helpers.py b/xos/synchronizer/helpers.py
index 3cbedb8..d228890 100755
--- a/xos/synchronizer/helpers.py
+++ b/xos/synchronizer/helpers.py
@@ -40,7 +40,7 @@
whitelisted = matching_entries[0]
try:
- onu = model_accessor.ONUDevice.objects.get(serial_number=dt_si.serial_number)
+ onu = model_accessor.ONUDevice.objects.get(serial_number=dt_si.serial_number.split("-")[0])
pon_port = onu.pon_port
except IndexError:
raise DeferredException("ONU device %s is not know to XOS yet" % dt_si.serial_number)
@@ -65,7 +65,8 @@
def find_or_create_dt_si(model_accessor, log, event):
try:
dt_si = model_accessor.DtWorkflowDriverServiceInstance.objects.get(
- serial_number=event["serialNumber"]
+ # FIXME: in this way we support a single UNI port per ONU
+ serial_number=event["serialNumber"].split("-")[0]
)
log.debug("DtHelpers: Found existing DtWorkflowDriverServiceInstance", si=dt_si)
except IndexError:
diff --git a/xos/synchronizer/model_policies/model_policy_dt_workflow_driver_serviceinstance.py b/xos/synchronizer/model_policies/model_policy_dt_workflow_driver_serviceinstance.py
index f885459..0248b44 100755
--- a/xos/synchronizer/model_policies/model_policy_dt_workflow_driver_serviceinstance.py
+++ b/xos/synchronizer/model_policies/model_policy_dt_workflow_driver_serviceinstance.py
@@ -98,19 +98,19 @@
si.authentication_state = "AWAITING"
def update_onu(self, serial_number, admin_state):
- onu = [onu for onu in self.model_accessor.ONUDevice.objects.all() if onu.serial_number.lower()
- == serial_number.lower()][0]
+ onu = [onu for onu in self.model_accessor.ONUDevice.objects.all()
+ if onu.serial_number.lower() == serial_number.lower().split('-')[0]][0]
if onu.admin_state == "ADMIN_DISABLED":
self.logger.debug(
"MODEL_POLICY: ONUDevice [%s] has been manually disabled, not changing state to %s" %
- (serial_number, admin_state))
+ (onu.serial_number, admin_state))
return
if onu.admin_state == admin_state:
self.logger.debug(
"MODEL_POLICY: ONUDevice [%s] already has admin_state to %s" %
- (serial_number, admin_state))
+ (onu.serial_number, admin_state))
else:
- self.logger.debug("MODEL_POLICY: setting ONUDevice [%s] admin_state to %s" % (serial_number, admin_state))
+ self.logger.debug("MODEL_POLICY: setting ONUDevice [%s] admin_state to %s" % (onu.serial_number, admin_state))
onu.admin_state = admin_state
onu.save_changed_fields(always_update_timestamp=True)