1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: GPL-2.0 3 """ 4 tdc_multibatch.py - a thin wrapper over tdc_batch.py to generate multiple batch 5 files 6 7 Copyright (C) 2019 Vlad Buslov <vladbu@mellanox.com> 8 """ 9 10 import argparse 11 import os 12 13 parser = argparse.ArgumentParser( 14 description='TC multiple batch file generator') 15 parser.add_argument("device", help="device name") 16 parser.add_argument("dir", help="where to put batch files") 17 parser.add_argument( 18 "num_filters", type=int, help="how many lines per batch file") 19 parser.add_argument("num_files", type=int, help="how many batch files") 20 parser.add_argument( 21 "operation", 22 choices=['add', 'del', 'replace'], 23 help="operation to perform on filters") 24 parser.add_argument( 25 "-x", 26 "--file_prefix", 27 default="", 28 help="prefix for generated batch file names") 29 parser.add_argument( 30 "-d", 31 "--duplicate_handles", 32 action="store_true", 33 help="duplicate filter handle range in all files") 34 parser.add_argument( 35 "-a", 36 "--handle_start", 37 type=int, 38 default=1, 39 help="start handle range from (default: 1)") 40 parser.add_argument( 41 "-m", 42 "--mac_prefix", 43 type=int, 44 default=0, 45 choices=range(0, 256), 46 help="add this value to third byte of source MAC address of flower filter" 47 "(default: 0)") 48 args = parser.parse_args() 49 50 device = args.device 51 dir = args.dir 52 file_prefix = args.file_prefix + args.operation + "_" 53 num_filters = args.num_filters 54 num_files = args.num_files 55 operation = args.operation 56 duplicate_handles = args.duplicate_handles 57 handle = args.handle_start 58 mac_prefix = args.mac_prefix 59 60 for i in range(num_files): 61 file = dir + '/' + file_prefix + str(i) 62 os.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format( 63 num_filters, handle, operation, i + mac_prefix, device, file)) 64 if not duplicate_handles: 65 handle += num_filters
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.