Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 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 | """ |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 18 | Broadcom OLT/ONU adapter. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 19 | """ |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 20 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 21 | from uuid import uuid4 |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 22 | import structlog |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 23 | from twisted.internet import reactor, task |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 24 | from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 25 | from zope.interface import implementer |
| 26 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 27 | from voltha.adapters.interface import IAdapterInterface |
| 28 | from voltha.core.logical_device_agent import mac_str_to_tuple |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 29 | import voltha.core.flow_decomposer as fd |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 30 | from voltha.protos import third_party |
| 31 | from voltha.protos.adapter_pb2 import Adapter |
| 32 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 33 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 34 | AdminState |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 35 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 36 | from voltha.protos.health_pb2 import HealthStatus |
| 37 | from voltha.protos.logical_device_pb2 import LogicalPort |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 38 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 39 | from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 40 | from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig, VOntaniConfig |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 41 | from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \ |
| 42 | TrafficDescriptorProfileData |
| 43 | from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData |
| 44 | from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 45 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 46 | from common.frameio.frameio import hexify |
| 47 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 48 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 49 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 50 | log = structlog.get_logger() |
| 51 | |
| 52 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 53 | BRDCM_DEFAULT_VLAN = 4091 |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 54 | ADMIN_STATE_LOCK = 1 |
| 55 | ADMIN_STATE_UNLOCK = 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 56 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 57 | @implementer(IAdapterInterface) |
| 58 | class BroadcomOnuAdapter(object): |
| 59 | |
| 60 | name = 'broadcom_onu' |
| 61 | |
| 62 | supported_device_types = [ |
| 63 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 64 | id=name, |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 65 | vendor_id='BRCM', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 66 | adapter=name, |
| 67 | accepts_bulk_flow_update=True |
| 68 | ) |
| 69 | ] |
| 70 | |
| 71 | def __init__(self, adapter_agent, config): |
| 72 | self.adapter_agent = adapter_agent |
| 73 | self.config = config |
| 74 | self.descriptor = Adapter( |
| 75 | id=self.name, |
| 76 | vendor='Voltha project', |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 77 | version='0.44', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 78 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 79 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 80 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 81 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 82 | # register for adapter messages |
| 83 | self.adapter_agent.register_for_inter_adapter_messages() |
| 84 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 85 | def start(self): |
| 86 | log.debug('starting') |
| 87 | log.info('started') |
| 88 | |
| 89 | def stop(self): |
| 90 | log.debug('stopping') |
| 91 | log.info('stopped') |
| 92 | |
| 93 | def adapter_descriptor(self): |
| 94 | return self.descriptor |
| 95 | |
| 96 | def device_types(self): |
| 97 | return DeviceTypes(items=self.supported_device_types) |
| 98 | |
| 99 | def health(self): |
| 100 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 101 | |
| 102 | def change_master_state(self, master): |
| 103 | raise NotImplementedError() |
| 104 | |
| 105 | def adopt_device(self, device): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 106 | log.info('adopt_device', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 107 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 108 | reactor.callLater(0, self.devices_handlers[device.id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 109 | return device |
| 110 | |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 111 | def reconcile_device(self, device): |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 112 | log.info('reconcile-device', device_id=device.id) |
| 113 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 114 | reactor.callLater(0, self.devices_handlers[device.id].reconcile, device) |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 115 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 116 | def abandon_device(self, device): |
| 117 | raise NotImplementedError() |
| 118 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 119 | def disable_device(self, device): |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 120 | log.info('disable-onu-device', device_id=device.id) |
| 121 | if device.id in self.devices_handlers: |
| 122 | handler = self.devices_handlers[device.id] |
| 123 | if handler is not None: |
| 124 | handler.disable(device) |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 125 | |
| 126 | def reenable_device(self, device): |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 127 | log.info('reenable-onu-device', device_id=device.id) |
| 128 | if device.id in self.devices_handlers: |
| 129 | handler = self.devices_handlers[device.id] |
| 130 | if handler is not None: |
| 131 | handler.reenable(device) |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 132 | |
| 133 | def reboot_device(self, device): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 134 | log.info('reboot-device', device_id=device.id) |
| 135 | if device.id in self.devices_handlers: |
| 136 | handler = self.devices_handlers[device.id] |
| 137 | if handler is not None: |
| 138 | handler.reboot() |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 139 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 140 | def download_image(self, device, request): |
| 141 | raise NotImplementedError() |
| 142 | |
| 143 | def get_image_download_status(self, device, request): |
| 144 | raise NotImplementedError() |
| 145 | |
| 146 | def cancel_image_download(self, device, request): |
| 147 | raise NotImplementedError() |
| 148 | |
| 149 | def activate_image_update(self, device, request): |
| 150 | raise NotImplementedError() |
| 151 | |
| 152 | def revert_image_update(self, device, request): |
| 153 | raise NotImplementedError() |
| 154 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 155 | def self_test_device(self, device): |
| 156 | """ |
| 157 | This is called to Self a device based on a NBI call. |
| 158 | :param device: A Voltha.Device object. |
| 159 | :return: Will return result of self test |
| 160 | """ |
| 161 | log.info('self-test-device', device=device.id) |
| 162 | raise NotImplementedError() |
| 163 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 164 | def delete_device(self, device): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 165 | log.info('delete-device', device_id=device.id) |
| 166 | if device.id in self.devices_handlers: |
| 167 | handler = self.devices_handlers[device.id] |
| 168 | if handler is not None: |
| 169 | handler.delete(device) |
| 170 | del self.devices_handlers[device.id] |
| 171 | return |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 172 | |
| 173 | def get_device_details(self, device): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 174 | raise NotImplementedError() |
| 175 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 176 | def update_pm_config(self, device, pm_configs): |
| 177 | raise NotImplementedError() |
| 178 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 179 | def update_flows_bulk(self, device, flows, groups): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 180 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 181 | log.info('bulk-flow-update', device_id=device.id, |
| 182 | flows=flows, groups=groups) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 183 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 184 | assert len(groups.items) == 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 185 | handler = self.devices_handlers[device.id] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 186 | return handler.update_flow_table(device, flows.items) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 187 | |
| 188 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 189 | raise NotImplementedError() |
| 190 | |
| 191 | def send_proxied_message(self, proxy_address, msg): |
| 192 | log.info('send-proxied-message', proxy_address=proxy_address, msg=msg) |
| 193 | |
| 194 | def receive_proxied_message(self, proxy_address, msg): |
| 195 | log.info('receive-proxied-message', proxy_address=proxy_address, |
| 196 | device_id=proxy_address.device_id, msg=hexify(msg)) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 197 | # Device_id from the proxy_address is the olt device id. We need to |
| 198 | # get the onu device id using the port number in the proxy_address |
| 199 | device = self.adapter_agent. \ |
| 200 | get_child_device_with_proxy_address(proxy_address) |
| 201 | if device: |
| 202 | handler = self.devices_handlers[device.id] |
| 203 | handler.receive_message(msg) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 204 | |
| 205 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 206 | log.info('packet-out', logical_device_id=logical_device_id, |
| 207 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 208 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 209 | def receive_inter_adapter_message(self, msg): |
| 210 | log.info('receive_inter_adapter_message', msg=msg) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 211 | proxy_address = msg['proxy_address'] |
| 212 | assert proxy_address is not None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 213 | # Device_id from the proxy_address is the olt device id. We need to |
| 214 | # get the onu device id using the port number in the proxy_address |
| 215 | device = self.adapter_agent. \ |
| 216 | get_child_device_with_proxy_address(proxy_address) |
| 217 | if device: |
| 218 | handler = self.devices_handlers[device.id] |
| 219 | handler.event_messages.put(msg) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 220 | else: |
| 221 | log.error("device-not-found") |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 222 | |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 223 | def create_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 224 | log.info('create-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 225 | if device.id in self.devices_handlers: |
| 226 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 227 | if handler is not None: |
| 228 | handler.create_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 229 | |
| 230 | def update_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 231 | log.info('update-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 232 | if device.id in self.devices_handlers: |
| 233 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 234 | if handler is not None: |
| 235 | handler.update_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 236 | |
| 237 | def remove_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 238 | log.info('remove-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 239 | if device.id in self.devices_handlers: |
| 240 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 241 | if handler is not None: |
| 242 | handler.remove_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 243 | |
| 244 | def receive_onu_detect_state(self, device_id, state): |
| 245 | raise NotImplementedError() |
| 246 | |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 247 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 248 | log.info('create-tcont', device_id=device.id) |
| 249 | if device.id in self.devices_handlers: |
| 250 | handler = self.devices_handlers[device.id] |
| 251 | if handler is not None: |
| 252 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 253 | |
| 254 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 255 | raise NotImplementedError() |
| 256 | |
| 257 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 258 | log.info('remove-tcont', device_id=device.id) |
| 259 | if device.id in self.devices_handlers: |
| 260 | handler = self.devices_handlers[device.id] |
| 261 | if handler is not None: |
| 262 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 263 | |
| 264 | def create_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 265 | log.info('create-gemport', device_id=device.id) |
| 266 | if device.id in self.devices_handlers: |
| 267 | handler = self.devices_handlers[device.id] |
| 268 | if handler is not None: |
| 269 | handler.create_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 270 | |
| 271 | def update_gemport(self, device, data): |
| 272 | raise NotImplementedError() |
| 273 | |
| 274 | def remove_gemport(self, device, data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 275 | log.info('remove-gemport', device_id=device.id) |
| 276 | if device.id in self.devices_handlers: |
| 277 | handler = self.devices_handlers[device.id] |
| 278 | if handler is not None: |
| 279 | handler.remove_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 280 | |
| 281 | def create_multicast_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 282 | log.info('create-multicast-gemport', device_id=device.id) |
| 283 | if device.id in self.devices_handlers: |
| 284 | handler = self.devices_handlers[device.id] |
| 285 | if handler is not None: |
| 286 | handler.create_multicast_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 287 | |
| 288 | def update_multicast_gemport(self, device, data): |
| 289 | raise NotImplementedError() |
| 290 | |
| 291 | def remove_multicast_gemport(self, device, data): |
| 292 | raise NotImplementedError() |
| 293 | |
| 294 | def create_multicast_distribution_set(self, device, data): |
| 295 | raise NotImplementedError() |
| 296 | |
| 297 | def update_multicast_distribution_set(self, device, data): |
| 298 | raise NotImplementedError() |
| 299 | |
| 300 | def remove_multicast_distribution_set(self, device, data): |
| 301 | raise NotImplementedError() |
| 302 | |
| 303 | def suppress_alarm(self, filter): |
| 304 | raise NotImplementedError() |
| 305 | |
Stephane Barbarie | 980a091 | 2017-05-11 11:27:06 -0400 | [diff] [blame] | 306 | def unsuppress_alarm(self, filter): |
| 307 | raise NotImplementedError() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 308 | |
| 309 | class BroadcomOnuHandler(object): |
| 310 | |
| 311 | def __init__(self, adapter, device_id): |
| 312 | self.adapter = adapter |
| 313 | self.adapter_agent = adapter.adapter_agent |
| 314 | self.device_id = device_id |
| 315 | self.log = structlog.get_logger(device_id=device_id) |
| 316 | self.incoming_messages = DeferredQueue() |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 317 | self.event_messages = DeferredQueue() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 318 | self.proxy_address = None |
| 319 | self.tx_id = 0 |
| 320 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 321 | # Need to query ONU for number of supported uni ports |
| 322 | # For now, temporarily set number of ports to 1 - port #2 |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 323 | self.uni_ports = (1, 2, 3, 4, 5) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 324 | |
| 325 | # Handle received ONU event messages |
| 326 | reactor.callLater(0, self.handle_onu_events) |
| 327 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 328 | def receive_message(self, msg): |
| 329 | self.incoming_messages.put(msg) |
| 330 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 331 | @inlineCallbacks |
| 332 | def handle_onu_events(self): |
| 333 | event_msg = yield self.event_messages.get() |
| 334 | |
| 335 | if event_msg['event'] == 'activation-completed': |
| 336 | |
| 337 | if event_msg['event_data']['activation_successful'] == True: |
| 338 | for uni in self.uni_ports: |
| 339 | port_no = self.proxy_address.channel_id + uni |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 340 | yield self.message_exchange( |
| 341 | self.proxy_address.onu_id, |
| 342 | self.proxy_address.onu_session_id, |
| 343 | port_no) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 344 | |
| 345 | device = self.adapter_agent.get_device(self.device_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 346 | device.connect_status = ConnectStatus.REACHABLE |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 347 | device.oper_status = OperStatus.ACTIVE |
| 348 | self.adapter_agent.update_device(device) |
| 349 | |
| 350 | else: |
| 351 | device = self.adapter_agent.get_device(self.device_id) |
| 352 | device.oper_status = OperStatus.FAILED |
| 353 | self.adapter_agent.update_device(device) |
| 354 | |
| 355 | elif event_msg['event'] == 'deactivation-completed': |
| 356 | device = self.adapter_agent.get_device(self.device_id) |
| 357 | device.oper_status = OperStatus.DISCOVERED |
| 358 | self.adapter_agent.update_device(device) |
| 359 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 360 | elif event_msg['event'] == 'deactivate-onu': |
Girish | a9eb021 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 361 | device = self.adapter_agent.get_device(self.device_id) |
| 362 | device.connect_status = ConnectStatus.UNREACHABLE |
| 363 | device.oper_status = OperStatus.DISCOVERED |
| 364 | self.adapter_agent.update_device(device) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 365 | self.disable_ports(device) |
Girish | a9eb021 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 366 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 367 | elif event_msg['event'] == 'ranging-completed': |
| 368 | |
| 369 | if event_msg['event_data']['ranging_successful'] == True: |
| 370 | device = self.adapter_agent.get_device(self.device_id) |
| 371 | device.oper_status = OperStatus.ACTIVATING |
| 372 | self.adapter_agent.update_device(device) |
| 373 | |
| 374 | else: |
| 375 | device = self.adapter_agent.get_device(self.device_id) |
| 376 | device.oper_status = OperStatus.FAILED |
| 377 | self.adapter_agent.update_device(device) |
| 378 | |
Shad Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame^] | 379 | elif event_msg['event'] == 'create-tcont': |
| 380 | tcont = TcontsConfigData() |
| 381 | tcont.alloc_id = event_msg['event_data']['alloc_id'] |
| 382 | self.create_tcont(tcont, traffic_descriptor_data=None) |
| 383 | |
| 384 | elif event_msg['event'] == 'create-venet': |
| 385 | venet = VEnetConfig(name=event_msg['event_data']['uni_name']) |
| 386 | venet.interface.name = event_msg['event_data']['interface_name'] |
| 387 | self.create_interface(venet) |
| 388 | |
| 389 | elif event_msg['event'] == 'create-gemport': |
| 390 | gem_port = GemportsConfigData() |
| 391 | gem_port.gemport_id = event_msg['event_data']['gemport_id'] |
| 392 | self.create_gemport(gem_port) |
| 393 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 394 | # Handle next event |
| 395 | reactor.callLater(0, self.handle_onu_events) |
| 396 | |
| 397 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 398 | def activate(self, device): |
| 399 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 400 | |
| 401 | # first we verify that we got parent reference and proxy info |
| 402 | assert device.parent_id |
| 403 | assert device.proxy_address.device_id |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 404 | #assert device.proxy_address.channel_id # c-vid |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 405 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 406 | # register for proxied messages right away |
| 407 | self.proxy_address = device.proxy_address |
| 408 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 409 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 410 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 411 | # populate device info |
| 412 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 413 | device.vendor = 'Broadcom' |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 414 | device.model = 'n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 415 | device.hardware_version = 'to be filled' |
| 416 | device.firmware_version = 'to be filled' |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 417 | device.images.image.extend([ |
| 418 | Image(version="to be filled") |
| 419 | ]) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 420 | device.connect_status = ConnectStatus.REACHABLE |
| 421 | self.adapter_agent.update_device(device) |
| 422 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 423 | self.adapter_agent.add_port(device.id, Port( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 424 | port_no=100, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 425 | label='PON port', |
| 426 | type=Port.PON_ONU, |
| 427 | admin_state=AdminState.ENABLED, |
| 428 | oper_status=OperStatus.ACTIVE, |
| 429 | peers=[ |
| 430 | Port.PeerPort( |
| 431 | device_id=device.parent_id, |
| 432 | port_no=device.parent_port_no |
| 433 | ) |
| 434 | ] |
| 435 | )) |
| 436 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 437 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 438 | logical_device_id = parent_device.parent_id |
| 439 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 440 | device = self.adapter_agent.get_device(device.id) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 441 | device.oper_status = OperStatus.DISCOVERED |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 442 | self.adapter_agent.update_device(device) |
| 443 | |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 444 | def reconcile(self, device): |
| 445 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 446 | self.log.info('reconciling-broadcom-onu-device-starts') |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 447 | |
| 448 | # first we verify that we got parent reference and proxy info |
| 449 | assert device.parent_id |
| 450 | assert device.proxy_address.device_id |
| 451 | |
| 452 | # register for proxied messages right away |
| 453 | self.proxy_address = device.proxy_address |
| 454 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 455 | |
| 456 | # TODO: Query ONU current status after reconcile and update. |
| 457 | # To be addressed in future commits. |
| 458 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 459 | self.log.info('reconciling-broadcom-onu-device-ends') |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 460 | |
sathishg | 24dad1e | 2018-01-10 10:48:45 +0530 | [diff] [blame] | 461 | def update_logical_port(self, logical_device_id, port_id, state): |
| 462 | self.log.info('updating-logical-port', logical_port_id=port_id, |
| 463 | logical_device_id=logical_device_id, state=state) |
| 464 | logical_port = self.adapter_agent.get_logical_port(logical_device_id, |
| 465 | port_id) |
| 466 | logical_port.ofp_port.state = state |
| 467 | self.adapter_agent.update_logical_port(logical_device_id, |
| 468 | logical_port) |
| 469 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 470 | def delete(self, device): |
| 471 | self.log.info('delete-onu') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 472 | # The device is already deleted in delete_v_ont_ani(). No more |
| 473 | # handling needed here |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 474 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 475 | @inlineCallbacks |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 476 | def update_flow_table(self, device, flows): |
| 477 | # |
| 478 | # We need to proxy through the OLT to get to the ONU |
| 479 | # Configuration from here should be using OMCI |
| 480 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 481 | #self.log.info('bulk-flow-update', device_id=device.id, flows=flows) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 482 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 483 | def is_downstream(port): |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 484 | return port == 100 # Need a better way |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 485 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 486 | def is_upstream(port): |
| 487 | return not is_downstream(port) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 488 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 489 | for flow in flows: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 490 | _type = None |
| 491 | _port = None |
| 492 | _vlan_vid = None |
| 493 | _udp_dst = None |
| 494 | _udp_src = None |
| 495 | _ipv4_dst = None |
| 496 | _ipv4_src = None |
| 497 | _metadata = None |
| 498 | _output = None |
| 499 | _push_tpid = None |
| 500 | _field = None |
| 501 | _set_vlan_vid = None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 502 | self.log.info('bulk-flow-update', device_id=device.id, flow=flow) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 503 | try: |
| 504 | _in_port = fd.get_in_port(flow) |
| 505 | assert _in_port is not None |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 506 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 507 | if is_downstream(_in_port): |
| 508 | self.log.info('downstream-flow') |
| 509 | elif is_upstream(_in_port): |
| 510 | self.log.info('upstream-flow') |
| 511 | else: |
| 512 | raise Exception('port should be 1 or 2 by our convention') |
| 513 | |
| 514 | _out_port = fd.get_out_port(flow) # may be None |
| 515 | self.log.info('out-port', out_port=_out_port) |
| 516 | |
| 517 | for field in fd.get_ofb_fields(flow): |
| 518 | if field.type == fd.ETH_TYPE: |
| 519 | _type = field.eth_type |
| 520 | self.log.info('field-type-eth-type', |
| 521 | eth_type=_type) |
| 522 | |
| 523 | elif field.type == fd.IP_PROTO: |
| 524 | _proto = field.ip_proto |
| 525 | self.log.info('field-type-ip-proto', |
| 526 | ip_proto=_proto) |
| 527 | |
| 528 | elif field.type == fd.IN_PORT: |
| 529 | _port = field.port |
| 530 | self.log.info('field-type-in-port', |
| 531 | in_port=_port) |
| 532 | |
| 533 | elif field.type == fd.VLAN_VID: |
| 534 | _vlan_vid = field.vlan_vid & 0xfff |
| 535 | self.log.info('field-type-vlan-vid', |
| 536 | vlan=_vlan_vid) |
| 537 | |
| 538 | elif field.type == fd.VLAN_PCP: |
| 539 | _vlan_pcp = field.vlan_pcp |
| 540 | self.log.info('field-type-vlan-pcp', |
| 541 | pcp=_vlan_pcp) |
| 542 | |
| 543 | elif field.type == fd.UDP_DST: |
| 544 | _udp_dst = field.udp_dst |
| 545 | self.log.info('field-type-udp-dst', |
| 546 | udp_dst=_udp_dst) |
| 547 | |
| 548 | elif field.type == fd.UDP_SRC: |
| 549 | _udp_src = field.udp_src |
| 550 | self.log.info('field-type-udp-src', |
| 551 | udp_src=_udp_src) |
| 552 | |
| 553 | elif field.type == fd.IPV4_DST: |
| 554 | _ipv4_dst = field.ipv4_dst |
| 555 | self.log.info('field-type-ipv4-dst', |
| 556 | ipv4_dst=_ipv4_dst) |
| 557 | |
| 558 | elif field.type == fd.IPV4_SRC: |
| 559 | _ipv4_src = field.ipv4_src |
| 560 | self.log.info('field-type-ipv4-src', |
| 561 | ipv4_dst=_ipv4_src) |
| 562 | |
| 563 | elif field.type == fd.METADATA: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 564 | _metadata = field.table_metadata |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 565 | self.log.info('field-type-metadata', |
| 566 | metadata=_metadata) |
| 567 | |
| 568 | else: |
| 569 | raise NotImplementedError('field.type={}'.format( |
| 570 | field.type)) |
| 571 | |
| 572 | for action in fd.get_actions(flow): |
| 573 | |
| 574 | if action.type == fd.OUTPUT: |
| 575 | _output = action.output.port |
| 576 | self.log.info('action-type-output', |
| 577 | output=_output, in_port=_in_port) |
| 578 | |
| 579 | elif action.type == fd.POP_VLAN: |
| 580 | self.log.info('action-type-pop-vlan', |
| 581 | in_port=_in_port) |
| 582 | |
| 583 | elif action.type == fd.PUSH_VLAN: |
| 584 | _push_tpid = action.push.ethertype |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 585 | self.log.info('action-type-push-vlan', |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 586 | push_tpid=_push_tpid, in_port=_in_port) |
| 587 | if action.push.ethertype != 0x8100: |
| 588 | self.log.error('unhandled-tpid', |
| 589 | ethertype=action.push.ethertype) |
| 590 | |
| 591 | elif action.type == fd.SET_FIELD: |
| 592 | _field = action.set_field.field.ofb_field |
| 593 | assert (action.set_field.field.oxm_class == |
| 594 | OFPXMC_OPENFLOW_BASIC) |
| 595 | self.log.info('action-type-set-field', |
| 596 | field=_field, in_port=_in_port) |
| 597 | if _field.type == fd.VLAN_VID: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 598 | _set_vlan_vid = _field.vlan_vid & 0xfff |
| 599 | self.log.info('set-field-type-valn-vid', _set_vlan_vid) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 600 | else: |
| 601 | self.log.error('unsupported-action-set-field-type', |
| 602 | field_type=_field.type) |
| 603 | else: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 604 | self.log.error('unsupported-action-type', |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 605 | action_type=action.type, in_port=_in_port) |
| 606 | |
| 607 | # |
| 608 | # All flows created from ONU adapter should be OMCI based |
| 609 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 610 | if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 611 | # allow priority tagged packets |
| 612 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 613 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 614 | |
| 615 | self.send_delete_vlan_tagging_filter_data(0x2102) |
| 616 | yield self.wait_for_response() |
| 617 | |
| 618 | #self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid) |
| 619 | self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid) |
| 620 | yield self.wait_for_response() |
| 621 | |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 622 | for port_id in self.uni_ports: |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 623 | |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 624 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, _set_vlan_vid) |
| 625 | yield self.wait_for_response() |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 626 | |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 627 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 8, 0, 0, |
| 628 | 1, 8, _set_vlan_vid) |
| 629 | yield self.wait_for_response() |
| 630 | |
| 631 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 632 | |
| 633 | except Exception as e: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 634 | self.log.exception('failed-to-install-flow', e=e, flow=flow) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 635 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 636 | def get_tx_id(self): |
| 637 | self.tx_id += 1 |
| 638 | return self.tx_id |
| 639 | |
| 640 | def send_omci_message(self, frame): |
| 641 | _frame = hexify(str(frame)) |
| 642 | self.log.info('send-omci-message-%s' % _frame) |
| 643 | device = self.adapter_agent.get_device(self.device_id) |
| 644 | try: |
| 645 | self.adapter_agent.send_proxied_message(device.proxy_address, _frame) |
| 646 | except Exception as e: |
| 647 | self.log.info('send-omci-message-exception', exc=str(e)) |
| 648 | |
| 649 | def send_get_circuit_pack(self, entity_id=0): |
| 650 | frame = OmciFrame( |
| 651 | transaction_id=self.get_tx_id(), |
| 652 | message_type=OmciGet.message_id, |
| 653 | omci_message=OmciGet( |
| 654 | entity_class=CircuitPack.class_id, |
| 655 | entity_id=entity_id, |
| 656 | attributes_mask=CircuitPack.mask_for('vendor_id') |
| 657 | ) |
| 658 | ) |
| 659 | self.send_omci_message(frame) |
| 660 | |
| 661 | def send_mib_reset(self, entity_id=0): |
| 662 | frame = OmciFrame( |
| 663 | transaction_id=self.get_tx_id(), |
| 664 | message_type=OmciMibReset.message_id, |
| 665 | omci_message=OmciMibReset( |
| 666 | entity_class=OntData.class_id, |
| 667 | entity_id=entity_id |
| 668 | ) |
| 669 | ) |
| 670 | self.send_omci_message(frame) |
| 671 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 672 | def send_create_gal_ethernet_profile(self, |
| 673 | entity_id, |
| 674 | max_gem_payload_size): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 675 | frame = OmciFrame( |
| 676 | transaction_id=self.get_tx_id(), |
| 677 | message_type=OmciCreate.message_id, |
| 678 | omci_message=OmciCreate( |
| 679 | entity_class=GalEthernetProfile.class_id, |
| 680 | entity_id=entity_id, |
| 681 | data=dict( |
| 682 | max_gem_payload_size=max_gem_payload_size |
| 683 | ) |
| 684 | ) |
| 685 | ) |
| 686 | self.send_omci_message(frame) |
| 687 | |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 688 | def send_set_admin_state(self, |
| 689 | entity_id, |
| 690 | admin_state): |
| 691 | data = dict( |
| 692 | administrative_state=admin_state |
| 693 | ) |
| 694 | frame = OmciFrame( |
| 695 | transaction_id=self.get_tx_id(), |
| 696 | message_type=OmciSet.message_id, |
| 697 | omci_message=OmciSet( |
| 698 | entity_class=OntG.class_id, |
| 699 | entity_id=entity_id, |
| 700 | attributes_mask=OntG.mask_for(*data.keys()), |
| 701 | data=data |
| 702 | ) |
| 703 | ) |
| 704 | self.send_omci_message(frame) |
| 705 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 706 | def send_set_tcont(self, |
| 707 | entity_id, |
| 708 | alloc_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 709 | data = dict( |
| 710 | alloc_id=alloc_id |
| 711 | ) |
| 712 | frame = OmciFrame( |
| 713 | transaction_id=self.get_tx_id(), |
| 714 | message_type=OmciSet.message_id, |
| 715 | omci_message=OmciSet( |
| 716 | entity_class=Tcont.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 717 | entity_id=entity_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 718 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 719 | data=data |
| 720 | ) |
| 721 | ) |
| 722 | self.send_omci_message(frame) |
| 723 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 724 | def send_create_8021p_mapper_service_profile(self, |
| 725 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 726 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 727 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 728 | message_type=OmciCreate.message_id, |
| 729 | omci_message=OmciCreate( |
| 730 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 731 | entity_id=entity_id, |
| 732 | data=dict( |
| 733 | tp_pointer=OmciNullPointer, |
| 734 | interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer, |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 735 | interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer, |
| 736 | interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer, |
| 737 | interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer, |
| 738 | interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer, |
| 739 | interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer, |
| 740 | interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer, |
| 741 | interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 742 | ) |
| 743 | ) |
| 744 | ) |
| 745 | self.send_omci_message(frame) |
| 746 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 747 | def send_create_mac_bridge_service_profile(self, |
| 748 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 749 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 750 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 751 | message_type=OmciCreate.message_id, |
| 752 | omci_message=OmciCreate( |
| 753 | entity_class=MacBridgeServiceProfile.class_id, |
| 754 | entity_id=entity_id, |
| 755 | data=dict( |
| 756 | spanning_tree_ind=False, |
| 757 | learning_ind=True, |
| 758 | priority=0x8000, |
| 759 | max_age=20 * 256, |
| 760 | hello_time=2 * 256, |
| 761 | forward_delay=15 * 256, |
| 762 | unknown_mac_address_discard=True |
| 763 | ) |
| 764 | ) |
| 765 | ) |
| 766 | self.send_omci_message(frame) |
| 767 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 768 | def send_create_gem_port_network_ctp(self, |
| 769 | entity_id, |
| 770 | port_id, |
| 771 | tcont_id, |
| 772 | direction, |
| 773 | tm): |
| 774 | _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3} |
| 775 | if _directions.has_key(direction): |
| 776 | _direction = _directions[direction] |
| 777 | else: |
| 778 | self.log.error('invalid-gem-port-direction', direction=direction) |
| 779 | raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction)) |
| 780 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 781 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 782 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 783 | message_type=OmciCreate.message_id, |
| 784 | omci_message=OmciCreate( |
| 785 | entity_class=GemPortNetworkCtp.class_id, |
| 786 | entity_id=entity_id, |
| 787 | data=dict( |
| 788 | port_id=port_id, |
| 789 | tcont_pointer=tcont_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 790 | direction=_direction, |
| 791 | traffic_management_pointer_upstream=tm |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 792 | ) |
| 793 | ) |
| 794 | ) |
| 795 | self.send_omci_message(frame) |
| 796 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 797 | def send_create_multicast_gem_interworking_tp(self, |
| 798 | entity_id, |
| 799 | gem_port_net_ctp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 800 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 801 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 802 | message_type=OmciCreate.message_id, |
| 803 | omci_message=OmciCreate( |
| 804 | entity_class=MulticastGemInterworkingTp.class_id, |
| 805 | entity_id=entity_id, |
| 806 | data=dict( |
| 807 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 808 | interworking_option=0, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 809 | service_profile_pointer=0x1 |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 810 | ) |
| 811 | ) |
| 812 | ) |
| 813 | self.send_omci_message(frame) |
| 814 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 815 | def send_create_gem_inteworking_tp(self, |
| 816 | entity_id, |
| 817 | gem_port_net_ctp_id, |
| 818 | service_profile_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 819 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 820 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 821 | message_type=OmciCreate.message_id, |
| 822 | omci_message=OmciCreate( |
| 823 | entity_class=GemInterworkingTp.class_id, |
| 824 | entity_id=entity_id, |
| 825 | data=dict( |
| 826 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 827 | interworking_option=5, |
| 828 | service_profile_pointer=service_profile_id, |
| 829 | interworking_tp_pointer=0x0, |
| 830 | gal_profile_pointer=0x1 |
| 831 | ) |
| 832 | ) |
| 833 | ) |
| 834 | self.send_omci_message(frame) |
| 835 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 836 | def send_delete_omci_mesage(self, |
| 837 | class_id, |
| 838 | entity_id): |
| 839 | frame = OmciFrame( |
| 840 | transaction_id=self.get_tx_id(), |
| 841 | message_type=OmciDelete.message_id, |
| 842 | omci_message=OmciDelete( |
| 843 | entity_class=class_id, |
| 844 | entity_id=entity_id |
| 845 | ) |
| 846 | ) |
| 847 | self.send_omci_message(frame) |
| 848 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 849 | def send_set_8021p_mapper_service_profile(self, |
| 850 | entity_id, |
| 851 | interwork_tp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 852 | data = dict( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 853 | interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id, |
| 854 | interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id, |
| 855 | interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id, |
| 856 | interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id, |
| 857 | interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id, |
| 858 | interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id, |
| 859 | interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id, |
| 860 | interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 861 | ) |
| 862 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 863 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 864 | message_type=OmciSet.message_id, |
| 865 | omci_message=OmciSet( |
| 866 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 867 | entity_id=entity_id, |
| 868 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for( |
| 869 | *data.keys()), |
| 870 | data=data |
| 871 | ) |
| 872 | ) |
| 873 | self.send_omci_message(frame) |
| 874 | |
| 875 | def send_create_mac_bridge_port_configuration_data(self, |
| 876 | entity_id, |
| 877 | bridge_id, |
| 878 | port_id, |
| 879 | tp_type, |
| 880 | tp_id): |
| 881 | frame = OmciFrame( |
| 882 | transaction_id=self.get_tx_id(), |
| 883 | message_type=OmciCreate.message_id, |
| 884 | omci_message=OmciCreate( |
| 885 | entity_class=MacBridgePortConfigurationData.class_id, |
| 886 | entity_id=entity_id, |
| 887 | data=dict( |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 888 | bridge_id_pointer=bridge_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 889 | port_num=port_id, |
| 890 | tp_type=tp_type, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 891 | tp_pointer=tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 892 | ) |
| 893 | ) |
| 894 | ) |
| 895 | self.send_omci_message(frame) |
| 896 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 897 | def send_create_vlan_tagging_filter_data(self, |
| 898 | entity_id, |
| 899 | vlan_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 900 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 901 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 902 | message_type=OmciCreate.message_id, |
| 903 | omci_message=OmciCreate( |
| 904 | entity_class=VlanTaggingFilterData.class_id, |
| 905 | entity_id=entity_id, |
| 906 | data=dict( |
| 907 | vlan_filter_0=vlan_id, |
| 908 | forward_operation=0x10, |
| 909 | number_of_entries=1 |
| 910 | ) |
| 911 | ) |
| 912 | ) |
| 913 | self.send_omci_message(frame) |
| 914 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 915 | def send_set_vlan_tagging_filter_data(self, |
| 916 | entity_id, |
| 917 | vlan_id): |
| 918 | data = dict( |
| 919 | vlan_filter_0=vlan_id, |
| 920 | forward_operation=0x10, |
| 921 | number_of_entries=1 |
| 922 | ) |
| 923 | |
| 924 | frame = OmciFrame( |
| 925 | transaction_id=self.get_tx_id(), |
| 926 | message_type=OmciSet.message_id, |
| 927 | omci_message=OmciSet( |
| 928 | entity_class=VlanTaggingFilterData.class_id, |
| 929 | entity_id=entity_id, |
| 930 | attributes_mask=VlanTaggingFilterData.mask_for( |
| 931 | *data.keys()), |
| 932 | data=data |
| 933 | ) |
| 934 | ) |
| 935 | self.send_omci_message(frame) |
| 936 | |
| 937 | def send_delete_vlan_tagging_filter_data(self, |
| 938 | entity_id): |
| 939 | frame = OmciFrame( |
| 940 | transaction_id=self.get_tx_id(), |
| 941 | message_type=OmciDelete.message_id, |
| 942 | omci_message=OmciDelete( |
| 943 | entity_class=VlanTaggingFilterData.class_id, |
| 944 | entity_id=entity_id |
| 945 | ) |
| 946 | ) |
| 947 | self.send_omci_message(frame) |
| 948 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 949 | def send_create_extended_vlan_tagging_operation_configuration_data(self, |
| 950 | entity_id, |
| 951 | assoc_type, |
| 952 | assoc_me): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 953 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 954 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 955 | message_type=OmciCreate.message_id, |
| 956 | omci_message=OmciCreate( |
| 957 | entity_class= |
| 958 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 959 | entity_id=entity_id, |
| 960 | data=dict( |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 961 | association_type=assoc_type, |
| 962 | associated_me_pointer=assoc_me |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 963 | ) |
| 964 | ) |
| 965 | ) |
| 966 | self.send_omci_message(frame) |
| 967 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 968 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, |
| 969 | entity_id, |
| 970 | input_tpid, |
| 971 | output_tpid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 972 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 973 | input_tpid=input_tpid, |
| 974 | output_tpid=output_tpid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 975 | downstream_mode=0, # inverse of upstream |
| 976 | ) |
| 977 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 978 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 979 | message_type=OmciSet.message_id, |
| 980 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 981 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 982 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 983 | entity_id=entity_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 984 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 985 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 986 | *data.keys()), |
| 987 | data=data |
| 988 | ) |
| 989 | ) |
| 990 | self.send_omci_message(frame) |
| 991 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 992 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self, |
| 993 | entity_id, |
| 994 | filter_inner_vid, |
| 995 | treatment_inner_vid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 996 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 997 | received_frame_vlan_tagging_operation_table= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 998 | VlanTaggingOperation( |
| 999 | filter_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1000 | filter_outer_vid=4096, |
| 1001 | filter_outer_tpid_de=0, |
| 1002 | |
| 1003 | filter_inner_priority=15, |
| 1004 | filter_inner_vid=filter_inner_vid, |
| 1005 | filter_inner_tpid_de=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1006 | filter_ether_type=0, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1007 | |
| 1008 | treatment_tags_to_remove=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1009 | treatment_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1010 | treatment_outer_vid=0, |
| 1011 | treatment_outer_tpid_de=0, |
| 1012 | |
| 1013 | treatment_inner_priority=0, |
| 1014 | treatment_inner_vid=treatment_inner_vid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1015 | treatment_inner_tpid_de=4 |
| 1016 | ) |
| 1017 | ) |
| 1018 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1019 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1020 | message_type=OmciSet.message_id, |
| 1021 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1022 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1023 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1024 | entity_id=entity_id, |
| 1025 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1026 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 1027 | *data.keys()), |
| 1028 | data=data |
| 1029 | ) |
| 1030 | ) |
| 1031 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1032 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 1033 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self, |
| 1034 | entity_id, |
| 1035 | filter_inner_priority, |
| 1036 | filter_inner_vid, |
| 1037 | filter_inner_tpid_de, |
| 1038 | treatment_tags_to_remove, |
| 1039 | treatment_inner_priority, |
| 1040 | treatment_inner_vid): |
| 1041 | data = dict( |
| 1042 | received_frame_vlan_tagging_operation_table= |
| 1043 | VlanTaggingOperation( |
| 1044 | filter_outer_priority=15, |
| 1045 | filter_outer_vid=4096, |
| 1046 | filter_outer_tpid_de=0, |
| 1047 | |
| 1048 | filter_inner_priority=filter_inner_priority, |
| 1049 | filter_inner_vid=filter_inner_vid, |
| 1050 | filter_inner_tpid_de=filter_inner_tpid_de, |
| 1051 | filter_ether_type=0, |
| 1052 | |
| 1053 | treatment_tags_to_remove=treatment_tags_to_remove, |
| 1054 | treatment_outer_priority=15, |
| 1055 | treatment_outer_vid=0, |
| 1056 | treatment_outer_tpid_de=0, |
| 1057 | |
| 1058 | treatment_inner_priority=treatment_inner_priority, |
| 1059 | treatment_inner_vid=treatment_inner_vid, |
| 1060 | treatment_inner_tpid_de=4 |
| 1061 | ) |
| 1062 | ) |
| 1063 | frame = OmciFrame( |
| 1064 | transaction_id=self.get_tx_id(), |
| 1065 | message_type=OmciSet.message_id, |
| 1066 | omci_message=OmciSet( |
| 1067 | entity_class= |
| 1068 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 1069 | entity_id=entity_id, |
| 1070 | attributes_mask= |
| 1071 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 1072 | *data.keys()), |
| 1073 | data=data |
| 1074 | ) |
| 1075 | ) |
| 1076 | self.send_omci_message(frame) |
| 1077 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1078 | def send_create_multicast_operations_profile(self, |
| 1079 | entity_id, |
| 1080 | igmp_ver): |
| 1081 | frame = OmciFrame( |
| 1082 | transaction_id=self.get_tx_id(), |
| 1083 | message_type=OmciCreate.message_id, |
| 1084 | omci_message=OmciCreate( |
| 1085 | entity_class= |
| 1086 | MulticastOperationsProfile.class_id, |
| 1087 | entity_id=entity_id, |
| 1088 | data=dict( |
| 1089 | igmp_version=igmp_ver, |
| 1090 | igmp_function=0, |
| 1091 | immediate_leave=0 |
| 1092 | ) |
| 1093 | ) |
| 1094 | ) |
| 1095 | self.send_omci_message(frame) |
| 1096 | |
| 1097 | def send_set_multicast_operations_profile_acl_row0(self, |
| 1098 | entity_id, |
| 1099 | acl_table, |
| 1100 | row_key, |
| 1101 | gem_port, |
| 1102 | vlan, |
| 1103 | src_ip, |
| 1104 | dst_ip_start, |
| 1105 | dst_ip_end): |
| 1106 | row0 = AccessControlRow0( |
| 1107 | set_ctrl=1, |
| 1108 | row_part_id=0, |
| 1109 | test=0, |
| 1110 | row_key=row_key, |
| 1111 | gem_port_id=gem_port, |
| 1112 | vlan_id=vlan, |
| 1113 | src_ip=src_ip, |
| 1114 | dst_ip_start=dst_ip_start, |
| 1115 | dst_ip_end=dst_ip_end, |
| 1116 | ipm_group_bw=0 |
| 1117 | ) |
| 1118 | |
| 1119 | if acl_table == 'dynamic': |
| 1120 | data = dict( |
| 1121 | dynamic_access_control_list_table=row0 |
| 1122 | ) |
| 1123 | else: |
| 1124 | data = dict( |
| 1125 | static_access_control_list_table=row0 |
| 1126 | ) |
| 1127 | |
| 1128 | frame = OmciFrame( |
| 1129 | transaction_id=self.get_tx_id(), |
| 1130 | message_type=OmciSet.message_id, |
| 1131 | omci_message=OmciSet( |
| 1132 | entity_class=MulticastOperationsProfile.class_id, |
| 1133 | entity_id=entity_id, |
| 1134 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 1135 | *data.keys()), |
| 1136 | data=data |
| 1137 | ) |
| 1138 | ) |
| 1139 | self.send_omci_message(frame) |
| 1140 | |
| 1141 | def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self, |
| 1142 | entity_id, |
| 1143 | ctrl_type, |
| 1144 | tci): |
| 1145 | data = dict( |
| 1146 | ds_igmp_mcast_tci= |
| 1147 | DownstreamIgmpMulticastTci( |
| 1148 | ctrl_type=ctrl_type, |
| 1149 | tci=tci |
| 1150 | ) |
| 1151 | ) |
| 1152 | frame = OmciFrame( |
| 1153 | transaction_id=self.get_tx_id(), |
| 1154 | message_type=OmciSet.message_id, |
| 1155 | omci_message=OmciSet( |
| 1156 | entity_class=MulticastOperationsProfile.class_id, |
| 1157 | entity_id=entity_id, |
| 1158 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 1159 | *data.keys()), |
| 1160 | data=data |
| 1161 | ) |
| 1162 | ) |
| 1163 | self.send_omci_message(frame) |
| 1164 | |
| 1165 | def send_create_multicast_subscriber_config_info(self, |
| 1166 | entity_id, |
| 1167 | me_type, |
| 1168 | mcast_oper_profile): |
| 1169 | frame = OmciFrame( |
| 1170 | transaction_id=self.get_tx_id(), |
| 1171 | message_type=OmciCreate.message_id, |
| 1172 | omci_message=OmciCreate( |
| 1173 | entity_class= |
| 1174 | MulticastSubscriberConfigInfo.class_id, |
| 1175 | entity_id=entity_id, |
| 1176 | data=dict( |
| 1177 | me_type=me_type, |
| 1178 | mcast_operations_profile_pointer=mcast_oper_profile |
| 1179 | ) |
| 1180 | ) |
| 1181 | ) |
| 1182 | self.send_omci_message(frame) |
| 1183 | |
| 1184 | def send_set_multicast_subscriber_config_info(self, |
| 1185 | entity_id, |
| 1186 | max_groups=0, |
| 1187 | max_mcast_bw=0, |
| 1188 | bw_enforcement=0): |
| 1189 | data = dict( |
| 1190 | max_simultaneous_groups=max_groups, |
| 1191 | max_multicast_bandwidth=max_mcast_bw, |
| 1192 | bandwidth_enforcement=bw_enforcement |
| 1193 | ) |
| 1194 | frame = OmciFrame( |
| 1195 | transaction_id=self.get_tx_id(), |
| 1196 | message_type=OmciSet.message_id, |
| 1197 | omci_message=OmciSet( |
| 1198 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1199 | entity_id=entity_id, |
| 1200 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1201 | *data.keys()), |
| 1202 | data=data |
| 1203 | ) |
| 1204 | ) |
| 1205 | self.send_omci_message(frame) |
| 1206 | |
| 1207 | def send_set_multicast_service_package(self, |
| 1208 | entity_id, |
| 1209 | row_key, |
| 1210 | vid_uni, |
| 1211 | max_groups, |
| 1212 | max_mcast_bw, |
| 1213 | mcast_oper_profile): |
| 1214 | data = dict( |
| 1215 | multicast_service_package_table= |
| 1216 | MulticastServicePackage( |
| 1217 | set_ctrl=1, |
| 1218 | row_key=row_key, |
| 1219 | |
| 1220 | vid_uni=vid_uni, |
| 1221 | max_simultaneous_groups=max_groups, |
| 1222 | max_multicast_bw=max_mcast_bw, |
| 1223 | mcast_operations_profile_pointer=mcast_oper_profile |
| 1224 | ) |
| 1225 | ) |
| 1226 | frame = OmciFrame( |
| 1227 | transaction_id=self.get_tx_id(), |
| 1228 | message_type=OmciSet.message_id, |
| 1229 | omci_message=OmciSet( |
| 1230 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1231 | entity_id=entity_id, |
| 1232 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1233 | *data.keys()), |
| 1234 | data=data |
| 1235 | ) |
| 1236 | ) |
| 1237 | self.send_omci_message(frame) |
| 1238 | |
| 1239 | def send_set_multicast_allowed_preview_groups_row0(self, |
| 1240 | entity_id, |
| 1241 | row_key, |
| 1242 | src_ip, |
| 1243 | vlan_id_ani, |
| 1244 | vlan_id_uni): |
| 1245 | data = dict( |
| 1246 | allowed_preview_groups_table= |
| 1247 | AllowedPreviewGroupsRow0( |
| 1248 | set_ctrl=1, |
| 1249 | row_part_id=0, |
| 1250 | row_key=row_key, |
| 1251 | |
| 1252 | src_ip=src_ip, |
| 1253 | vlan_id_ani=vlan_id_ani, |
| 1254 | vlan_id_uni=vlan_id_uni |
| 1255 | ) |
| 1256 | ) |
| 1257 | frame = OmciFrame( |
| 1258 | transaction_id=self.get_tx_id(), |
| 1259 | message_type=OmciSet.message_id, |
| 1260 | omci_message=OmciSet( |
| 1261 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1262 | entity_id=entity_id, |
| 1263 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1264 | *data.keys()), |
| 1265 | data=data |
| 1266 | ) |
| 1267 | ) |
| 1268 | self.send_omci_message(frame) |
| 1269 | |
| 1270 | def send_set_multicast_allowed_preview_groups_row1(self, |
| 1271 | entity_id, |
| 1272 | row_key, |
| 1273 | dst_ip, |
| 1274 | duration, |
| 1275 | time_left): |
| 1276 | data = dict( |
| 1277 | allowed_preview_groups_table= |
| 1278 | AllowedPreviewGroupsRow1( |
| 1279 | set_ctrl=1, |
| 1280 | row_part_id=1, |
| 1281 | row_key=row_key, |
| 1282 | |
| 1283 | dst_ip=dst_ip, |
| 1284 | duration=duration, |
| 1285 | time_left=time_left |
| 1286 | ) |
| 1287 | ) |
| 1288 | frame = OmciFrame( |
| 1289 | transaction_id=self.get_tx_id(), |
| 1290 | message_type=OmciSet.message_id, |
| 1291 | omci_message=OmciSet( |
| 1292 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1293 | entity_id=entity_id, |
| 1294 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1295 | *data.keys()), |
| 1296 | data=data |
| 1297 | ) |
| 1298 | ) |
| 1299 | self.send_omci_message(frame) |
| 1300 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1301 | def send_reboot(self): |
| 1302 | frame = OmciFrame( |
| 1303 | transaction_id=self.get_tx_id(), |
| 1304 | message_type=OmciReboot.message_id, |
| 1305 | omci_message=OmciReboot( |
| 1306 | entity_class=OntG.class_id, |
| 1307 | entity_id=0 |
| 1308 | ) |
| 1309 | ) |
| 1310 | self.send_omci_message(frame) |
| 1311 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1312 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1313 | def wait_for_response(self): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1314 | self.log.info('wait-for-response') |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1315 | try: |
| 1316 | response = yield self.incoming_messages.get() |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1317 | self.log.info('got-response') |
| 1318 | resp = OmciFrame(response) |
| 1319 | resp.show() |
| 1320 | returnValue(resp) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1321 | except Exception as e: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1322 | returnValue(None) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1323 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1324 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1325 | @inlineCallbacks |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1326 | def message_exchange(self, onu, gem, cvid): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1327 | self.log.info('message_exchange', onu=onu, gem=gem, cvid=cvid) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1328 | # reset incoming message queue |
| 1329 | while self.incoming_messages.pending: |
| 1330 | _ = yield self.incoming_messages.get() |
| 1331 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1332 | cvid = BRDCM_DEFAULT_VLAN |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1333 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1334 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1335 | # MIB Reset - OntData - 0 |
| 1336 | self.send_mib_reset() |
| 1337 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1338 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1339 | # Create AR - GalEthernetProfile - 1 |
| 1340 | self.send_create_gal_ethernet_profile(1, 48) |
| 1341 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1342 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1343 | # MAC Bridge Service config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1344 | # Create AR - MacBridgeServiceProfile - 513 |
| 1345 | self.send_create_mac_bridge_service_profile(0x201) |
| 1346 | yield self.wait_for_response() |
| 1347 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1348 | # Mapper Service config |
| 1349 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 1350 | self.send_create_8021p_mapper_service_profile(0x8001) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1351 | yield self.wait_for_response() |
| 1352 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1353 | # MAC Bridge Port config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1354 | # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769 |
| 1355 | self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001) |
| 1356 | yield self.wait_for_response() |
| 1357 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1358 | # VLAN Tagging Filter config |
| 1359 | # Create AR - VlanTaggingFilterData - 8450 - c-vid |
| 1360 | self.send_create_vlan_tagging_filter_data(0x2102, cvid) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1361 | yield self.wait_for_response() |
| 1362 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1363 | |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 1364 | for port_id in self.uni_ports: |
| 1365 | # Extended VLAN Tagging Operation config |
| 1366 | # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num) |
| 1367 | self.send_create_extended_vlan_tagging_operation_configuration_data(0x200 + port_id, 2, 0x100 + port_id) |
| 1368 | yield self.wait_for_response() |
| 1369 | |
| 1370 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
| 1371 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x200 + port_id, 0x8100, 0x8100) |
| 1372 | yield self.wait_for_response() |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | # Create AR - MacBridgePortConfigData - Entity_id - |
| 1377 | # bridge ID - |
| 1378 | # port num - |
| 1379 | # tp_type - |
| 1380 | # IEEE MApper poniter |
| 1381 | self.send_create_mac_bridge_port_configuration_data(0x200 + port_id, 0x201, port_id, 1, 0x100 + port_id) |
| 1382 | yield self.wait_for_response() |
| 1383 | |
| 1384 | |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1389 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
| 1390 | #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid) |
| 1391 | #yield self.wait_for_response() |
| 1392 | |
| 1393 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1394 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid |
| 1395 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, cvid) |
| 1396 | yield self.wait_for_response() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1397 | |
| 1398 | # Multicast related MEs |
| 1399 | # Set AR - MulticastOperationsProfile - Dynamic Access Control List table |
| 1400 | # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6 |
| 1401 | self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6) |
| 1402 | yield self.wait_for_response() |
| 1403 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1404 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1405 | # Create AR - MulticastOperationsProfile |
| 1406 | self.send_create_multicast_operations_profile(0x201, 3) |
| 1407 | yield self.wait_for_response() |
| 1408 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1409 | # Multicast Subscriber config |
| 1410 | # Create AR - MulticastSubscriberConfigInfo |
| 1411 | self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201) |
| 1412 | yield self.wait_for_response() |
| 1413 | |
| 1414 | # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast |
| 1415 | self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0) |
| 1416 | yield self.wait_for_response() |
| 1417 | |
| 1418 | # Multicast GEM Interworking config Multicast |
| 1419 | # Create AR - MulticastGemInterworkingTp - 6 - 260 |
| 1420 | self.send_create_multicast_gem_interworking_tp(0x6, 0x104) |
| 1421 | yield self.wait_for_response() |
| 1422 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1423 | self.send_set_multicast_operations_profile_acl_row0(0x201, |
| 1424 | 'dynamic', |
| 1425 | 0, |
| 1426 | 0x0fa0, |
| 1427 | 0x0fa0, |
| 1428 | '0.0.0.0', |
| 1429 | '224.0.0.0', |
| 1430 | '239.255.255.255') |
| 1431 | yield self.wait_for_response() |
| 1432 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1433 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1434 | # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1435 | self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid) |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1436 | yield self.wait_for_response() |
| 1437 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1438 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1439 | |
| 1440 | def add_uni_port(self, device, parent_logical_device_id, |
| 1441 | name, parent_port_num=None): |
| 1442 | self.log.info('adding-logical-port', device_id=device.id, |
| 1443 | logical_device_id=parent_logical_device_id, |
| 1444 | name=name) |
| 1445 | if parent_port_num is not None: |
| 1446 | uni = parent_port_num |
| 1447 | port_no = parent_port_num |
| 1448 | else: |
| 1449 | uni = self.uni_ports[0] |
| 1450 | port_no = device.proxy_address.channel_id + uni |
| 1451 | # register physical ports |
| 1452 | uni_port = Port( |
| 1453 | port_no=uni, |
Shad Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame^] | 1454 | label='uni-'+str(uni), |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1455 | type=Port.ETHERNET_UNI, |
| 1456 | admin_state=AdminState.ENABLED, |
| 1457 | oper_status=OperStatus.ACTIVE |
| 1458 | ) |
| 1459 | self.adapter_agent.add_port(device.id, uni_port) |
| 1460 | # add uni port to logical device |
| 1461 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
| 1462 | self.adapter_agent.add_logical_port(parent_logical_device_id, |
| 1463 | LogicalPort( |
| 1464 | id='uni-{}'.format(port_no), |
| 1465 | ofp_port=ofp_port( |
| 1466 | port_no=port_no, |
| 1467 | hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' % |
| 1468 | (device.proxy_address.onu_id & 0xff, |
| 1469 | (port_no >> 8) & 0xff, |
| 1470 | port_no & 0xff)), |
| 1471 | #name='uni-{}'.format(port_no), |
| 1472 | name=name, |
| 1473 | config=0, |
| 1474 | state=OFPPS_LIVE, |
| 1475 | curr=cap, |
| 1476 | advertised=cap, |
| 1477 | peer=cap, |
| 1478 | curr_speed=OFPPF_1GB_FD, |
| 1479 | max_speed=OFPPF_1GB_FD |
| 1480 | ), |
| 1481 | device_id=device.id, |
| 1482 | device_port_no=uni_port.port_no |
| 1483 | )) |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1484 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1485 | def del_uni_port(self, device, parent_logical_device_id, |
| 1486 | name, parent_port_num=None): |
| 1487 | self.log.info('del-uni-port', device_id=device.id, |
| 1488 | logical_device_id=parent_logical_device_id, |
| 1489 | name=name) |
| 1490 | if parent_port_num is not None: |
| 1491 | uni = parent_port_num |
| 1492 | port_no = parent_port_num |
| 1493 | else: |
| 1494 | uni = self.uni_ports[0] |
| 1495 | port_no = device.proxy_address.channel_id + uni |
| 1496 | # register physical ports |
| 1497 | ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_UNI) |
| 1498 | for port in ports: |
Shad Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame^] | 1499 | if port.label == 'uni-'+str(uni): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1500 | break |
| 1501 | self.adapter_agent.delete_port(self.device_id, port) |
| 1502 | self.adapter_agent.delete_logical_port_by_id(parent_logical_device_id, |
| 1503 | 'uni-{}'.format(port_no)) |
| 1504 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1505 | |
| 1506 | @inlineCallbacks |
| 1507 | def delete_v_ont_ani(self, data): |
| 1508 | self.log.info('deleting-v_ont_ani') |
| 1509 | |
| 1510 | device = self.adapter_agent.get_device(self.device_id) |
| 1511 | # construct message |
| 1512 | # MIB Reset - OntData - 0 |
| 1513 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1514 | self.log.error('device-unreachable') |
| 1515 | returnValue(None) |
| 1516 | |
| 1517 | self.send_mib_reset() |
| 1518 | yield self.wait_for_response() |
| 1519 | self.proxy_address = device.proxy_address |
| 1520 | self.adapter_agent.unregister_for_proxied_messages(device.proxy_address) |
| 1521 | |
| 1522 | ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU) |
| 1523 | if ports is not None: |
| 1524 | for port in ports: |
| 1525 | if port.label == 'PON port': |
| 1526 | self.adapter_agent.delete_port(self.device_id, port) |
| 1527 | break |
| 1528 | |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1529 | def create_interface(self, data): |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1530 | if isinstance(data, VEnetConfig): |
| 1531 | parent_port_num = None |
| 1532 | onu_device = self.adapter_agent.get_device(self.device_id) |
| 1533 | ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI) |
| 1534 | parent_port_num = None |
| 1535 | for port in ports: |
| 1536 | if port.label == data.interface.name: |
| 1537 | parent_port_num = port.port_no |
| 1538 | break |
| 1539 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1540 | parent_device = self.adapter_agent.get_device(onu_device.parent_id) |
| 1541 | logical_device_id = parent_device.parent_id |
| 1542 | assert logical_device_id |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1543 | self.add_uni_port(onu_device, logical_device_id, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1544 | data.name, parent_port_num) |
| 1545 | |
| 1546 | if parent_port_num is None: |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1547 | self.log.error("matching-parent-uni-port-num-not-found") |
| 1548 | return |
| 1549 | |
| 1550 | onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU) |
| 1551 | if onu_ports: |
| 1552 | # To-Do : |
| 1553 | # Assumed only one PON port and UNI port per ONU. |
| 1554 | pon_port = onu_ports[0] |
| 1555 | else: |
| 1556 | self.log.error("No-Pon-port-configured-yet") |
| 1557 | return |
| 1558 | |
| 1559 | self.adapter_agent.delete_port_reference_from_parent(self.device_id, |
| 1560 | pon_port) |
| 1561 | |
| 1562 | pon_port.peers[0].device_id = onu_device.parent_id |
| 1563 | pon_port.peers[0].port_no = parent_port_num |
| 1564 | self.adapter_agent.add_port_reference_to_parent(self.device_id, |
| 1565 | pon_port) |
| 1566 | else: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1567 | self.log.info('Not-handled-Yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1568 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1569 | |
| 1570 | def update_interface(self, data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1571 | self.log.info('Not-Implemented-yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1572 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1573 | |
| 1574 | def remove_interface(self, data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1575 | if isinstance(data, VEnetConfig): |
| 1576 | parent_port_num = None |
| 1577 | onu_device = self.adapter_agent.get_device(self.device_id) |
| 1578 | ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI) |
| 1579 | parent_port_num = None |
| 1580 | for port in ports: |
| 1581 | if port.label == data.interface.name: |
| 1582 | parent_port_num = port.port_no |
| 1583 | break |
| 1584 | |
| 1585 | parent_device = self.adapter_agent.get_device(onu_device.parent_id) |
| 1586 | logical_device_id = parent_device.parent_id |
| 1587 | assert logical_device_id |
| 1588 | self.del_uni_port(onu_device, logical_device_id, |
| 1589 | data.name, parent_port_num) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1590 | if isinstance(data, VOntaniConfig): |
| 1591 | self.delete_v_ont_ani(data) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1592 | else: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1593 | self.log.info('not-handled-yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1594 | return |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1595 | |
| 1596 | @inlineCallbacks |
| 1597 | def create_gemport(self, data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1598 | self.log.info('create-gemport') |
| 1599 | gem_port = GemportsConfigData() |
| 1600 | gem_port.CopyFrom(data) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1601 | if gem_port.tcont_ref is None: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1602 | self.log.error('recevied-null-gem-port-data') |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1603 | else: |
| 1604 | #To-Do Need to see how the valuse 0x8001 is derived |
| 1605 | self.send_create_gem_port_network_ctp(gem_port.gemport_id, |
| 1606 | gem_port.gemport_id, 0x8001, |
| 1607 | "bi-directional", 0x100) |
| 1608 | yield self.wait_for_response() |
| 1609 | |
| 1610 | # GEM Interworking config |
| 1611 | # Create AR - GemInterworkingTp - Gem_port,TP_pointer - |
| 1612 | # Gem port CTP pointer - |
| 1613 | # Mapper service profile id |
| 1614 | self.send_create_gem_inteworking_tp(gem_port.gemport_id, |
| 1615 | gem_port.gemport_id, 0x8001) |
| 1616 | yield self.wait_for_response() |
| 1617 | |
| 1618 | # Mapper Service Profile config |
| 1619 | # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id - |
| 1620 | # gem_port_tp pointer |
| 1621 | self.send_set_8021p_mapper_service_profile(0x8001, |
| 1622 | gem_port.gemport_id) |
| 1623 | yield self.wait_for_response() |
| 1624 | |
| 1625 | |
| 1626 | @inlineCallbacks |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1627 | def remove_gemport(self, data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1628 | self.log.info('remove-gemport') |
| 1629 | gem_port = GemportsConfigData() |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1630 | gem_port.CopyFrom(data) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1631 | device = self.adapter_agent.get_device(self.device_id) |
| 1632 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1633 | self.log.error('device-unreachable') |
| 1634 | returnValue(None) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1635 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1636 | self.send_set_8021p_mapper_service_profile(0x8001, |
| 1637 | 0xFFFF) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1638 | yield self.wait_for_response() |
| 1639 | |
| 1640 | self.send_delete_omci_mesage(GemInterworkingTp.class_id, |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1641 | gem_port.gemport_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1642 | yield self.wait_for_response() |
| 1643 | |
| 1644 | #To-Do Need to see how the valuse 0x8001 is derived |
| 1645 | self.send_delete_omci_mesage(GemPortNetworkCtp.class_id, |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1646 | gem_port.gemport_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1647 | yield self.wait_for_response() |
| 1648 | |
| 1649 | @inlineCallbacks |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1650 | def create_tcont(self, tcont_data, traffic_descriptor_data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1651 | self.log.info('create-tcont') |
| 1652 | tcont = TcontsConfigData() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1653 | tcont.CopyFrom(tcont_data) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1654 | if tcont.interface_reference is not None: |
| 1655 | self.log.debug('tcont', tcont=tcont.alloc_id) |
| 1656 | self.send_set_tcont(0x8001, tcont.alloc_id) |
| 1657 | yield self.wait_for_response() |
| 1658 | else: |
| 1659 | self.log.info('recevied-null-tcont-data', tcont=tcont.alloc_id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1660 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1661 | @inlineCallbacks |
| 1662 | def remove_tcont(self, tcont_data, traffic_descriptor_data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1663 | self.log.info('remove-tcont') |
| 1664 | device = self.adapter_agent.get_device(self.device_id) |
| 1665 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1666 | self.log.error('device-unreachable') |
| 1667 | returnValue(None) |
| 1668 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1669 | self.send_set_tcont(0x8001, 0xFFFF) |
| 1670 | yield self.wait_for_response() |
| 1671 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1672 | def create_multicast_gemport(self, data): |
| 1673 | self.log.info('Send relevant OMCI message') |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1674 | |
| 1675 | @inlineCallbacks |
| 1676 | def disable(self, device): |
| 1677 | try: |
| 1678 | self.log.info('sending-admin-state-lock-towards-device', device=device) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1679 | |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1680 | self.send_set_admin_state(0x0000, ADMIN_STATE_LOCK) |
| 1681 | yield self.wait_for_response() |
| 1682 | device = self.adapter_agent.get_device(device.id) |
| 1683 | # Disable all ports on that device |
| 1684 | self.adapter_agent.disable_all_ports(self.device_id) |
| 1685 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 1686 | logical_device_id = parent_device.parent_id |
| 1687 | assert logical_device_id |
| 1688 | # Mark OF PORT STATE DOWN |
| 1689 | ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI) |
| 1690 | for port in ports: |
| 1691 | state = OFPPS_LINK_DOWN |
| 1692 | port_id = 'uni-{}'.format(port.port_no) |
| 1693 | self.update_logical_port(logical_device_id, port_id, state) |
| 1694 | device.oper_status = OperStatus.UNKNOWN |
| 1695 | device.connect_status = ConnectStatus.UNREACHABLE |
| 1696 | self.adapter_agent.update_device(device) |
| 1697 | except Exception as e: |
| 1698 | log.exception('exception-in-onu-disable', exception=e) |
| 1699 | |
| 1700 | @inlineCallbacks |
| 1701 | def reenable(self, device): |
| 1702 | try: |
| 1703 | self.log.info('sending-admin-state-unlock-towards-device', device=device) |
| 1704 | self.send_set_admin_state(0x0000, ADMIN_STATE_UNLOCK) |
| 1705 | yield self.wait_for_response() |
| 1706 | device = self.adapter_agent.get_device(device.id) |
| 1707 | # Re-enable the ports on that device |
| 1708 | self.adapter_agent.enable_all_ports(device.id) |
| 1709 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 1710 | logical_device_id = parent_device.parent_id |
| 1711 | assert logical_device_id |
| 1712 | # Mark OF PORT STATE UP |
| 1713 | ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI) |
| 1714 | for port in ports: |
| 1715 | state = OFPPS_LIVE |
| 1716 | port_id = 'uni-{}'.format(port.port_no) |
| 1717 | self.update_logical_port(logical_device_id, port_id, state) |
| 1718 | device.oper_status = OperStatus.ACTIVE |
| 1719 | device.connect_status = ConnectStatus.REACHABLE |
| 1720 | self.adapter_agent.update_device(device) |
| 1721 | except Exception as e: |
| 1722 | log.exception('exception-in-onu-reenable', exception=e) |
| 1723 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1724 | @inlineCallbacks |
| 1725 | def reboot(self): |
| 1726 | self.log.info('reboot-device') |
| 1727 | device = self.adapter_agent.get_device(self.device_id) |
| 1728 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1729 | self.log.error("device-unreacable") |
| 1730 | returnValue(None) |
| 1731 | |
| 1732 | self.send_reboot() |
| 1733 | response = yield self.wait_for_response() |
| 1734 | if response is not None: |
| 1735 | omci_response = response.getfieldval("omci_message") |
| 1736 | success_code = omci_response.getfieldval("success_code") |
| 1737 | if success_code == 0: |
| 1738 | self.log.info("reboot-command-processed-successfully") |
| 1739 | # Update the device connection and operation status |
| 1740 | device = self.adapter_agent.get_device(self.device_id) |
| 1741 | device.connect_status = ConnectStatus.UNREACHABLE |
| 1742 | device.oper_status = OperStatus.DISCOVERED |
| 1743 | self.adapter_agent.update_device(device) |
| 1744 | self.disable_ports(device) |
| 1745 | else: |
| 1746 | self.log.info("reboot-failed", success_code=success_code) |
| 1747 | else: |
| 1748 | self.log.info("error-in-processing-reboot-response") |
| 1749 | |
| 1750 | def disable_ports(self, onu_device): |
| 1751 | self.log.info('disable-ports', device_id=self.device_id) |
| 1752 | |
| 1753 | # Disable all ports on that device |
| 1754 | self.adapter_agent.disable_all_ports(self.device_id) |
| 1755 | |
| 1756 | parent_device = self.adapter_agent.get_device(onu_device.parent_id) |
| 1757 | assert parent_device |
| 1758 | logical_device_id = parent_device.parent_id |
| 1759 | assert logical_device_id |
| 1760 | ports = self.adapter_agent.get_ports(onu_device.id, Port.ETHERNET_UNI) |
| 1761 | for port in ports: |
| 1762 | port_id = 'uni-{}'.format(port.port_no) |
| 1763 | self.update_logical_port(logical_device_id, port_id, OFPPS_LINK_DOWN) |