def _juniper_bgp_api_converter(hostname: str, cmd_output: dict, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): if not isinstance(v.get('bgp'), dict): v['bgp'] = format_xml_output(v.get('bgp')) if not isinstance(v.get('rid'), dict): v['rid'] = format_xml_output(v.get('rid')) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL3): printline() PP.pprint(v) bgp_sessions_lst = ListBGPSessions(list()) if ('bgp' in v.keys() and 'bgp-information' in v.get('bgp').keys() and v.get('bgp').get('bgp-information') is not None and 'bgp-peer' in v.get('bgp').get('bgp-information').keys()): for n in v.get('bgp').get('bgp-information').get('bgp-peer'): bgp_sessions_lst.bgp_sessions.append( BGPSession(src_hostname=hostname, peer_ip=n.get('peer-address', NOT_SET), peer_hostname=NOT_SET, remote_as=n.get('peer-as', NOT_SET), state_brief=get_bgp_state_brief( n.get('peer-state', NOT_SET)), session_state=n.get('peer-state', NOT_SET), state_time=NOT_SET, prefix_received=NOT_SET, options=options)) as_number = n.get('bgp-option-information').get('local-as') router_id = NOT_SET if ('rid' in v.keys() and 'instance-information' in v.get('rid').keys() and 'instance-core' in v.get('rid').get('instance-information').keys()): router_id = v.get('rid') \ .get('instance-information') \ .get('instance-core') \ .get('router-id') bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF(vrf_name=k, as_number=as_number, router_id=router_id, bgp_sessions=bgp_sessions_lst)) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL1): printline() print(f'>>>>> {hostname}') PP.pprint(bgp.to_json()) return bgp
def _extreme_vsp_bgp_ssh_converter(hostname: str, cmd_output, options={}) -> BGP: if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL3): printline() PP.pprint(cmd_output) bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) if cmd_output is not None: for vrf in cmd_output: cmd_output[vrf] = parse_textfsm( content=str(cmd_output[vrf]), template_file="extreme_vsp_show_ip_bgp_summary.textfsm") bgp_sessions_lst = ListBGPSessions(bgp_sessions=list()) asn = NOT_SET router_id = NOT_SET for v in cmd_output.get(vrf): if v[3] != '': asn = v[1] router_id = v[2] bgp_sessions_lst.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=v[3], peer_hostname=NOT_SET, remote_as=v[4], state_brief=get_bgp_state_brief(v[5]), session_state=v[5], state_time=_extreme_vsp_peer_uptime_converter( day=v[13], hour=v[14], min=v[15], sec=v[16], ), prefix_received=NOT_SET, )) bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF( vrf_name=vrf, as_number=asn, router_id=router_id, bgp_sessions=bgp_sessions_lst, )) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL1): printline() print(f">>>>> {hostname}") PP.pprint(bgp.to_json()) return bgp
def _cumulus_bgp_api_converter(hostname: str, cmd_output, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): if not isinstance(v, dict): v = json.loads(v) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL3): printline() PP.pprint(v) peer = False if ('ipv4 unicast' in v.keys() and 'ipv4Unicast' in v.get('ipv4 unicast').keys() and 'peers' in v.get('ipv4 unicast').get('ipv4Unicast').keys()): sub_dict = v.get('ipv4 unicast').get('ipv4Unicast') peer = True elif ('ipv4 unicast' in v.keys() and 'peers' in v.get('ipv4 unicast').keys()): sub_dict = v.get('ipv4 unicast') peer = True if peer: bgp_vrf = BGPSessionsVRF( vrf_name=k, as_number=sub_dict.get('as', NOT_SET), router_id=sub_dict.get('routerId', NOT_SET), bgp_sessions=ListBGPSessions(bgp_sessions=list())) for i, p in sub_dict.get('peers').items(): bgp_vrf.bgp_sessions.bgp_sessions.append( BGPSession(src_hostname=hostname, peer_ip=i, peer_hostname=p.get('hostname', NOT_SET), remote_as=p.get('remoteAs', NOT_SET), state_brief=get_bgp_state_brief( p.get('state', NOT_SET)), session_state=p.get('state', NOT_SET), state_time=get_bgp_peer_uptime( value=p.get('peerUptimeMsec', NOT_SET), format=BGP_UPTIME_FORMAT_MS), prefix_received=p.get('prefixReceivedCount', NOT_SET), options=options)) bgp_sessions_vrf_lst.bgp_sessions_vrf.append(bgp_vrf) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL1): printline() print(f">>>>> {hostname}") PP.pprint(bgp.to_json()) return bgp
def _iosxr_bgp_ssh_converter(hostname: str, cmd_output: dict, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): v['peers'] = parse_textfsm( content=v.get('peers'), template_file='cisco_xr_show_bgp_neighbors.textfsm') v['rid'] = parse_textfsm(content=v.get('rid'), template_file='cisco_xr_show_bgp.textfsm') if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL3): printline() print(v) bgp_sessions_lst = ListBGPSessions(list()) asn = NOT_SET if len(v['peers']) > 0: for i in v['peers']: asn = i[3] bgp_sessions_lst.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=i[0], peer_hostname=NOT_SET, remote_as=i[2], state_brief=get_bgp_state_brief(i[4]), session_state=i[4], state_time=NOT_SET, prefix_received=NOT_SET, )) if len(v['rid']) > 0: rid = v['rid'][0][0] else: rid = NOT_SET bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF( vrf_name=k, as_number=asn, router_id=rid, bgp_sessions=bgp_sessions_lst, )) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL1): printline() print(f'>>>>> {hostname}') PP.pprint(bgp.to_json()) return bgp
def _arista_bgp_api_converter(hostname: str, cmd_output, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL3): printline() PP.pprint(cmd_output) bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for vrf in cmd_output.get('result', []): if 'vrfs' in vrf.keys() and len(vrf.get('vrfs').keys()) > 0: bgp_sessions_lst = ListBGPSessions(list()) for name, facts in vrf.get("vrfs", NOT_SET).items(): for n, f in facts.get('peers').items(): bgp_sessions_lst.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=n, peer_hostname=f.get("hostname", NOT_SET), remote_as=f.get("asn", NOT_SET), state_brief=get_bgp_state_brief( state=f.get('peerState')), session_state=f.get("peerState", NOT_SET), state_time=f.get("upDownTime", NOT_SET), prefix_received=f.get("prefixReceived", NOT_SET), )) bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF( vrf_name=name, as_number=facts.get('asn', NOT_SET), router_id=facts.get("routerId", NOT_SET), bgp_sessions=bgp_sessions_lst, )) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL1): printline() print(f">>>>> {hostname}") PP.pprint(bgp.to_json()) return bgp
def _napalm_bgp_converter(hostname: str(), cmd_output: json, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) local_as = "" if "get_bgp_neighbors" in cmd_output.keys(): for k, v in cmd_output.get("get_bgp_neighbors").items(): bgp_sessions_lst = ListBGPSessions(list()) for peer_ip, facts in v.get("peers").items(): bgp_obj = BGPSession( src_hostname=hostname, peer_ip=peer_ip, peer_hostname=facts.get("hostname", NOT_SET), remote_as=facts.get("remote_as", NOT_SET), state_brief=_napalm_bgp_status_converter( facts.get("is_up", NOT_SET)), session_state=facts.get("session_state", NOT_SET), state_time=facts.get("uptime", NOT_SET), prefix_received=facts.get("address_family").get( "ipv4").get("received_prefixes"), ) local_as = facts.get("local_as", NOT_SET) bgp_sessions_lst.bgp_sessions.append(bgp_obj) bgp_session_vrf = BGPSessionsVRF( vrf_name=_napalm_bgp_vrf_converter(k), as_number=local_as, router_id=v.get("router_id"), bgp_sessions=bgp_sessions_lst, ) bgp_sessions_vrf_lst.bgp_sessions_vrf.append(bgp_session_vrf) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL1): printline() print(f'>>>>> {hostname}') PP.pprint(bgp.to_json()) return bgp
def _ios_bgp_netconf_converter(hostname: str, cmd_output: dict, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) cmd_output = format_xml_output(cmd_output) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL3): printline() print(cmd_output) if ('data' in cmd_output.keys() and 'bgp-state-data' in cmd_output.get('data').keys() and 'address-families' in cmd_output.get('data').get('bgp-state-data').keys() and 'address-family' in cmd_output.get('data').get( 'bgp-state-data').get('address-families').keys()): for v in cmd_output.get('data') \ .get('bgp-state-data') \ .get('address-families') \ .get('address-family'): bgp_sessions_lst = ListBGPSessions(list()) if ('bgp-neighbor-summaries' in v.keys() and 'bgp-neighbor-summary' in v.get('bgp-neighbor-summaries').keys()): if isinstance( v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary'), list): for n in v.get('bgp-neighbor-summaries') \ .get('bgp-neighbor-summary'): bgp_sessions_lst.bgp_sessions.append( BGPSession(src_hostname=hostname, peer_ip=n.get('id', NOT_SET), peer_hostname=NOT_SET, remote_as=n.get('as', NOT_SET), state_brief=get_bgp_state_brief( state=n.get('state', NOT_SET)), session_state=n.get('state', NOT_SET), state_time=n.get('up-time', NOT_SET), prefix_received=n.get( 'prefixes-received', 0), options=options)) elif isinstance( v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary'), dict): bgp_sessions_lst.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary').get('id', NOT_SET), peer_hostname=NOT_SET, remote_as=v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary').get('as', NOT_SET), state_brief=get_bgp_state_brief( state=v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary').get( 'state', NOT_SET)), session_state=v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary').get('state', NOT_SET), state_time=v.get('bgp-neighbor-summaries').get( 'bgp-neighbor-summary').get( 'up-time', NOT_SET), prefix_received=v.get('bgp-neighbor-summaries'). get('bgp-neighbor-summary').get( 'prefixes-received', 0), options=options)) bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF( vrf_name=v.get('vrf-name'), as_number=v.get('local-as'), router_id=v.get('router-id'), bgp_sessions=bgp_sessions_lst, )) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL1): printline() print(f'>>>>> {hostname}') PP.pprint(bgp.to_json()) return bgp
def _nxos_bgp_ssh_converter(hostname: str, cmd_output, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): if not isinstance(v, dict): v = json.loads(v) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL3): printline() PP.pprint(v) bgp_sessions_lst = ListBGPSessions(list()) if ('TABLE_vrf' in v.keys() and 'ROW_vrf' in v.get('TABLE_vrf').keys() and 'TABLE_neighbor' in v.get('TABLE_vrf').get('ROW_vrf').keys() and 'ROW_neighbor' in v.get('TABLE_vrf').get('ROW_vrf').get( 'TABLE_neighbor').keys()): if isinstance( v.get("TABLE_vrf").get("ROW_vrf").get( "TABLE_neighbor").get("ROW_neighbor", NOT_SET), list, ): for n in v.get("TABLE_vrf", NOT_SET) \ .get("ROW_vrf", NOT_SET) \ .get("TABLE_neighbor", NOT_SET) \ .get("ROW_neighbor", NOT_SET): bgp_sessions_lst.bgp_sessions.append( BGPSession(src_hostname=hostname, peer_ip=n.get("neighbor-id", NOT_SET), peer_hostname=n.get("interfaces", NOT_SET), remote_as=n.get("remoteas", NOT_SET), state_brief=get_bgp_state_brief( n.get("state", NOT_SET)), session_state=n.get("state", NOT_SET), state_time=n.get("LastUpDn", NOT_SET), prefix_received=n.get( "prefixReceived", NOT_SET), options=options)) elif isinstance( v.get("TABLE_vrf", NOT_SET).get("ROW_vrf", NOT_SET).get( "TABLE_neighbor", NOT_SET).get("ROW_neighbor", NOT_SET), dict, ): bgp_sessions_lst.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("neighbor-id", NOT_SET), peer_hostname=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("interfaces", NOT_SET), remote_as=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("remoteas", NOT_SET), state_brief=get_bgp_state_brief(state=v.get( "TABLE_vrf", NOT_SET).get("ROW_vrf", NOT_SET).get( "TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get( "state", NOT_SET)), session_state=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("state", NOT_SET), state_time=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("LastUpDn", NOT_SET), prefix_received=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("TABLE_neighbor", NOT_SET).get( "ROW_neighbor", NOT_SET).get("prefixReceived", NOT_SET), options=options)) bgp_sessions_vrf_lst.bgp_sessions_vrf.append( BGPSessionsVRF(vrf_name=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("vrf-name-out", NOT_SET), as_number=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("local-as", NOT_SET), router_id=v.get("TABLE_vrf", NOT_SET).get( "ROW_vrf", NOT_SET).get("router-id", NOT_SET), bgp_sessions=bgp_sessions_lst)) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL1): printline() print(f">>>>> {hostname}") PP.pprint(bgp.to_json()) return bgp
def _nxos_bgp_api_converter(hostname: str, cmd_output, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): if not isinstance(v, dict): v = json.loads(v) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL3): printline() PP.pprint(v) if ('ins_api' in v.keys() and 'outputs' in v.get('ins_api').keys() and 'output' in v.get('ins_api').get('outputs').keys() and 'body' in v.get('ins_api').get('outputs').get('output').keys() and v.get('ins_api').get('outputs').get('output').get('code') == '200'): bgp_vrf = BGPSessionsVRF( vrf_name=v.get('ins_api').get('outputs').get('output').get( 'body').get('TABLE_vrf').get('ROW_vrf').get( 'vrf-name-out', NOT_SET), as_number=v.get('ins_api').get('outputs').get('output').get( 'body').get('TABLE_vrf').get('ROW_vrf').get( 'local-as', NOT_SET), router_id=v.get('ins_api').get('outputs').get('output').get( 'body').get('TABLE_vrf').get('ROW_vrf').get( 'router-id', NOT_SET), bgp_sessions=ListBGPSessions(bgp_sessions=list())) if isinstance( v.get('ins_api').get('outputs').get('output').get( 'body').get('TABLE_vrf').get('ROW_vrf').get( 'TABLE_neighbor').get('ROW_neighbor'), dict): bgp_vrf.bgp_sessions.bgp_sessions.append( BGPSession( src_hostname=hostname, peer_ip=v.get('ins_api').get('outputs').get( 'output').get('body').get('TABLE_vrf').get( 'ROW_vrf').get('TABLE_neighbor').get( 'ROW_neighbor').get('neighbor-id'), peer_hostname=NOT_SET, remote_as=v.get('ins_api').get('outputs').get( 'output').get('body').get('TABLE_vrf').get( 'ROW_vrf').get('TABLE_neighbor').get( 'ROW_neighbor').get('remoteas'), state_brief=get_bgp_state_brief( state=v.get('ins_api').get('outputs').get( 'output').get('body').get('TABLE_vrf').get( 'ROW_vrf').get('TABLE_neighbor').get( 'ROW_neighbor').get('state')), session_state=v.get('ins_api').get('outputs').get( 'output').get('body').get('TABLE_vrf').get( 'ROW_vrf').get('TABLE_neighbor').get( 'ROW_neighbor').get('state'), state_time=v.get('ins_api').get('outputs').get( 'output').get('body').get('TABLE_vrf').get( 'ROW_vrf').get('TABLE_neighbor').get( 'ROW_neighbor').get('lastflap'), prefix_received=NOT_SET, options=options)) elif isinstance( v.get('ins_api').get('outputs').get('output').get( 'body').get('TABLE_vrf').get('ROW_vrf').get( 'TABLE_neighbor').get('ROW_neighbor'), list): for n in v.get('ins_api') \ .get('outputs') \ .get('output') \ .get('body') \ .get('TABLE_vrf') \ .get('ROW_vrf') \ .get('TABLE_neighbor') \ .get('ROW_neighbor'): bgp_vrf.bgp_sessions.bgp_sessions.append( BGPSession(src_hostname=hostname, peer_ip=n.get('neighbor-id'), peer_hostname=NOT_SET, remote_as=n.get('remoteas'), state_brief=get_bgp_state_brief( state=n.get('state')), session_state=n.get('state'), state_time=n.get('lastflap'), prefix_received=NOT_SET, options=options)) bgp_sessions_vrf_lst.bgp_sessions_vrf.append(bgp_vrf) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get("NETESTS_VERBOSE", NOT_SET), needed_value=LEVEL1): printline() print(f">>>>> {hostname}") PP.pprint(bgp.to_json()) return bgp
def _juniper_bgp_ssh_converter(hostname: str, cmd_output: dict, options={}) -> BGP: bgp_sessions_vrf_lst = ListBGPSessionsVRF(list()) for k, v in cmd_output.items(): if not isinstance(v.get('bgp'), dict): v['bgp'] = json.loads(v.get('bgp')) if not isinstance(v.get('rid'), dict): v['rid'] = json.loads(v.get('rid')) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL3): printline() PP.pprint(v) bgp_sessions_lst = ListBGPSessions(list()) local_as = '' if ('bgp' in v.keys() and 'bgp-peer' in v.get('bgp').get('bgp-information')[0].keys()): for bgp_peer in v.get('bgp') \ .get('bgp-information')[0] \ .get('bgp-peer'): local_as = bgp_peer.get('local-as')[0] \ .get('data', NOT_SET) if 'bgp-rib' in bgp_peer.keys(): prefix_rcv = bgp_peer.get('bgp-rib')[0] \ .get('received-prefix-count')[0] \ .get('data', NOT_SET) else: prefix_rcv = NOT_SET bgp_session = BGPSession( src_hostname=hostname, peer_ip=_juniper_bgp_addr_filter( bgp_peer.get('peer-address')[0].get('data', NOT_SET)), peer_hostname=NOT_SET, remote_as=bgp_peer.get('peer-as')[0].get('data', NOT_SET), state_brief=get_bgp_state_brief( bgp_peer.get('peer-state')[0].get('data', NOT_SET), ), session_state=(bgp_peer.get('peer-state')[0].get( 'data', NOT_SET)), state_time=NOT_SET, prefix_received=prefix_rcv, ) bgp_sessions_lst.bgp_sessions.append(bgp_session) router_id = NOT_SET if ('rid' in v.keys() and 'instance-information' in v.get('rid').keys()): router_id = v.get('rid') \ .get('instance-information')[0] \ .get('instance-core')[0] \ .get('router-id')[0] \ .get('data', NOT_SET) bgp_session_vrf = BGPSessionsVRF( vrf_name=k, as_number=local_as, router_id=router_id, bgp_sessions=bgp_sessions_lst, ) bgp_sessions_vrf_lst.bgp_sessions_vrf.append(bgp_session_vrf) bgp = BGP(hostname=hostname, bgp_sessions_vrf_lst=bgp_sessions_vrf_lst) if verbose_mode(user_value=os.environ.get('NETESTS_VERBOSE', NOT_SET), needed_value=LEVEL1): printline() print(f'>>>>> {hostname}') PP.pprint(bgp.to_json()) return bgp