William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2018 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 | Openolt adapter. |
| 19 | """ |
| 20 | import arrow |
| 21 | import grpc |
| 22 | import structlog |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 23 | |
| 24 | from zope.interface import implementer |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 25 | from google.protobuf.empty_pb2 import Empty |
| 26 | from google.protobuf.json_format import MessageToDict |
| 27 | from scapy.layers.inet import Raw |
| 28 | import json |
| 29 | from google.protobuf.message import Message |
| 30 | from grpc._channel import _Rendezvous |
| 31 | from scapy.layers.l2 import Ether, Dot1Q |
| 32 | from simplejson import dumps |
| 33 | from twisted.internet import reactor |
| 34 | from twisted.internet.defer import inlineCallbacks, returnValue |
| 35 | from twisted.internet.task import LoopingCall |
| 36 | |
William Kurkian | 44cd7bb | 2019-02-11 16:39:12 -0500 | [diff] [blame] | 37 | from pyvoltha.adapters.common.frameio.frameio import BpfProgramFilter, hexify |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 38 | from pyvoltha.adapters.iadapter import IAdapterInterface |
William Kurkian | 44cd7bb | 2019-02-11 16:39:12 -0500 | [diff] [blame] | 39 | from pyvoltha.common.utils.asleep import asleep |
| 40 | from pyvoltha.common.utils.registry import registry |
| 41 | from pyvoltha.adapters.kafka.kafka_proxy import get_kafka_proxy |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 42 | from voltha_protos import openolt_pb2 |
| 43 | #from voltha_protos import third_party |
| 44 | from voltha_protos.common_pb2 import OperStatus, ConnectStatus |
| 45 | from voltha_protos.common_pb2 import LogLevel |
| 46 | from voltha_protos.common_pb2 import OperationResp |
| 47 | from voltha_protos.inter_container_pb2 import SwitchCapability, PortCapability, \ |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 48 | InterAdapterMessageType, InterAdapterResponseBody |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 49 | from voltha_protos.device_pb2 import Port, PmConfig, PmConfigs, \ |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 50 | DeviceType, DeviceTypes |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 51 | from voltha_protos.adapter_pb2 import Adapter |
| 52 | from voltha_protos.adapter_pb2 import AdapterConfig |
William Kurkian | 3350875 | 2019-02-12 14:56:06 -0500 | [diff] [blame] | 53 | from openolt_flow_mgr import OpenOltFlowMgr |
| 54 | from openolt_alarms import OpenOltAlarmMgr |
| 55 | from openolt_statistics import OpenOltStatisticsMgr |
| 56 | from openolt_bw import OpenOltBW |
| 57 | from openolt_platform import OpenOltPlatform |
| 58 | from openolt_resource_manager import OpenOltResourceMgr |
| 59 | from openolt_device import OpenoltDevice |
Matt Jeanneret | 9fd36df | 2019-02-14 19:14:36 -0500 | [diff] [blame] | 60 | |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 61 | from voltha_protos.events_pb2 import KpiEvent, KpiEventType, MetricValuePairs |
| 62 | from voltha_protos.logical_device_pb2 import LogicalPort |
| 63 | from voltha_protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, \ |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 64 | OFPPF_1GB_FD, \ |
| 65 | OFPC_GROUP_STATS, OFPC_PORT_STATS, OFPC_TABLE_STATS, OFPC_FLOW_STATS, \ |
| 66 | ofp_switch_features, ofp_desc |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 67 | from voltha_protos.openflow_13_pb2 import ofp_port |
Arun Arora | 75e6bb2 | 2019-03-07 13:57:31 +0000 | [diff] [blame] | 68 | from pyvoltha.common.utils.nethelpers import mac_str_to_tuple |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 69 | |
William Kurkian | 8b1690c | 2019-03-04 16:53:22 -0500 | [diff] [blame] | 70 | #_ = third_party |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 71 | log = structlog.get_logger() |
William Kurkian | fefd464 | 2019-02-07 15:30:03 -0500 | [diff] [blame] | 72 | OpenOltDefaults = { |
| 73 | 'support_classes': { |
| 74 | 'platform': OpenOltPlatform, |
| 75 | 'resource_mgr': OpenOltResourceMgr, |
| 76 | 'flow_mgr': OpenOltFlowMgr, |
| 77 | 'alarm_mgr': OpenOltAlarmMgr, |
| 78 | 'stats_mgr': OpenOltStatisticsMgr, |
| 79 | 'bw_mgr': OpenOltBW |
| 80 | } |
| 81 | } |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 82 | |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 83 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 84 | @implementer(IAdapterInterface) |
| 85 | class OpenoltAdapter(object): |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 86 | name = 'openolt' |
| 87 | |
| 88 | supported_device_types = [ |
| 89 | DeviceType( |
| 90 | id=name, |
| 91 | adapter=name, |
| 92 | accepts_bulk_flow_update=True, |
| 93 | accepts_add_remove_flow_updates=True |
| 94 | ) |
| 95 | ] |
| 96 | |
| 97 | # System Init Methods # |
| 98 | def __init__(self, core_proxy, adapter_proxy, config): |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 99 | self.adapter_proxy = adapter_proxy |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 100 | self.adapter_agent = core_proxy |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 101 | self.config = config |
| 102 | self.descriptor = Adapter( |
| 103 | id=self.name, |
| 104 | vendor='OLT white box vendor', |
| 105 | version='0.1', |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 106 | config=AdapterConfig(log_level=LogLevel.INFO) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 107 | ) |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 108 | log.debug('openolt.__init__', adapter_agent=adapter_proxy) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 109 | self.devices = dict() # device_id -> OpenoltDevice() |
| 110 | self.interface = registry('main').get_args().interface |
| 111 | self.logical_device_id_to_root_device_id = dict() |
| 112 | self.num_devices = 0 |
Arun Arora | 75e6bb2 | 2019-03-07 13:57:31 +0000 | [diff] [blame] | 113 | self.ofp_port_no = None |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 114 | |
| 115 | def start(self): |
| 116 | log.info('started', interface=self.interface) |
| 117 | |
| 118 | def stop(self): |
| 119 | log.info('stopped', interface=self.interface) |
| 120 | |
Arun Arora | 75e6bb2 | 2019-03-07 13:57:31 +0000 | [diff] [blame] | 121 | def get_ofp_device_info(self, device): |
| 122 | log.info('get_ofp_device_info', device_id=device.id) |
| 123 | return SwitchCapability( |
| 124 | desc=ofp_desc( |
| 125 | hw_desc='white box OLT', # Hardware description |
| 126 | sw_desc='openolt', # Software description |
| 127 | serial_num=device.serial_number, # Serial number |
| 128 | dp_desc='n/a' # Human readable description of datapath |
| 129 | ), |
| 130 | switch_features=ofp_switch_features( |
| 131 | n_buffers=256, # Max packets buffered at once # TODO fake for now |
| 132 | n_tables=2, # Number of tables supported by datapath # TODO fake for now |
| 133 | capabilities=( #Bitmap of support "ofp_capabilities" # TODO fake for now |
| 134 | OFPC_FLOW_STATS |
| 135 | | OFPC_TABLE_STATS |
| 136 | | OFPC_PORT_STATS |
| 137 | | OFPC_GROUP_STATS |
| 138 | ) |
| 139 | ) |
| 140 | ) |
| 141 | |
| 142 | def get_ofp_port_info(self, device, port_no): |
| 143 | # Since the adapter created the device port then it has the reference of the port to |
| 144 | # return the capability. TODO: Do a lookup on the NNI port number and return the |
| 145 | # appropriate attributes |
| 146 | log.info('get_ofp_port_info', port_no=port_no, |
| 147 | info=self.ofp_port_no, device_id=device.id) |
| 148 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
| 149 | return PortCapability( |
| 150 | port=LogicalPort( |
| 151 | ofp_port=ofp_port( |
| 152 | hw_addr=mac_str_to_tuple( |
| 153 | '00:00:00:00:00:%02x' % port_no), |
| 154 | config=0, |
| 155 | state=OFPPS_LIVE, |
| 156 | curr=cap, |
| 157 | advertised=cap, |
| 158 | peer=cap, |
| 159 | curr_speed=OFPPF_1GB_FD, |
| 160 | max_speed=OFPPF_1GB_FD |
| 161 | ), |
| 162 | device_id=device.id, |
| 163 | device_port_no=port_no |
| 164 | ) |
| 165 | ) |
| 166 | |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 167 | def adapter_descriptor(self): |
| 168 | log.debug('get descriptor', interface=self.interface) |
| 169 | return self.descriptor |
| 170 | |
| 171 | def device_types(self): |
| 172 | log.debug('get device_types', interface=self.interface, |
| 173 | items=self.supported_device_types) |
| 174 | return DeviceTypes(items=self.supported_device_types) |
| 175 | |
| 176 | def health(self): |
| 177 | log.debug('get health', interface=self.interface) |
| 178 | raise NotImplementedError() |
| 179 | |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 180 | def change_master_state(self, master): |
| 181 | log.debug('change_master_state', interface=self.interface, |
| 182 | master=master) |
| 183 | raise NotImplementedError() |
| 184 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 185 | def adopt_device(self, device): |
| 186 | log.info('adopt-device', device=device) |
| 187 | |
| 188 | kwargs = { |
| 189 | 'support_classes': OpenOltDefaults['support_classes'], |
| 190 | 'adapter_proxy': self.adapter_proxy, |
| 191 | 'adapter_agent': self.adapter_agent, |
| 192 | 'device': device, |
| 193 | 'device_num': self.num_devices + 1 |
| 194 | } |
| 195 | try: |
| 196 | self.devices[device.id] = OpenoltDevice(**kwargs) |
| 197 | except Exception as e: |
| 198 | log.error('Failed to adopt OpenOLT device', error=e) |
| 199 | # TODO set status to ERROR so that is clear something went wrong |
| 200 | del self.devices[device.id] |
| 201 | raise |
| 202 | else: |
| 203 | self.num_devices += 1 |
| 204 | |
| 205 | def reconcile_device(self, device): |
| 206 | log.info('reconcile-device', device=device) |
| 207 | kwargs = { |
| 208 | 'support_classes': OpenOltDefaults['support_classes'], |
| 209 | 'adapter_agent': self.adapter_agent, |
| 210 | 'device': device, |
| 211 | 'device_num': self.num_devices + 1, |
| 212 | 'reconciliation': True |
| 213 | } |
| 214 | try: |
| 215 | reconciled_device = OpenoltDevice(**kwargs) |
| 216 | log.debug('reconciled-device-recreated', |
| 217 | device_id=reconciled_device.device_id) |
| 218 | self.devices[device.id] = reconciled_device |
| 219 | except Exception as e: |
| 220 | log.error('Failed to reconcile OpenOLT device', error=e, |
| 221 | exception_type=type(e).__name__) |
| 222 | del self.devices[device.id] |
| 223 | raise |
| 224 | else: |
| 225 | self.num_devices += 1 |
| 226 | # Invoke the children reconciliation which would setup the |
| 227 | # basic children data structures |
| 228 | self.adapter_agent.reconcile_child_devices(device.id) |
| 229 | return device |
| 230 | |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 231 | def abandon_device(self, device): |
| 232 | log.info('abandon-device', device=device) |
| 233 | raise NotImplementedError() |
| 234 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 235 | def disable_device(self, device): |
| 236 | log.info('disable-device', device=device) |
| 237 | handler = self.devices[device.id] |
| 238 | handler.disable() |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 239 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 240 | def reenable_device(self, device): |
| 241 | log.info('reenable-device', device=device) |
| 242 | handler = self.devices[device.id] |
| 243 | handler.reenable() |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 244 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 245 | def reboot_device(self, device): |
| 246 | log.info('reboot_device', device=device) |
| 247 | handler = self.devices[device.id] |
| 248 | handler.reboot() |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 249 | |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 250 | def download_image(self, device, request): |
| 251 | log.info('image_download - Not implemented yet', device=device, |
| 252 | request=request) |
| 253 | raise NotImplementedError() |
| 254 | |
| 255 | def get_image_download_status(self, device, request): |
| 256 | log.info('get_image_download - Not implemented yet', device=device, |
| 257 | request=request) |
| 258 | raise NotImplementedError() |
| 259 | |
| 260 | def cancel_image_download(self, device, request): |
| 261 | log.info('cancel_image_download - Not implemented yet', device=device) |
| 262 | raise NotImplementedError() |
| 263 | |
| 264 | def activate_image_update(self, device, request): |
| 265 | log.info('activate_image_update - Not implemented yet', |
| 266 | device=device, request=request) |
| 267 | raise NotImplementedError() |
| 268 | |
| 269 | def revert_image_update(self, device, request): |
| 270 | log.info('revert_image_update - Not implemented yet', |
| 271 | device=device, request=request) |
| 272 | raise NotImplementedError() |
| 273 | |
| 274 | def self_test_device(self, device): |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 275 | log.info('Not implemented yet') |
| 276 | raise NotImplementedError() |
| 277 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 278 | def delete_device(self, device): |
| 279 | log.info('delete-device', device=device) |
| 280 | handler = self.devices[device.id] |
| 281 | handler.delete() |
| 282 | del self.devices[device.id] |
| 283 | del self.logical_device_id_to_root_device_id[device.parent_id] |
| 284 | return device |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 285 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 286 | def get_device_details(self, device): |
| 287 | log.debug('get_device_details', device=device) |
| 288 | raise NotImplementedError() |
| 289 | |
| 290 | def update_flows_bulk(self, device, flows, groups): |
| 291 | log.info('bulk-flow-update', device_id=device.id, |
Matt Jeanneret | 9fd36df | 2019-02-14 19:14:36 -0500 | [diff] [blame] | 292 | number_of_flows=len(flows.items), |
| 293 | number_of_groups=len(groups.items)) |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 294 | log.debug('flows and grousp details', flows=flows, groups=groups) |
| 295 | assert len(groups.items) == 0, "Cannot yet deal with groups" |
| 296 | handler = self.devices[device.id] |
| 297 | return handler.update_flow_table(flows.items) |
| 298 | |
| 299 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 300 | log.debug('update_flows_incrementally', device=device, |
| 301 | flow_changes=flow_changes, group_changes=group_changes) |
| 302 | log.info('This device does not allow this, therefore it is Not ' |
| 303 | 'implemented') |
| 304 | raise NotImplementedError() |
| 305 | |
| 306 | def update_logical_flows(self, device_id, flows_to_add, flows_to_remove, |
| 307 | groups, device_rules_map): |
| 308 | |
| 309 | log.info('logical-flows-update', flows_to_add=len(flows_to_add), |
| 310 | flows_to_remove=len(flows_to_remove)) |
| 311 | log.debug('logical-flows-details', flows_to_add=flows_to_add, |
| 312 | flows_to_remove=flows_to_remove) |
| 313 | assert len(groups) == 0, "Cannot yet deal with groups" |
| 314 | handler = self.devices[device_id] |
| 315 | handler.update_logical_flows(flows_to_add, flows_to_remove, |
| 316 | device_rules_map) |
| 317 | |
| 318 | def update_pm_config(self, device, pm_configs): |
| 319 | log.info('update_pm_config - Not implemented yet', device=device, |
| 320 | pm_configs=pm_configs) |
| 321 | raise NotImplementedError() |
| 322 | |
| 323 | def send_proxied_message(self, proxy_address, msg): |
| 324 | log.debug('send-proxied-message', |
| 325 | proxy_address=proxy_address, |
| 326 | proxied_msg=msg) |
| 327 | handler = self.devices[proxy_address.device_id] |
| 328 | handler.send_proxied_message(proxy_address, msg) |
| 329 | |
| 330 | def receive_proxied_message(self, proxy_address, msg): |
| 331 | log.debug('receive_proxied_message - Not implemented', |
| 332 | proxy_address=proxy_address, |
| 333 | proxied_msg=msg) |
| 334 | raise NotImplementedError() |
| 335 | |
| 336 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 337 | log.debug('packet-out', logical_device_id=logical_device_id, |
| 338 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 339 | |
| 340 | def ldi_to_di(ldi): |
| 341 | di = self.logical_device_id_to_root_device_id.get(ldi) |
| 342 | if di is None: |
| 343 | logical_device = self.adapter_agent.get_logical_device(ldi) |
| 344 | di = logical_device.root_device_id |
| 345 | self.logical_device_id_to_root_device_id[ldi] = di |
| 346 | return di |
| 347 | |
| 348 | try: |
| 349 | device_id = ldi_to_di(logical_device_id) |
| 350 | handler = self.devices[device_id] |
| 351 | handler.packet_out(egress_port_no, msg) |
| 352 | except Exception as e: |
| 353 | log.error('packet-out:exception', e=e.message) |
| 354 | |
| 355 | def receive_inter_adapter_message(self, msg): |
| 356 | log.info('rx_inter_adapter_msg - Not implemented') |
| 357 | raise NotImplementedError() |
| 358 | |
| 359 | def suppress_alarm(self, filter): |
| 360 | log.info('suppress_alarm - Not implemented yet', filter=filter) |
| 361 | raise NotImplementedError() |
| 362 | |
| 363 | def unsuppress_alarm(self, filter): |
| 364 | log.info('unsuppress_alarm - Not implemented yet', filter=filter) |
| 365 | raise NotImplementedError() |
| 366 | |
| 367 | # PON Mgnt APIs # |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 368 | def create_interface(self, device, data): |
| 369 | log.debug('create-interface - Not implemented - We do not use this', |
| 370 | data=data) |
| 371 | raise NotImplementedError() |
| 372 | |
| 373 | def update_interface(self, device, data): |
| 374 | log.debug('update-interface - Not implemented - We do not use this', |
| 375 | data=data) |
| 376 | raise NotImplementedError() |
| 377 | |
| 378 | def remove_interface(self, device, data): |
| 379 | log.debug('remove-interface - Not implemented - We do not use this', |
| 380 | data=data) |
| 381 | raise NotImplementedError() |
| 382 | |
| 383 | def receive_onu_detect_state(self, proxy_address, state): |
| 384 | log.debug('receive-onu-detect-state - Not implemented - We do not ' |
| 385 | 'use this', proxy_address=proxy_address, |
| 386 | state=state) |
| 387 | raise NotImplementedError() |
| 388 | |
| 389 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 390 | log.info('create-tcont - Not implemented - We do not use this', |
| 391 | tcont_data=tcont_data, |
| 392 | traffic_descriptor_data=traffic_descriptor_data) |
| 393 | raise NotImplementedError() |
| 394 | |
| 395 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 396 | log.info('update-tcont - Not implemented - We do not use this', |
| 397 | tcont_data=tcont_data, |
| 398 | traffic_descriptor_data=traffic_descriptor_data) |
| 399 | raise NotImplementedError() |
| 400 | |
| 401 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 402 | log.info('remove-tcont - Not implemented - We do not use this', |
| 403 | tcont_data=tcont_data, |
| 404 | traffic_descriptor_data=traffic_descriptor_data) |
| 405 | raise NotImplementedError() |
| 406 | |
| 407 | def create_gemport(self, device, data): |
| 408 | log.info('create-gemport - Not implemented - We do not use this', |
| 409 | data=data) |
| 410 | raise NotImplementedError() |
| 411 | |
| 412 | def update_gemport(self, device, data): |
| 413 | log.info('update-gemport - Not implemented - We do not use this', |
| 414 | data=data) |
| 415 | raise NotImplementedError() |
| 416 | |
| 417 | def remove_gemport(self, device, data): |
| 418 | log.info('remove-gemport - Not implemented - We do not use this', |
| 419 | data=data) |
| 420 | raise NotImplementedError() |
| 421 | |
| 422 | def create_multicast_gemport(self, device, data): |
| 423 | log.info('create-mcast-gemport - Not implemented - We do not use ' |
| 424 | 'this', data=data) |
| 425 | raise NotImplementedError() |
| 426 | |
| 427 | def update_multicast_gemport(self, device, data): |
| 428 | log.info('update-mcast-gemport - Not implemented - We do not use ' |
| 429 | 'this', data=data) |
| 430 | raise NotImplementedError() |
| 431 | |
| 432 | def remove_multicast_gemport(self, device, data): |
| 433 | log.info('remove-mcast-gemport - Not implemented - We do not use ' |
| 434 | 'this', data=data) |
| 435 | raise NotImplementedError() |
| 436 | |
| 437 | def create_multicast_distribution_set(self, device, data): |
| 438 | log.info('create-mcast-distribution-set - Not implemented - We do ' |
| 439 | 'not use this', data=data) |
| 440 | raise NotImplementedError() |
| 441 | |
| 442 | def update_multicast_distribution_set(self, device, data): |
| 443 | log.info('update-mcast-distribution-set - Not implemented - We do ' |
| 444 | 'not use this', data=data) |
| 445 | raise NotImplementedError() |
| 446 | |
| 447 | def remove_multicast_distribution_set(self, device, data): |
| 448 | log.info('remove-mcast-distribution-set - Not implemented - We do ' |
| 449 | 'not use this', data=data) |
| 450 | raise NotImplementedError() |
| 451 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 452 | def delete_child_device(self, parent_device_id, child_device): |
| 453 | log.info('delete-child_device', parent_device_id=parent_device_id, |
| 454 | child_device=child_device) |
| 455 | handler = self.devices[parent_device_id] |
| 456 | if handler is not None: |
| 457 | handler.delete_child_device(child_device) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 458 | else: |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 459 | log.error('Could not find matching handler', |
| 460 | looking_for_device_id=parent_device_id, |
| 461 | available_handlers=self.devices.keys()) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 462 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 463 | # This is currently not part of the Iadapter interface |
| 464 | def collect_stats(self, device_id): |
| 465 | log.info('collect_stats', device_id=device_id) |
| 466 | handler = self.devices[device_id] |
| 467 | if handler is not None: |
| 468 | handler.trigger_statistics_collection() |
| 469 | else: |
| 470 | log.error('Could not find matching handler', |
| 471 | looking_for_device_id=device_id, |
| 472 | available_handlers=self.devices.keys()) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 473 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 474 | def simulate_alarm(self, device, request): |
| 475 | log.info('simulate_alarm', device=device, request=request) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 476 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 477 | if device.id not in self.devices: |
| 478 | log.error("Device does not exist", device_id=device.id) |
| 479 | return OperationResp(code=OperationResp.OPERATION_FAILURE, |
| 480 | additional_info="Device %s does not exist" |
Matt Jeanneret | 9fd36df | 2019-02-14 19:14:36 -0500 | [diff] [blame] | 481 | % device.id) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 482 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 483 | handler = self.devices[device.id] |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 484 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 485 | handler.simulate_alarm(request) |
William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 486 | |
Matt Jeanneret | 7906d23 | 2019-02-14 14:57:38 -0500 | [diff] [blame] | 487 | return OperationResp(code=OperationResp.OPERATION_SUCCESS) |