VOL-1495: Implement new tech profile interadapter message
Handle ia message type for pushing tech profiles info to the onu.
Remove old ia message style handler.
Update uni port lookup function to properly find affected uni
for flow pushes. Do not compare logical port name/id. Use actual assigned id
These changes allow load tech profile and update_flow_table to work,
resulting in successful OMCI message exchange for both tech profile
task and vlan filter task.
Change-Id: I0fed35182a498362fb7f4f349e4599fb2c9d3483
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 a58a870..8a6cad6 100644
--- a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
+++ b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
@@ -37,7 +37,8 @@
from pyvoltha.common.config.config_backend import EtcdStore
from voltha_protos.common_pb2 import OperStatus, ConnectStatus, AdminState
from voltha_protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port, OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD
-from voltha_protos.inter_container_pb2 import InterAdapterMessageType, InterAdapterOmciMessage, PortCapability
+from voltha_protos.inter_container_pb2 import InterAdapterMessageType, \
+ InterAdapterOmciMessage, PortCapability, InterAdapterTechProfileDownloadMessage
from voltha_protos.openolt_pb2 import OnuIndication
from pyvoltha.adapters.extensions.omci.onu_configuration import OMCCVersion
from pyvoltha.adapters.extensions.omci.onu_device_entry import OnuDeviceEvents, \
@@ -122,9 +123,6 @@
self.log.error('Invalid-backend')
raise Exception("Invalid-backend-for-kv-store")
- # Handle received ONU event messages
- reactor.callLater(0, self.handle_onu_events)
-
@property
def enabled(self):
return self._enabled
@@ -157,7 +155,7 @@
assert isinstance(port_no_or_name, int), 'Invalid parameter type'
return next((uni for uni in self.uni_ports
- if uni.logical_port_number == port_no_or_name), None)
+ if uni.port_number == port_no_or_name), None)
@property
def pon_port(self):
@@ -289,21 +287,6 @@
self.log.info('onu-already-activated')
@inlineCallbacks
- def handle_onu_events(self):
- event_msg = yield self.event_messages.get()
- try:
- if event_msg['event'] == 'download_tech_profile':
- tp_path = event_msg['event_data']
- uni_id = event_msg['uni_id']
- self.load_and_configure_tech_profile(uni_id, tp_path)
-
- except Exception as e:
- self.log.error("exception-handling-onu-event", e=e)
-
- # Handle next event
- reactor.callLater(0, self.handle_onu_events)
-
- @inlineCallbacks
def _init_pon_state(self, device):
self.log.debug('function-entry', device=device)
@@ -681,6 +664,13 @@
else:
self.log.error("unknown-onu-indication", onu_indication=onu_indication)
+ elif request.header.type == InterAdapterMessageType.TECH_PROFILE_DOWNLOAD_REQUEST:
+ tech_msg = InterAdapterTechProfileDownloadMessage()
+ request.body.Unpack(tech_msg)
+ self.log.debug('inter-adapter-recv-tech-profile', tech_msg=tech_msg)
+
+ self.load_and_configure_tech_profile(tech_msg.uni_id, tech_msg.path)
+
else:
self.log.error("inter-adapter-unhandled-type", request=request)
diff --git a/python/adapters/brcm_openomci_onu/uni_port.py b/python/adapters/brcm_openomci_onu/uni_port.py
index 9ee3198..33fbf61 100644
--- a/python/adapters/brcm_openomci_onu/uni_port.py
+++ b/python/adapters/brcm_openomci_onu/uni_port.py
@@ -45,7 +45,6 @@
self._port = None
self._port_number = port_no
self._ofp_port_no = ofp_port_no
- self._logical_port_number = None
self._entity_id = None
self._mac_bridge_port_num = 0
self._type = type
@@ -143,14 +142,6 @@
self._entity_id = value
@property
- def logical_port_number(self):
- """
- Logical device port number (used as OpenFlow port for UNI)
- :return: (int) port number
- """
- return self._logical_port_number
-
- @property
def type(self):
"""
UNI Type used in OMCI messaging
@@ -173,55 +164,3 @@
def port_id_name(self):
return 'uni-{}'.format(self._port_number)
- def add_logical_port(self, openflow_port_no, multi_uni_naming,
- capabilities=OFPPF_10GB_FD | OFPPF_FIBER,
- speed=OFPPF_10GB_FD):
-
- self.log.debug('function-entry')
-
- if self._logical_port_number is not None:
- # delete old logical port if it exists
- try:
- port = self._handler.adapter_agent.get_logical_port(self._handler.logical_device_id,
- self.port_id_name())
- self._handler.adapter_agent.delete_logical_port(self._handler.logical_device_id, port)
-
- except Exception as e:
- # assume this exception was because logical port does not already exist
- pass
-
- self._logical_port_number = None
-
- port_no = openflow_port_no or self._ofp_port_no
-
- if self._logical_port_number is None and port_no is not None:
- self._logical_port_number = port_no
-
- device = self._handler.adapter_agent.get_device(self._handler.device_id)
-
- # leave the ports down until omci mib download has finished. otherwise flows push before time
- openflow_port = ofp_port(
- port_no=port_no,
- hw_addr=mac_str_to_tuple('08:%02x:%02x:%02x:%02x:%02x' %
- ((device.parent_port_no >> 8 & 0xff),
- device.parent_port_no & 0xff,
- (port_no >> 16) & 0xff,
- (port_no >> 8) & 0xff,
- port_no & 0xff)),
- name=device.serial_number + ['', '-' + str(self._mac_bridge_port_num)][multi_uni_naming],
- config=0,
- state=OFPPS_LINK_DOWN,
- curr=capabilities,
- advertised=capabilities,
- peer=capabilities,
- curr_speed=speed,
- max_speed=speed
- )
- self._handler.adapter_agent.add_logical_port(self._handler.logical_device_id,
- LogicalPort(
- id=self.port_id_name(),
- ofp_port=openflow_port,
- device_id=device.id,
- device_port_no=self._port_number))
-
- self.log.debug('logical-port', id=self.port_id_name(), device_port_no=self._port_number, openflow_port=openflow_port)