def makeThriftLink(self, qdepth, qrate): services = self.get_thrift_services(self.thriftPre) services.extend(self.ssget_thrift_services()) self.standard_client, self.mc_client, self.sswitch_client = utils.thrift_connect( self.thriftIp, self.thriftPort, services) # self.standard_client, self.mc_client = utils.thrift_connect( # self.thriftIp, self.thriftPort, self.get_thrift_services(self.thriftPre)) self.json_str = utils.get_json_config( self.standard_client, self.jsonPath) self.load_json_str() # self.sswitch_client.set_egress_queue_depth(port, qdepth) self.sswitch_client.set_all_egress_queue_depths(qdepth) self.sswitch_client.set_all_egress_queue_rates(qrate)
def configure_runtime_api(): sys.path.append('../bmv2/tools') from bm_runtime.simple_pre import SimplePre from bm_runtime.standard import Standard import bmpy_utils as utils from runtime_CLI import RuntimeAPI, load_json_config client, mc_client = utils.thrift_connect( "localhost", 22222, [("standard", Standard.Client), ("simple_pre", SimplePre.Client)]) load_json_config(client, None) return RuntimeAPI(SimplePre, client, mc_client)
def __init__(self, thrift_ip="127.0.0.1", thrift_port=9090, services=[('standard', Standard.Client), ('simple_pre', SimplePre.Client)]): self.client, mc_client = utils.thrift_connect(thrift_ip, thrift_port, services) self.level_epoch_data = {} self.ptr_reg_name = 'pointers' self.level_reg_name = 'level_pointer_idx' self.fch_reg_name = 'fch_reg' self.g_reg_name = 'g_reg' self.key_ipaddrs = {} self.init_fch() self.init_levels()
def thrift_connect(thrift_ip, thrift_port, services): return utils.thrift_connect(thrift_ip, thrift_port, services)
help='p4info proto in text format from p4c', type=str, action="store", required=False, default='./build/basic.p4.p4info.txt') parser.add_argument('--bmv2-json', help='BMv2 JSON file from p4c', type=str, action="store", required=False, default='./build/basic.json') args = parser.parse_args() if not os.path.exists(args.p4info): parser.print_help() print "\np4info file not found: %s\nHave you run 'make'?" % args.p4info parser.exit(1) if not os.path.exists(args.bmv2_json): parser.print_help() print "\nBMv2 JSON file not found: %s\nHave you run 'make'?" % args.bmv2_json parser.exit(1) standard_client, mc_client = utils.thrift_connect( args.thrift_ip, args.thrift_port, runtime_CLI.RuntimeAPI.get_thrift_services(args.pre)) runtime_CLI.load_json_config(standard_client, args.bmv2_json) runtimeAPI = runtime_CLI.RuntimeAPI(args.pre, standard_client, mc_client) main(args.p4info, args.bmv2_json, runtimeAPI)