示例#1
0
def process_stats(args):
    """Process the VPP Stats.

    The reply contains single item covering all paths.

    :param args: Command line arguments passed to VPP PAPI Provider.
    :type args: ArgumentParser
    :returns: JSON formatted string.
    :rtype: str
    :raises RuntimeError: If PAPI command error occurs.
    """

    try:
        stats = VPPStats(args.socket)
    except Exception as err:
        raise RuntimeError(f"PAPI init failed:\n{err!r}")

    paths = json.loads(args.data)
    directory = stats.ls(paths)
    reply = [stats.dump(directory)]

    try:
        return json.dumps(reply)
    except UnicodeDecodeError as err:
        raise RuntimeError(f"PAPI reply {reply} error:\n{err!r}")
示例#2
0
def process_stats(args):
    """Process the VPP Stats.

    :param args: Command line arguments passed to VPP PAPI Provider.
    :type args: ArgumentParser
    :returns: JSON formatted string.
    :rtype: str
    :raises RuntimeError: If PAPI command error occurs.
    """

    try:
        stats = VPPStats(args.socket)
    except Exception as err:
        raise RuntimeError(f"PAPI init failed:\n{err!r}")

    json_data = json.loads(args.data)

    reply = list()

    for path in json_data:
        directory = stats.ls(path)
        data = stats.dump(directory)
        reply.append(data)

    try:
        return json.dumps(reply)
    except UnicodeDecodeError as err:
        raise RuntimeError(f"PAPI reply {reply} error:\n{err!r}")