mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 12:49:18 +00:00
tools: upstream linter is recommending double quotes
Replaced single quotes with double quotes for strings in the frr_babeltrace.py utility. Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
This commit is contained in:
parent
b9c3be8be2
commit
32dcd36d29
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
'''
|
"""
|
||||||
Usage: frr_babeltrace.py trace_path
|
Usage: frr_babeltrace.py trace_path
|
||||||
|
|
||||||
FRR pushes data into lttng tracepoints in the least overhead way possible
|
FRR pushes data into lttng tracepoints in the least overhead way possible
|
||||||
@ -23,7 +23,7 @@ more details.
|
|||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along
|
||||||
with this program; see the file COPYING; if not, write to the Free Software
|
with this program; see the file COPYING; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
'''
|
"""
|
||||||
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import socket
|
import socket
|
||||||
@ -33,56 +33,56 @@ import babeltrace
|
|||||||
|
|
||||||
########################### common parsers - start ############################
|
########################### common parsers - start ############################
|
||||||
def print_ip_addr(field_val):
|
def print_ip_addr(field_val):
|
||||||
'''
|
"""
|
||||||
pretty print "struct ipaddr"
|
pretty print "struct ipaddr"
|
||||||
'''
|
"""
|
||||||
if field_val[0] == socket.AF_INET:
|
if field_val[0] == socket.AF_INET:
|
||||||
addr = [str(fv) for fv in field_val[4:8]]
|
addr = [str(fv) for fv in field_val[4:8]]
|
||||||
return str(ipaddress.IPv4Address('.'.join(addr)))
|
return str(ipaddress.IPv4Address(".".join(addr)))
|
||||||
|
|
||||||
if field_val[0] == socket.AF_INET6:
|
if field_val[0] == socket.AF_INET6:
|
||||||
tmp = ''.join('%02x' % fb for fb in field_val[4:])
|
tmp = "".join("%02x" % fb for fb in field_val[4:])
|
||||||
addr = []
|
addr = []
|
||||||
while tmp:
|
while tmp:
|
||||||
addr.append(tmp[:4])
|
addr.append(tmp[:4])
|
||||||
tmp = tmp[4:]
|
tmp = tmp[4:]
|
||||||
addr = ':'.join(addr)
|
addr = ":".join(addr)
|
||||||
return str(ipaddress.IPv6Address(addr))
|
return str(ipaddress.IPv6Address(addr))
|
||||||
|
|
||||||
if not field_val[0]:
|
if not field_val[0]:
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
return field_val
|
return field_val
|
||||||
|
|
||||||
|
|
||||||
def print_mac(field_val):
|
def print_mac(field_val):
|
||||||
'''
|
"""
|
||||||
pretty print "u8 mac[6]"
|
pretty print "u8 mac[6]"
|
||||||
'''
|
"""
|
||||||
return ':'.join('%02x' % fb for fb in field_val)
|
return ":".join("%02x" % fb for fb in field_val)
|
||||||
|
|
||||||
def print_net_ipv4_addr(field_val):
|
def print_net_ipv4_addr(field_val):
|
||||||
'''
|
"""
|
||||||
pretty print ctf_integer_network ipv4
|
pretty print ctf_integer_network ipv4
|
||||||
'''
|
"""
|
||||||
return str(ipaddress.IPv4Address(field_val))
|
return str(ipaddress.IPv4Address(field_val))
|
||||||
|
|
||||||
def print_esi(field_val):
|
def print_esi(field_val):
|
||||||
'''
|
"""
|
||||||
pretty print ethernet segment id, esi_t
|
pretty print ethernet segment id, esi_t
|
||||||
'''
|
"""
|
||||||
return ':'.join('%02x' % fb for fb in field_val)
|
return ":".join("%02x" % fb for fb in field_val)
|
||||||
|
|
||||||
def get_field_list(event):
|
def get_field_list(event):
|
||||||
'''
|
"""
|
||||||
only fetch fields added via the TP, skip metadata etc.
|
only fetch fields added via the TP, skip metadata etc.
|
||||||
'''
|
"""
|
||||||
return event.field_list_with_scope(babeltrace.CTFScope.EVENT_FIELDS)
|
return event.field_list_with_scope(babeltrace.CTFScope.EVENT_FIELDS)
|
||||||
|
|
||||||
def parse_event(event, field_parsers):
|
def parse_event(event, field_parsers):
|
||||||
'''
|
"""
|
||||||
Wild card event parser; doesn't make things any prettier
|
Wild card event parser; doesn't make things any prettier
|
||||||
'''
|
"""
|
||||||
field_list = get_field_list(event)
|
field_list = get_field_list(event)
|
||||||
field_info = {}
|
field_info = {}
|
||||||
for field in field_list:
|
for field in field_list:
|
||||||
@ -96,7 +96,7 @@ def parse_event(event, field_parsers):
|
|||||||
|
|
||||||
############################ evpn parsers - start #############################
|
############################ evpn parsers - start #############################
|
||||||
def parse_frr_bgp_evpn_mac_ip_zsend(event):
|
def parse_frr_bgp_evpn_mac_ip_zsend(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn mac-ip parser; raw format -
|
bgp evpn mac-ip parser; raw format -
|
||||||
ctf_array(unsigned char, mac, &pfx->prefix.macip_addr.mac,
|
ctf_array(unsigned char, mac, &pfx->prefix.macip_addr.mac,
|
||||||
sizeof(struct ethaddr))
|
sizeof(struct ethaddr))
|
||||||
@ -104,147 +104,147 @@ def parse_frr_bgp_evpn_mac_ip_zsend(event):
|
|||||||
sizeof(struct ipaddr))
|
sizeof(struct ipaddr))
|
||||||
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'ip': print_ip_addr,
|
field_parsers = {"ip": print_ip_addr,
|
||||||
'mac': print_mac,
|
"mac": print_mac,
|
||||||
'esi': print_esi,
|
"esi": print_esi,
|
||||||
'vtep': print_net_ipv4_addr}
|
"vtep": print_net_ipv4_addr}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_bum_vtep_zsend(event):
|
def parse_frr_bgp_evpn_bum_vtep_zsend(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn bum-vtep parser; raw format -
|
bgp evpn bum-vtep parser; raw format -
|
||||||
ctf_integer_network_hex(unsigned int, vtep,
|
ctf_integer_network_hex(unsigned int, vtep,
|
||||||
pfx->prefix.imet_addr.ip.ipaddr_v4.s_addr)
|
pfx->prefix.imet_addr.ip.ipaddr_v4.s_addr)
|
||||||
|
|
||||||
'''
|
"""
|
||||||
field_parsers = {'vtep': print_net_ipv4_addr}
|
field_parsers = {"vtep": print_net_ipv4_addr}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_mh_nh_rmac_send(event):
|
def parse_frr_bgp_evpn_mh_nh_rmac_send(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn nh-rmac parser; raw format -
|
bgp evpn nh-rmac parser; raw format -
|
||||||
ctf_array(unsigned char, rmac, &nh->rmac, sizeof(struct ethaddr))
|
ctf_array(unsigned char, rmac, &nh->rmac, sizeof(struct ethaddr))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'rmac': print_mac}
|
field_parsers = {"rmac": print_mac}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_mh_local_es_add_zrecv(event):
|
def parse_frr_bgp_evpn_mh_local_es_add_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-es parser; raw format -
|
bgp evpn local-es parser; raw format -
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
||||||
'''
|
"""
|
||||||
field_parsers = {'esi': print_esi,
|
field_parsers = {"esi": print_esi,
|
||||||
'vtep': print_net_ipv4_addr}
|
"vtep": print_net_ipv4_addr}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_mh_local_es_del_zrecv(event):
|
def parse_frr_bgp_evpn_mh_local_es_del_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-es parser; raw format -
|
bgp evpn local-es parser; raw format -
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'esi': print_esi}
|
field_parsers = {"esi": print_esi}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv(event):
|
def parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-es-evi parser; raw format -
|
bgp evpn local-es-evi parser; raw format -
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'esi': print_esi}
|
field_parsers = {"esi": print_esi}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv(event):
|
def parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-es-evi parser; raw format -
|
bgp evpn local-es-evi parser; raw format -
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'esi': print_esi}
|
field_parsers = {"esi": print_esi}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_local_vni_add_zrecv(event):
|
def parse_frr_bgp_evpn_local_vni_add_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-vni parser; raw format -
|
bgp evpn local-vni parser; raw format -
|
||||||
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
||||||
ctf_integer_network_hex(unsigned int, mc_grp, mc_grp.s_addr)
|
ctf_integer_network_hex(unsigned int, mc_grp, mc_grp.s_addr)
|
||||||
'''
|
"""
|
||||||
field_parsers = {'vtep': print_net_ipv4_addr,
|
field_parsers = {"vtep": print_net_ipv4_addr,
|
||||||
'mc_grp': print_net_ipv4_addr}
|
"mc_grp": print_net_ipv4_addr}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_local_l3vni_add_zrecv(event):
|
def parse_frr_bgp_evpn_local_l3vni_add_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-l3vni parser; raw format -
|
bgp evpn local-l3vni parser; raw format -
|
||||||
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
|
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, svi_rmac, svi_rmac, sizeof(struct ethaddr))
|
||||||
ctf_array(unsigned char, vrr_rmac, vrr_rmac, sizeof(struct ethaddr))
|
ctf_array(unsigned char, vrr_rmac, vrr_rmac, sizeof(struct ethaddr))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'vtep': print_net_ipv4_addr,
|
field_parsers = {"vtep": print_net_ipv4_addr,
|
||||||
'svi_rmac': print_mac,
|
"svi_rmac": print_mac,
|
||||||
'vrr_rmac': print_mac}
|
"vrr_rmac": print_mac}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_local_macip_add_zrecv(event):
|
def parse_frr_bgp_evpn_local_macip_add_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-mac-ip parser; raw format -
|
bgp evpn local-mac-ip parser; raw format -
|
||||||
ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
|
ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
|
||||||
ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
|
ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
|
||||||
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'ip': print_ip_addr,
|
field_parsers = {"ip": print_ip_addr,
|
||||||
'mac': print_mac,
|
"mac": print_mac,
|
||||||
'esi': print_esi}
|
"esi": print_esi}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
def parse_frr_bgp_evpn_local_macip_del_zrecv(event):
|
def parse_frr_bgp_evpn_local_macip_del_zrecv(event):
|
||||||
'''
|
"""
|
||||||
bgp evpn local-mac-ip del parser; raw format -
|
bgp evpn local-mac-ip del parser; raw format -
|
||||||
ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
|
ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
|
||||||
ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
|
ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
|
||||||
'''
|
"""
|
||||||
field_parsers = {'ip': print_ip_addr,
|
field_parsers = {"ip": print_ip_addr,
|
||||||
'mac': print_mac}
|
"mac": print_mac}
|
||||||
|
|
||||||
parse_event(event, field_parsers)
|
parse_event(event, field_parsers)
|
||||||
|
|
||||||
############################ evpn parsers - end *#############################
|
############################ evpn parsers - end *#############################
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
'''
|
"""
|
||||||
FRR lttng trace output parser; babel trace plugin
|
FRR lttng trace output parser; babel trace plugin
|
||||||
'''
|
"""
|
||||||
event_parsers = {'frr_bgp:evpn_mac_ip_zsend':
|
event_parsers = {"frr_bgp:evpn_mac_ip_zsend":
|
||||||
parse_frr_bgp_evpn_mac_ip_zsend,
|
parse_frr_bgp_evpn_mac_ip_zsend,
|
||||||
'frr_bgp:evpn_bum_vtep_zsend':
|
"frr_bgp:evpn_bum_vtep_zsend":
|
||||||
parse_frr_bgp_evpn_bum_vtep_zsend,
|
parse_frr_bgp_evpn_bum_vtep_zsend,
|
||||||
'frr_bgp:evpn_mh_nh_rmac_zsend':
|
"frr_bgp:evpn_mh_nh_rmac_zsend":
|
||||||
parse_frr_bgp_evpn_mh_nh_rmac_send,
|
parse_frr_bgp_evpn_mh_nh_rmac_send,
|
||||||
'frr_bgp:evpn_mh_local_es_add_zrecv':
|
"frr_bgp:evpn_mh_local_es_add_zrecv":
|
||||||
parse_frr_bgp_evpn_mh_local_es_add_zrecv,
|
parse_frr_bgp_evpn_mh_local_es_add_zrecv,
|
||||||
'frr_bgp:evpn_mh_local_es_del_zrecv':
|
"frr_bgp:evpn_mh_local_es_del_zrecv":
|
||||||
parse_frr_bgp_evpn_mh_local_es_del_zrecv,
|
parse_frr_bgp_evpn_mh_local_es_del_zrecv,
|
||||||
'frr_bgp:evpn_mh_local_es_evi_add_zrecv':
|
"frr_bgp:evpn_mh_local_es_evi_add_zrecv":
|
||||||
parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv,
|
parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv,
|
||||||
'frr_bgp:evpn_mh_local_es_evi_del_zrecv':
|
"frr_bgp:evpn_mh_local_es_evi_del_zrecv":
|
||||||
parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv,
|
parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv,
|
||||||
'frr_bgp:evpn_local_vni_add_zrecv':
|
"frr_bgp:evpn_local_vni_add_zrecv":
|
||||||
parse_frr_bgp_evpn_local_vni_add_zrecv,
|
parse_frr_bgp_evpn_local_vni_add_zrecv,
|
||||||
'frr_bgp:evpn_local_l3vni_add_zrecv':
|
"frr_bgp:evpn_local_l3vni_add_zrecv":
|
||||||
parse_frr_bgp_evpn_local_l3vni_add_zrecv,
|
parse_frr_bgp_evpn_local_l3vni_add_zrecv,
|
||||||
'frr_bgp:evpn_local_macip_add_zrecv':
|
"frr_bgp:evpn_local_macip_add_zrecv":
|
||||||
parse_frr_bgp_evpn_local_macip_add_zrecv,
|
parse_frr_bgp_evpn_local_macip_add_zrecv,
|
||||||
'frr_bgp:evpn_local_macip_del_zrecv':
|
"frr_bgp:evpn_local_macip_del_zrecv":
|
||||||
parse_frr_bgp_evpn_local_macip_del_zrecv,
|
parse_frr_bgp_evpn_local_macip_del_zrecv,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ def main():
|
|||||||
|
|
||||||
# grab events
|
# grab events
|
||||||
trace_collection = babeltrace.TraceCollection()
|
trace_collection = babeltrace.TraceCollection()
|
||||||
trace_collection.add_traces_recursive(trace_path, 'ctf')
|
trace_collection.add_traces_recursive(trace_path, "ctf")
|
||||||
|
|
||||||
for event in trace_collection.events:
|
for event in trace_collection.events:
|
||||||
if event.name in event_parsers:
|
if event.name in event_parsers:
|
||||||
@ -262,5 +262,5 @@ def main():
|
|||||||
else:
|
else:
|
||||||
parse_event(event, {})
|
parse_event(event, {})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user