diff --git a/tests/common/helpers/pfc_gen.py b/tests/common/helpers/pfc_gen.py index cfcd03b36bd..f269df5b5cc 100755 --- a/tests/common/helpers/pfc_gen.py +++ b/tests/common/helpers/pfc_gen.py @@ -44,12 +44,12 @@ def main(): (options, args) = parser.parse_args() if options.interface is None: - print "Need to specify the interface to send PFC/global pause frame packets." + print("Need to specify the interface to send PFC/global pause frame packets.") parser.print_help() sys.exit(1) if options.time > 65535 or options.time < 0: - print "Quanta is not valid. Need to be in range 0-65535." + print("Quanta is not valid. Need to be in range 0-65535.") parser.print_help() sys.exit(1) @@ -57,11 +57,11 @@ def main(): # Send global pause frames # -p option should not be set if options.priority != -1: - print "'-p' option is not valid when sending global pause frames ('--global' / '-g')" + print("'-p' option is not valid when sending global pause frames ('--global' / '-g')") parser.print_help() sys.exit(1) elif options.priority > 255 or options.priority < 0: - print "Enable class bitmap is not valid. Need to be in range 0-255." + print("Enable class bitmap is not valid. Need to be in range 0-255.") parser.print_help() sys.exit(1) @@ -72,7 +72,7 @@ def main(): for i in range(0, len(interfaces)): sockets.append(socket(AF_PACKET, SOCK_RAW)) except: - print "Unable to create socket. Check your permissions" + print("Unable to create socket. Check your permissions") sys.exit(1) # Configure logging @@ -122,13 +122,13 @@ def main(): pause time | 0x0000 | ------------------------- """ - src_addr = "\x00\x01\x02\x03\x04\x05" - dst_addr = "\x01\x80\xc2\x00\x00\x01" + src_addr = b"\x00\x01\x02\x03\x04\x05" + dst_addr = b"\x01\x80\xc2\x00\x00\x01" if options.global_pf: - opcode = "\x00\x01" + opcode = b"\x00\x01" else: - opcode = "\x01\x01" - ethertype = "\x88\x08" + opcode = b"\x01\x01" + ethertype = b"\x88\x08" packet = dst_addr + src_addr + ethertype + opcode if options.global_pf: @@ -142,10 +142,10 @@ def main(): if (class_enable & (1<
0: diff --git a/tests/common/templates/pfc_storm_sonic.j2 b/tests/common/templates/pfc_storm_sonic.j2 index cf523ba4e43..a626c77fe6b 100644 --- a/tests/common/templates/pfc_storm_sonic.j2 +++ b/tests/common/templates/pfc_storm_sonic.j2 @@ -1,6 +1,6 @@ cd {{pfc_gen_dir}} {% if (pfc_asym is defined) and (pfc_asym == True) %} -nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}" > /dev/null 2>&1 & +nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} sudo python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}" > /dev/null 2>&1 & {% else %} -nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}" > /dev/null 2>&1 & +nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} sudo python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}" > /dev/null 2>&1 & {% endif %} diff --git a/tests/common/templates/pfc_storm_stop_sonic.j2 b/tests/common/templates/pfc_storm_stop_sonic.j2 index 4208e15dc88..43c4dc5f99d 100644 --- a/tests/common/templates/pfc_storm_stop_sonic.j2 +++ b/tests/common/templates/pfc_storm_stop_sonic.j2 @@ -1,6 +1,6 @@ cd {{pfc_gen_dir}} {% if (pfc_asym is defined) and (pfc_asym == True) %} -nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} pkill -f 'python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}'" > /dev/null 2>&1 & +nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} sudo pkill -f 'python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}'" > /dev/null 2>&1 & {% else %} -nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} pkill -f 'python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}'" > /dev/null 2>&1 & +nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} sudo pkill -f 'python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}'" > /dev/null 2>&1 & {% endif %}