Skip to content

Commit

Permalink
tools: fix style check babletrace file
Browse files Browse the repository at this point in the history
python3 -m black tools/frr_babeltrace.py

Signed-off-by: Chirag Shah <[email protected]>
  • Loading branch information
chiragshah6 committed Nov 25, 2024
1 parent 91119da commit 814a89f
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions tools/frr_babeltrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import babeltrace


########################### common parsers - start ############################
def print_ip_addr(field_val):
"""
Expand Down Expand Up @@ -48,24 +49,28 @@ def print_mac(field_val):
"""
return ":".join("%02x" % fb for fb in field_val)


def print_net_ipv4_addr(field_val):
"""
pretty print ctf_integer_network ipv4
"""
return str(ipaddress.IPv4Address(field_val))


def print_esi(field_val):
"""
pretty print ethernet segment id, esi_t
"""
return ":".join("%02x" % fb for fb in field_val)


def get_field_list(event):
"""
only fetch fields added via the TP, skip metadata etc.
"""
return event.field_list_with_scope(babeltrace.CTFScope.EVENT_FIELDS)


def parse_event(event, field_parsers):
"""
Wild card event parser; doesn't make things any prettier
Expand Down Expand Up @@ -103,6 +108,7 @@ def print_family_str(field_val):

############################ common parsers - end #############################


############################ evpn parsers - start #############################
def parse_frr_bgp_evpn_mac_ip_zsend(event):
"""
Expand All @@ -114,13 +120,16 @@ def parse_frr_bgp_evpn_mac_ip_zsend(event):
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
"""
field_parsers = {"ip": print_ip_addr,
"mac": print_mac,
"esi": print_esi,
"vtep": print_net_ipv4_addr}
field_parsers = {
"ip": print_ip_addr,
"mac": print_mac,
"esi": print_esi,
"vtep": print_net_ipv4_addr,
}

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_bum_vtep_zsend(event):
"""
bgp evpn bum-vtep parser; raw format -
Expand All @@ -132,6 +141,7 @@ def parse_frr_bgp_evpn_bum_vtep_zsend(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_nh_rmac_send(event):
"""
bgp evpn nh-rmac parser; raw format -
Expand All @@ -141,17 +151,18 @@ def parse_frr_bgp_evpn_mh_nh_rmac_send(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_es_add_zrecv(event):
"""
bgp evpn local-es parser; raw format -
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
"""
field_parsers = {"esi": print_esi,
"vtep": print_net_ipv4_addr}
field_parsers = {"esi": print_esi, "vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_es_del_zrecv(event):
"""
bgp evpn local-es parser; raw format -
Expand All @@ -161,6 +172,7 @@ def parse_frr_bgp_evpn_mh_local_es_del_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv(event):
"""
bgp evpn local-es-evi parser; raw format -
Expand All @@ -170,6 +182,7 @@ def parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv(event):
"""
bgp evpn local-es-evi parser; raw format -
Expand All @@ -179,6 +192,7 @@ def parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_es_evi_vtep_add(event):
"""
bgp evpn remote ead evi remote vtep add; raw format -
Expand All @@ -189,6 +203,7 @@ def parse_frr_bgp_evpn_mh_es_evi_vtep_add(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_es_evi_vtep_del(event):
"""
bgp evpn remote ead evi remote vtep del; raw format -
Expand All @@ -199,6 +214,7 @@ def parse_frr_bgp_evpn_mh_es_evi_vtep_del(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_upd(event):
"""
bgp evpn local ead evi vtep; raw format -
Expand All @@ -209,6 +225,7 @@ def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_upd(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_del(event):
"""
bgp evpn local ead evi vtep del; raw format -
Expand All @@ -219,6 +236,7 @@ def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_del(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_local_vni_add_zrecv(event):
"""
bgp evpn local-vni parser; raw format -
Expand All @@ -230,19 +248,23 @@ def parse_frr_bgp_evpn_local_vni_add_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_local_l3vni_add_zrecv(event):
"""
bgp evpn local-l3vni parser; raw format -
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
ctf_array(unsigned char, svi_rmac, svi_rmac, sizeof(struct ethaddr))
ctf_array(unsigned char, vrr_rmac, vrr_rmac, sizeof(struct ethaddr))
"""
field_parsers = {"vtep": print_net_ipv4_addr,
"svi_rmac": print_mac,
"vrr_rmac": print_mac}
field_parsers = {
"vtep": print_net_ipv4_addr,
"svi_rmac": print_mac,
"vrr_rmac": print_mac,
}

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_local_macip_add_zrecv(event):
"""
bgp evpn local-mac-ip parser; raw format -
Expand All @@ -256,6 +278,7 @@ def parse_frr_bgp_evpn_local_macip_add_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_local_macip_del_zrecv(event):
"""
bgp evpn local-mac-ip del parser; raw format -
Expand All @@ -267,16 +290,20 @@ def parse_frr_bgp_evpn_local_macip_del_zrecv(event):

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_advertise_type5(event):
"""
local originated type-5 route
"""
field_parsers = {"ip": print_ip_addr,
"rmac": print_mac,
"vtep": print_net_ipv4_addr}
field_parsers = {
"ip": print_ip_addr,
"rmac": print_mac,
"vtep": print_net_ipv4_addr,
}

parse_event(event, field_parsers)


def parse_frr_bgp_evpn_withdraw_type5(event):
"""
local originated type-5 route withdraw
Expand All @@ -285,8 +312,10 @@ def parse_frr_bgp_evpn_withdraw_type5(event):

parse_event(event, field_parsers)


############################ evpn parsers - end *#############################


def main():
"""
FRR lttng trace output parser; babel trace plugin
Expand Down Expand Up @@ -341,5 +370,6 @@ def main():
else:
parse_event(event, {})


if __name__ == "__main__":
main()

0 comments on commit 814a89f

Please sign in to comment.