VOL-1291 - Tellabs OpenOMCI ONU Adapter
Added Tellabs ONU Adapter derived from Broadcom OpenOMCI adapter to provide
hooks for custom OMCI MEs and other specialization as neccesary
Change-Id: Id4584361cd83862cbdc2819e2981f8ea4aa229bd
diff --git a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu.py b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu.py
index b7af15e..0f07fa4 100644
--- a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu.py
+++ b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu.py
@@ -81,20 +81,25 @@
#self.broadcom_omci['mib-synchronizer']['tasks']['mib-audit'] = BrcmGetMdsTask
self.broadcom_omci['omci-capabilities']['tasks']['get-capabilities'] = BrcmCapabilitiesTask
- self._omci_agent = OpenOMCIAgent(self.adapter_agent.core,
- support_classes=self.broadcom_omci)
-
+ # Defer creation of omci agent to a lazy init that allows subclasses to override support classes
# register for adapter messages
self.adapter_agent.register_for_inter_adapter_messages()
+ def custom_me_entities(self):
+ return None
+
@property
def omci_agent(self):
+ if not hasattr(self, '_omci_agent') or self._omci_agent is None:
+ log.debug('creating-omci-agent')
+ self._omci_agent = OpenOMCIAgent(self.adapter_agent.core,
+ support_classes=self.broadcom_omci)
return self._omci_agent
def start(self):
log.debug('starting')
- self._omci_agent.start()
+ self.omci_agent.start()
log.info('started')
def stop(self):
diff --git a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
index fa2a2dc..dcc123e 100644
--- a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
+++ b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
@@ -228,7 +228,8 @@
# Create and start the OpenOMCI ONU Device Entry for this ONU
self._onu_omci_device = self.omci_agent.add_device(self.device_id,
self.adapter_agent,
- support_classes=self.adapter.broadcom_omci)
+ support_classes=self.adapter.broadcom_omci,
+ custom_me_map=self.adapter.custom_me_entities())
# Port startup
if self._pon is not None:
self._pon.enabled = True
diff --git a/voltha/adapters/tellabs_openomci_onu/__init__.py b/voltha/adapters/tellabs_openomci_onu/__init__.py
new file mode 100755
index 0000000..b0fb0b2
--- /dev/null
+++ b/voltha/adapters/tellabs_openomci_onu/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/voltha/adapters/tellabs_openomci_onu/omci/__init__.py b/voltha/adapters/tellabs_openomci_onu/omci/__init__.py
new file mode 100644
index 0000000..b0fb0b2
--- /dev/null
+++ b/voltha/adapters/tellabs_openomci_onu/omci/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/voltha/adapters/tellabs_openomci_onu/omci/omci_entities.py b/voltha/adapters/tellabs_openomci_onu/omci/omci_entities.py
new file mode 100644
index 0000000..6929fa9
--- /dev/null
+++ b/voltha/adapters/tellabs_openomci_onu/omci/omci_entities.py
@@ -0,0 +1,54 @@
+# Copyright 2018-present Tellabs, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+""" Tellabs vendor-specific OMCI Entities"""
+
+import inspect
+import structlog
+import sys
+
+from scapy.fields import ShortField, IntField, ByteField, StrFixedLenField
+from voltha.extensions.omci.omci_entities import EntityClassAttribute, \
+ AttributeAccess, OmciNullPointer, EntityOperations, EntityClass
+
+log = structlog.get_logger()
+
+# abbreviations
+ECA = EntityClassAttribute
+AA = AttributeAccess
+OP = EntityOperations
+
+#################################################################################
+# entity class lookup table from entity_class values
+_onu_entity_classes_name_map = dict(
+ inspect.getmembers(sys.modules[__name__], lambda o:
+ inspect.isclass(o) and issubclass(o, EntityClass) and o is not EntityClass)
+)
+_onu_custom_entity_classes = [c for c in _onu_entity_classes_name_map.itervalues()]
+_onu_custom_entity_id_to_class_map = dict()
+
+
+def onu_custom_me_entities():
+ log.info('onu_custom_me_entities')
+
+ if len(_onu_custom_entity_id_to_class_map) == 0:
+ for entity_class in _onu_custom_entity_classes:
+ log.info('adding-custom-me', class_id=entity_class.class_id)
+ assert entity_class.class_id not in _onu_custom_entity_id_to_class_map, \
+ "Class ID '{}' already exists in the class map".format(entity_class.class_id)
+ _onu_custom_entity_id_to_class_map[entity_class.class_id] = entity_class
+
+ log.info('onu_custom_me_entities', map=_onu_custom_entity_id_to_class_map)
+ return _onu_custom_entity_id_to_class_map
+
diff --git a/voltha/adapters/tellabs_openomci_onu/tellabs_openomci_onu.py b/voltha/adapters/tellabs_openomci_onu/tellabs_openomci_onu.py
new file mode 100755
index 0000000..c1cf775
--- /dev/null
+++ b/voltha/adapters/tellabs_openomci_onu/tellabs_openomci_onu.py
@@ -0,0 +1,83 @@
+#
+# Copyright 2017-present Tellabs, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Tellabs OpenOMCI OLT/ONU adapter.
+"""
+
+from twisted.internet import reactor, task
+from zope.interface import implementer
+
+from voltha.adapters.brcm_openomci_onu.brcm_openomci_onu import BrcmOpenomciOnuAdapter
+from voltha.adapters.brcm_openomci_onu.brcm_openomci_onu_handler import BrcmOpenomciOnuHandler
+from voltha.adapters.interface import IAdapterInterface
+from voltha.protos import third_party
+from voltha.protos.adapter_pb2 import Adapter
+from voltha.protos.adapter_pb2 import AdapterConfig
+from voltha.protos.common_pb2 import LogLevel
+from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image
+from voltha.protos.health_pb2 import HealthStatus
+
+from common.frameio.frameio import hexify
+from voltha.extensions.omci.openomci_agent import OpenOMCIAgent, OpenOmciAgentDefaults
+from voltha.extensions.omci.omci_me import *
+from voltha.extensions.omci.database.mib_db_dict import MibDbVolatileDict
+from voltha.adapters.brcm_openomci_onu.omci.brcm_capabilities_task import BrcmCapabilitiesTask
+from voltha.adapters.brcm_openomci_onu.omci.brcm_get_mds_task import BrcmGetMdsTask
+from voltha.adapters.brcm_openomci_onu.omci.brcm_mib_sync import BrcmMibSynchronizer
+from copy import deepcopy
+
+from omci.omci_entities import onu_custom_me_entities
+
+from voltha.extensions.omci.database.mib_db_ext import MibDbExternal
+
+_ = third_party
+log = structlog.get_logger()
+
+
+@implementer(IAdapterInterface)
+class TellabsOpenomciOnuAdapter(BrcmOpenomciOnuAdapter):
+
+ name = 'tellabs_openomci_onu'
+
+ supported_device_types = [
+ DeviceType(
+ id=name,
+ vendor_ids=['BFWS', 'TSLS', 'IPHO', 'SHGJ'],
+ adapter=name,
+ accepts_bulk_flow_update=True
+ )
+ ]
+
+ def __init__(self, adapter_agent, config):
+ super(TellabsOpenomciOnuAdapter, self).__init__(adapter_agent, config)
+
+ self.descriptor = Adapter(
+ id=self.name,
+ vendor='Tellabs Inc.',
+ version='0.1',
+ config=AdapterConfig(log_level=LogLevel.INFO)
+ )
+ log.info('tellabs_openomci_onu.__init__', adapter=self.descriptor)
+
+ self.broadcom_omci['mib-synchronizer']['database'] = MibDbExternal
+
+ def device_types(self):
+ return DeviceTypes(items=self.supported_device_types)
+
+ def custom_me_entities(self):
+ return onu_custom_me_entities()
+