- parser = argparse.ArgumentParser()
- parser.add_argument("-j", "--json_data",
- required=True,
- type=str,
- help="JSON string (list) containing API name(s) and "
- "its/their input argument(s).")
- parser.add_argument("-d", "--json_dir",
- type=str,
- default='/usr/share/vpp/api/',
- help="Directory containing all vpp json api files.")
- args = parser.parse_args()
- json_string = args.json_data
- vpp_json_dir = args.json_dir
-
- vpp = papi_init(vpp_json_dir=vpp_json_dir)
+ # The functions which process different types of VPP Python API methods.
+ process_request = dict(
+ request=process_json_request,
+ dump=process_json_request,
+ stats=process_stats,
+ stats_request=process_stats_request
+ )
+
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description=__doc__
+ )
+ parser.add_argument(
+ u"-m", u"--method", required=True,
+ choices=[str(key) for key in process_request.keys()],
+ help=u"Specifies the VPP API methods: "
+ u"1. request - simple request / reply; "
+ u"2. dump - dump function;"
+ u"3. stats - VPP statistics."
+ )
+ parser.add_argument(
+ u"-d", u"--data", required=True,
+ help=u"If the method is 'request' or 'dump', data is a JSON string "
+ u"(list) containing API name(s) and its/their input argument(s). "
+ u"If the method is 'stats', data is a JSON string containing t"
+ u"he list of path(s) to the required data."
+ )
+ parser.add_argument(
+ u"-s", u"--socket", default=u"/var/run/vpp/stats.sock",
+ help=u"A file descriptor over the VPP stats Unix domain socket. "
+ u"It is used only if method=='stats'."
+ )