Zsolt Haraszti | ed09160 | 2016-12-08 13:36:38 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016 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 | """ |
| 18 | Tibit OLT device adapter |
| 19 | """ |
| 20 | |
| 21 | import structlog |
| 22 | from zope.interface import implementer |
| 23 | |
Zsolt Haraszti | a17f3ec | 2016-12-08 14:55:49 -0800 | [diff] [blame^] | 24 | from voltha.registry import registry |
Zsolt Haraszti | ed09160 | 2016-12-08 13:36:38 -0800 | [diff] [blame] | 25 | from voltha.adapters.interface import IAdapterInterface |
| 26 | from voltha.protos.adapter_pb2 import Adapter, AdapterConfig |
| 27 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes |
| 28 | from voltha.protos.health_pb2 import HealthStatus |
| 29 | from voltha.protos.common_pb2 import LogLevel |
| 30 | |
| 31 | log = structlog.get_logger() |
| 32 | |
| 33 | |
| 34 | @implementer(IAdapterInterface) |
| 35 | class TibitOltAdapter(object): |
| 36 | |
| 37 | name = 'tibit_olt' |
| 38 | |
| 39 | supported_device_types = [ |
| 40 | DeviceType( |
| 41 | id='tibit_olt', |
| 42 | adapter=name, |
| 43 | accepts_bulk_flow_update=True |
| 44 | ) |
| 45 | ] |
| 46 | |
| 47 | def __init__(self, adapter_agent, config): |
| 48 | self.adapter_agent = adapter_agent |
| 49 | self.config = config |
| 50 | self.descriptor = Adapter( |
| 51 | id=self.name, |
| 52 | vendor='Tibit Communications Inc.', |
| 53 | version='0.1', |
| 54 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 55 | ) |
Zsolt Haraszti | a17f3ec | 2016-12-08 14:55:49 -0800 | [diff] [blame^] | 56 | self.interface = registry('main').get_args().interface |
Zsolt Haraszti | ed09160 | 2016-12-08 13:36:38 -0800 | [diff] [blame] | 57 | |
| 58 | def start(self): |
Zsolt Haraszti | a17f3ec | 2016-12-08 14:55:49 -0800 | [diff] [blame^] | 59 | log.debug('starting', interface=self.interface) |
| 60 | log.info('started', interface=self.interface) |
Zsolt Haraszti | ed09160 | 2016-12-08 13:36:38 -0800 | [diff] [blame] | 61 | |
| 62 | def stop(self): |
| 63 | log.debug('stopping') |
| 64 | log.info('stopped') |
| 65 | |
| 66 | def adapter_descriptor(self): |
| 67 | return self.descriptor |
| 68 | |
| 69 | def device_types(self): |
| 70 | return DeviceTypes(items=self.supported_device_types) |
| 71 | |
| 72 | def health(self): |
| 73 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 74 | |
| 75 | def change_master_state(self, master): |
| 76 | raise NotImplementedError() |
| 77 | |
| 78 | def adopt_device(self, device): |
| 79 | log.info('adopt-device', device=device) |
| 80 | return device |
| 81 | |
| 82 | def abandon_device(self, device): |
| 83 | raise NotImplementedError(0 |
| 84 | ) |
| 85 | def deactivate_device(self, device): |
| 86 | raise NotImplementedError() |
| 87 | |
| 88 | def update_flows_bulk(self, device, flows, groups): |
| 89 | log.debug('bulk-flow-update', device_id=device.id, |
| 90 | flows=flows, groups=groups) |
| 91 | |
| 92 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 93 | raise NotImplementedError() |
| 94 | |
| 95 | def send_proxied_message(self, proxy_address, msg): |
| 96 | log.debug('send-proxied-message', |
| 97 | proxy_address=proxy_address, msg=msg) |
| 98 | |
| 99 | def receive_proxied_message(self, proxy_address, msg): |
| 100 | raise NotImplementedError() |