blob: 1b1f284752129181bf21c74c7bbea6390342815f [file] [log] [blame]
Shad Ansari2fc48642017-06-10 01:40:32 -07001#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17"""
18Asfvolt16 OLT adapter
19"""
20
Shad Ansarib32e31c2017-06-28 01:55:50 -070021import structlog
Shad Ansarid1aa9e72017-06-23 21:34:25 -070022from voltha.adapters.iadapter import OltAdapter
Shad Ansarid8194f82017-07-04 10:19:37 -070023from voltha.adapters.asfvolt16_olt.asfvolt16_device_handler import Asfvolt16Handler
rshettye4bd2ed2017-07-19 16:38:11 +053024from voltha.adapters.asfvolt16_olt.asfvolt16_rx_handler import Asfvolt16RxHandler
Shad Ansarib32e31c2017-06-28 01:55:50 -070025
26log = structlog.get_logger()
Shad Ansari2fc48642017-06-10 01:40:32 -070027
rshettyc26a3c32017-07-27 11:06:38 +053028
Shad Ansarid1aa9e72017-06-23 21:34:25 -070029class Asfvolt16Adapter(OltAdapter):
Shad Ansari2fc48642017-06-10 01:40:32 -070030 def __init__(self, adapter_agent, config):
Shad Ansari14bcd992017-06-13 14:27:20 -070031 super(Asfvolt16Adapter, self).__init__(adapter_agent=adapter_agent,
32 config=config,
rshettyc26a3c32017-07-27 11:06:38 +053033 device_handler_class=Asfvolt16Handler,
Shad Ansari14bcd992017-06-13 14:27:20 -070034 name='asfvolt16_olt',
35 vendor='Edgecore',
sathishgf33c6162017-11-27 10:15:14 +053036 version='0.94',
Nikolay Titov89004ec2017-06-19 18:22:42 -040037 device_type='asfvolt16_olt')
Shad Ansari2fc48642017-06-10 01:40:32 -070038 # register for adapter messages
rshettye4bd2ed2017-07-19 16:38:11 +053039 self.port = 60001
40 self.rx_handler = Asfvolt16RxHandler(self, self.port, log)
41 self.rx_handler.start()
Shad Ansari2fc48642017-06-10 01:40:32 -070042 self.adapter_agent.register_for_inter_adapter_messages()
rshettye4bd2ed2017-07-19 16:38:11 +053043
44 def stop(self):
45 self.rx_handler.stop()
rshetty1cc73982017-09-02 03:31:12 +053046
47 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
48 log.info('create-tcont', device_id=device.id)
49 if device.id in self.devices_handlers:
50 handler = self.devices_handlers[device.id]
51 if handler is not None:
52 handler.create_tcont(tcont_data, traffic_descriptor_data)
53
54 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
55 log.info('update-tcont', device_id=device.id)
56 if device.id in self.devices_handlers:
57 handler = self.devices_handlers[device.id]
58 if handler is not None:
59 handler.update_tcont(tcont_data, traffic_descriptor_data)
60
61 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
62 log.info('remove-tcont', device_id=device.id)
63 if device.id in self.devices_handlers:
64 handler = self.devices_handlers[device.id]
65 if handler is not None:
66 handler.remove_tcont(tcont_data, traffic_descriptor_data)
67
68 def create_gemport(self, device, data):
69 log.info('create-gemport', device_id=device.id)
70 if device.id in self.devices_handlers:
71 handler = self.devices_handlers[device.id]
72 if handler is not None:
73 handler.create_gemport(data)
74
75 def update_gemport(self, device, data):
76 log.info('update-gemport', device_id=device.id)
77 if device.id in self.devices_handlers:
78 handler = self.devices_handlers[device.id]
79 if handler is not None:
80 handler.update_gemport(data)
81
82 def remove_gemport(self, device, data):
83 log.info('remove-gemport', device_id=device.id)
84 if device.id in self.devices_handlers:
85 handler = self.devices_handlers[device.id]
86 if handler is not None:
87 handler.remove_gemport(data)