def _get_onu_info(self, serial_number): """ Parse through available xPON information for ONU configuration settings :param serial_number: (string) Decoded (not base64) serial number string :return: (dict) onu config data or None on lookup failure """ try: from flow.demo_data import get_tconts, get_gem_ports if self.activation_method == "autoactivate": onu_id = self.get_next_onu_id() enabled = True channel_speed = 0 elif self.activation_method == "autodiscovery": if self.authentication_method == 'serial-number': gpon_info = self.olt.get_xpon_info(self.pon_id) try: vont_info = next( info for _, info in gpon_info['v_ont_anis'].items() if info.get( 'expected-serial-number') == serial_number) onu_id = vont_info['onu-id'] enabled = vont_info['enabled'] channel_speed = vont_info['upstream-channel-speed'] except StopIteration: return None else: return None else: return None onu_info = { 'serial-number': serial_number, 'xpon-name': None, 'pon': self, 'onu-id': onu_id, 'enabled': enabled, 'upstream-channel-speed': channel_speed, 'password': Onu.DEFAULT_PASSWORD, 't-conts': get_tconts(self.pon_id, serial_number, onu_id), 'gem-ports': get_gem_ports(self.pon_id, serial_number, onu_id), 'onu-vid': self.olt.get_channel_id(self._pon_id, onu_id) } return onu_info except Exception as e: self.log.exception('get-onu-info', e=e) return None
def _get_onu_info(self, serial_number): """ Parse through available xPON information for ONU configuration settings :param serial_number: (string) Decoded (not base64) serial number string :return: (dict) onu config data or None on lookup failure """ try: from flow.demo_data import get_tconts, get_gem_ports, get_onu_id if self.activation_method == "autoactivate": # This is currently just for 'DEMO' mode onu_id = get_onu_id(serial_number) if onu_id is None: onu_id = self.get_next_onu_id() enabled = True channel_speed = 8500000000 tconts = get_tconts(serial_number, onu_id) gem_ports = get_gem_ports(serial_number, onu_id) vont_ani = None xpon_name = None upstream_fec_enabled = True elif self.activation_method == "autodiscovery": if self.authentication_method == 'serial-number': gpon_info = self.olt.get_xpon_info(self.pon_id) try: # TODO: Change iteration to itervalues below vont_info = next(info for _, info in gpon_info['vont-anis'].items() if info.get('expected-serial-number') == serial_number) ont_info = next(info for _, info in gpon_info['ont-anis'].items() if info.get('name') == vont_info['name']) vont_ani = vont_info['data'] onu_id = vont_info['onu-id'] enabled = vont_info['enabled'] channel_speed = vont_info['upstream-channel-speed'] xpon_name = ont_info['name'] upstream_fec_enabled = ont_info.get('upstream-fec', False) tconts = {key: val for key, val in gpon_info['tconts'].iteritems() if val.vont_ani == vont_info['name']} gem_ports = {key: val for key, val in gpon_info['gem-ports'].iteritems() if val.tcont_ref in tconts.keys()} except StopIteration: # Can happen if vont-ani or ont-ani has not yet been configured self.log.debug('no-vont-or-ont') return None except Exception as e: self.log.exception('autodiscovery', e=e) raise else: self.log.debug('not-serial-number-authentication') return None else: self.log.debug('not-auto-discovery') return None onu_info = { 'device-id': self.olt.device_id, 'serial-number': serial_number, 'xpon-name': xpon_name, 'pon': self, 'onu-id': onu_id, 'enabled': enabled, 'upstream-channel-speed': channel_speed, 'upstream-fec': upstream_fec_enabled, 'password': Onu.DEFAULT_PASSWORD, 't-conts': tconts, 'gem-ports': gem_ports, 'onu-vid': self.olt.get_channel_id(self._pon_id, onu_id), 'channel-id': self.olt.get_channel_id(self._pon_id, onu_id), 'vont-ani': vont_ani } # Hold off ONU activation until at least one GEM Port is defined. self.log.debug('onu-info', gem_ports=gem_ports) return onu_info # return onu_info if len(gem_ports) > 0 else None except Exception as e: self.log.exception('get-onu-info', e=e) return None
def _get_onu_info(self, serial_number): """ Parse through available xPON information for ONU configuration settings :param serial_number: (string) Decoded (not base64) serial number string :return: (dict) onu config data or None on lookup failure """ try: from flow.demo_data import get_tconts, get_gem_ports, get_onu_id if self.activation_method == "autoactivate": onu_id = get_onu_id(serial_number) if onu_id is None: onu_id = self.get_next_onu_id() enabled = True channel_speed = 0 tconts = get_tconts(serial_number, onu_id) gem_ports = get_gem_ports(serial_number, onu_id) vont_ani = None elif self.activation_method == "autodiscovery": if self.authentication_method == 'serial-number': gpon_info = self.olt.get_xpon_info(self.pon_id) try: # TODO: Change iteration to itervalues below vont_info = next(info for _, info in gpon_info['v-ont-anis'].items() if info.get('expected-serial-number') == serial_number) vont_ani = vont_info['data'] onu_id = vont_info['onu-id'] enabled = vont_info['enabled'] channel_speed = vont_info['upstream-channel-speed'] tconts = {key: val for key, val in gpon_info['tconts'].iteritems() if val.vont_ani == vont_info['name']} tcont_names = set(tconts.keys()) gem_ports = {key: val for key, val in gpon_info['gem-ports'].iteritems() if val.tconf_ref in tcont_names} except StopIteration: self.log.debug('no-vont-ony') return None # Can happen if vont-ani/serial-number has not yet been configured else: self.log.debug('not-serial-number-authentication') return None else: self.log.debug('not-auto-discovery') return None onu_info = { 'device-id': self.olt.device_id, 'serial-number': serial_number, 'xpon-name': None, 'pon': self, 'onu-id': onu_id, 'enabled': enabled, 'upstream-channel-speed': channel_speed, 'password': Onu.DEFAULT_PASSWORD, 't-conts': tconts, 'gem-ports': gem_ports, 'onu-vid': self.olt.get_channel_id(self._pon_id, onu_id), 'channel-id': self.olt.get_channel_id(self._pon_id, onu_id), 'vont-ani': vont_ani } # Hold off ONU activation until at least one GEM Port is defined. self.log.debug('onu-info', gem_ports=gem_ports) return onu_info # return onu_info if len(gem_ports) > 0 else None except Exception as e: self.log.exception('get-onu-info', e=e) return None