def get_bgp_neighbors_detail(self, neighbor_address='<STR_LIT>'):
bgp_neighbors = {}<EOL>default_neighbor_details = {<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT>',<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': -<NUM_LIT:1>,<EOL>'<STR_LIT>': <NUM_LIT:0><EOL>}<EOL>OPTION_KEY_MAP = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>def _bgp_iter_core(neighbor_data, instance=None):<EOL><INDENT>'''<STR_LIT>'''<EOL>for bgp_neighbor in neighbor_data:<EOL><INDENT>remote_as = int(bgp_neighbor[<NUM_LIT:0>])<EOL>neighbor_details = deepcopy(default_neighbor_details)<EOL>neighbor_details.update(<EOL>{elem[<NUM_LIT:0>]: elem[<NUM_LIT:1>] for elem in bgp_neighbor[<NUM_LIT:1>] if elem[<NUM_LIT:1>] is not None}<EOL>)<EOL>if not instance:<EOL><INDENT>peer_fwd_rti = neighbor_details.pop('<STR_LIT>')<EOL>instance = peer_fwd_rti<EOL><DEDENT>else:<EOL><INDENT>peer_fwd_rti = neighbor_details.pop('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>instance_name = '<STR_LIT>' if instance == '<STR_LIT>' else instance<EOL>options = neighbor_details.pop('<STR_LIT>', '<STR_LIT>')<EOL>if isinstance(options, str):<EOL><INDENT>options_list = options.split()<EOL>for option in options_list:<EOL><INDENT>key = OPTION_KEY_MAP.get(option)<EOL>if key is not None:<EOL><INDENT>neighbor_details[key] = True<EOL><DEDENT><DEDENT><DEDENT>four_byte_as = neighbor_details.pop('<STR_LIT>', <NUM_LIT:0>)<EOL>local_address = neighbor_details.pop('<STR_LIT>', '<STR_LIT>')<EOL>local_details = local_address.split('<STR_LIT:+>')<EOL>neighbor_details['<STR_LIT>'] = napalm_base.helpers.convert(<EOL>napalm_base.helpers.ip, local_details[<NUM_LIT:0>], local_details[<NUM_LIT:0>])<EOL>if len(local_details) == <NUM_LIT:2>:<EOL><INDENT>neighbor_details['<STR_LIT>'] = int(local_details[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>neighbor_details['<STR_LIT>'] = <NUM_LIT><EOL><DEDENT>neighbor_details['<STR_LIT>'] = (remote_as != four_byte_as)<EOL>peer_address = neighbor_details.pop('<STR_LIT>', '<STR_LIT>')<EOL>remote_details = peer_address.split('<STR_LIT:+>')<EOL>neighbor_details['<STR_LIT>'] = napalm_base.helpers.convert(<EOL>napalm_base.helpers.ip, remote_details[<NUM_LIT:0>], remote_details[<NUM_LIT:0>])<EOL>if len(remote_details) == <NUM_LIT:2>:<EOL><INDENT>neighbor_details['<STR_LIT>'] = int(remote_details[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>neighbor_details['<STR_LIT>'] = <NUM_LIT><EOL><DEDENT>neighbor_details['<STR_LIT>'] = instance_name<EOL>neighbor_details['<STR_LIT>'] = napalm_base.helpers.as_number(<EOL>neighbor_details['<STR_LIT>'])<EOL>neighbor_details['<STR_LIT>'] = napalm_base.helpers.as_number(<EOL>neighbor_details['<STR_LIT>'])<EOL>neighbors_rib = neighbor_details.pop('<STR_LIT>')<EOL>neighbors_queue = neighbor_details.pop('<STR_LIT>')<EOL>messages_queued_out = <NUM_LIT:0><EOL>for queue_entry in neighbors_queue.items():<EOL><INDENT>messages_queued_out += queue_entry[<NUM_LIT:1>][<NUM_LIT:0>][<NUM_LIT:1>]<EOL><DEDENT>neighbor_details['<STR_LIT>'] = messages_queued_out<EOL>if instance_name not in bgp_neighbors.keys():<EOL><INDENT>bgp_neighbors[instance_name] = {}<EOL><DEDENT>if remote_as not in bgp_neighbors[instance_name].keys():<EOL><INDENT>bgp_neighbors[instance_name][remote_as] = []<EOL><DEDENT>neighbor_rib_stats = neighbors_rib.items()<EOL>if not neighbor_rib_stats:<EOL><INDENT>bgp_neighbors[instance_name][remote_as].append(neighbor_details)<EOL>continue  <EOL><DEDENT>neighbor_rib_details = {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0><EOL>}<EOL>for rib_entry in neighbor_rib_stats:<EOL><INDENT>for elem in rib_entry[<NUM_LIT:1>]:<EOL><INDENT>if elem[<NUM_LIT:1>] is None:<EOL><INDENT>neighbor_rib_details[elem[<NUM_LIT:0>]] += <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>neighbor_rib_details[elem[<NUM_LIT:0>]] += elem[<NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT>neighbor_details.update(neighbor_rib_details)<EOL>bgp_neighbors[instance_name][remote_as].append(neighbor_details)<EOL><DEDENT><DEDENT>bgp_neighbors_table = junos_views.junos_bgp_neighbors_table(self.device)<EOL>instances = junos_views.junos_route_instance_table(self.device)<EOL>for instance, instance_data in instances.get().items():<EOL><INDENT>if instance.startswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>neighbor_data = bgp_neighbors_table.get(instance=instance,<EOL>neighbor_address=str(neighbor_address)).items()<EOL>_bgp_iter_core(neighbor_data, instance=instance)<EOL><DEDENT>return bgp_neighbors<EOL>
Detailed view of the BGP neighbors operational data.