VOL-2524: Do not use omci link alarms for uni state

ONU sending omci link state alarms do not seem reliable enough
to drive dataplane provisioning.

The problem is two part:

1) omci alarms by default are unset (no alarms).  This includes
uni link state alarms.  This means by default all UNI are up.
Initially this means the core and BAL must provision flows for
ALL uni.

2) Given above the link state for unis is initially all up,
then all down (some staying down),
then one uni with an RG is up again. this messaging churn cause stress in other systems,
most notibly BAL on the olt.

There is a *need* for a down alarm to happen for an up alarm
to mean anything. And if these alarms are not reliably sent by the onu, we cannot depend
on them for provisioning.

Later (15 seconds) alarm reconciliation may pick up the alarm for uni that are permanently down
but if the uni that needs the down-then-up misses the down.. it never gets to act
on the "clear" or up alarm in order to provision.

So we assume all uni are up by default.  Also given there is no operator
requirement for multiple uni (and its load implications on the core), we only enable
the first uni.  Future features may decide how to know which uni to provision.

Also start version 2.3.2-dev

Change-Id: Idc1642bcd67d337c27ac59842d52dc6cc032eb08
diff --git a/VERSION b/VERSION
index 2bf1c1c..4074260 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.1
+2.3.2-dev
diff --git a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
index 4958f60..a5bc1ea 100644
--- a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
+++ b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
@@ -1007,40 +1007,45 @@
     def disable_ports(self, lock_ports=True):
         self.log.info('disable-ports', device_id=self.device_id)
 
-        bus = self._onu_omci_device.event_bus
-        bus.unsubscribe(self._port_state_subscription)
-        self._port_state_subscription = None
-
-        # Disable all ports on that device
+        # TODO: for now only support the first UNI given no requirement for multiple uni yet. Also needed to reduce flow
+        #  load on the core
         for port in self.uni_ports:
-            port.operstatus = OperStatus.UNKNOWN
-            self.log.info('disable-port', device_id=self.device_id, port=port)
+            if port.mac_bridge_port_num == 1:
+                port.operstatus = OperStatus.UNKNOWN
+                self.log.info('disable-port', device_id=self.device_id, port=port)
+                yield self.core_proxy.port_state_update(self.device_id, Port.ETHERNET_UNI, port.port_number, port.operstatus)
 
         if lock_ports is True:
             self.lock_ports(lock=True)
 
-        yield self.core_proxy.ports_state_update(self.device_id, OperStatus.UNKNOWN)
-
     @inlineCallbacks
     def enable_ports(self):
         self.log.info('enable-ports', device_id=self.device_id)
 
-        # Listen for UNI link state alarms and set the oper_state based on that rather than assuming all UNI are up
-        bus = self._onu_omci_device.event_bus
-        topic = OnuDeviceEntry.event_bus_topic(self.device_id,
-                                               OnuDeviceEvents.PortEvent)
-        self._port_state_subscription = bus.subscribe(topic, self.port_state_handler)
         self.lock_ports(lock=False)
 
-        # TODO: Currently the only VEIP capable ONU i can test with does not send UNI link state alarms
-        #  or set operational-state per OMCI spec.  So i have know way of "knowing" if the port is up.
-        #  Given this i assume its always up for now.  Maybe a software upgrade will fix my onu...
+        # TODO: for now only support the first UNI given no requirement for multiple uni yet. Also needed to reduce flow
+        #  load on the core
+        # Given by default all unis are initially active according to omci alarming, we must mimic this.
         for port in self.uni_ports:
-            if port.type.value == UniType.VEIP.value:
+            if port.mac_bridge_port_num == 1:
                 port.operstatus = OperStatus.ACTIVE
-                self.log.warn('force-showing-veip-link-up', device_id=self.device_id, port=port)
+                self.log.info('enable-port', device_id=self.device_id, port=port)
                 yield self.core_proxy.port_state_update(self.device_id, Port.ETHERNET_UNI, port.port_number, port.operstatus)
 
+
+    # TODO: Normally we would want any uni ethernet link down or uni ethernet link up alarms to register in the core,
+    #  but practically olt provisioning cannot handle the churn of links up, down, then up again typical on startup.
+    #
+    # Basically the link state sequence:
+    # 1) per omci default alarm state, all unis are initially up (no link down alarms received yet)
+    # 2) a link state down alarm is received for all uni, given the lock command, and also because most unis have nothing plugged in
+    # 3) a link state up alarm is received for the uni plugged in.
+    #
+    # Given the olt (BAL) has to provision all uni, de-provision all uni, and re-provision one uni in quick succession
+    # and cannot (bug?), we have to skip this and leave uni ports as assumed active.  Also all the link state activity
+    # would have a ripple effect through the core to the controller as well.  And is it really worth it?
+    '''
     @inlineCallbacks
     def port_state_handler(self, _topic, msg):
         self.log.info("port-state-change", _topic=_topic, msg=msg)
@@ -1062,24 +1067,31 @@
             self.log.info('link-down', device_id=self.device_id, port=uni_port)
 
         yield self.core_proxy.port_state_update(self.device_id, Port.ETHERNET_UNI, uni_port.port_number, uni_port.operstatus)
+    '''
 
     # Called just before openomci state machine is started.  These listen for events from selected state machines,
     # most importantly, mib in sync.  Which ultimately leads to downloading the mib
     def _subscribe_to_events(self):
         self.log.debug('subscribe-to-events')
 
-        # OMCI MIB Database sync status
         bus = self._onu_omci_device.event_bus
+
+        # OMCI MIB Database sync status
         topic = OnuDeviceEntry.event_bus_topic(self.device_id,
                                                OnuDeviceEvents.MibDatabaseSyncEvent)
         self._in_sync_subscription = bus.subscribe(topic, self.in_sync_handler)
 
         # OMCI Capabilities
-        bus = self._onu_omci_device.event_bus
         topic = OnuDeviceEntry.event_bus_topic(self.device_id,
                                                OnuDeviceEvents.OmciCapabilitiesEvent)
         self._capabilities_subscription = bus.subscribe(topic, self.capabilties_handler)
 
+        # TODO: these alarms seem to be unreliable depending on the environment
+        # Listen for UNI link state alarms and set the oper_state based on that rather than assuming all UNI are up
+        #topic = OnuDeviceEntry.event_bus_topic(self.device_id,
+        #                                       OnuDeviceEvents.PortEvent)
+        #self._port_state_subscription = bus.subscribe(topic, self.port_state_handler)
+
     # Called when the mib is in sync
     def in_sync_handler(self, _topic, msg):
         self.log.debug('in-sync-handler', _topic=_topic, msg=msg)