aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/rpc_server.py
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-01-04 16:29:15 -0800
committerMartin Braun <martin.braun@ettus.com>2018-01-08 11:48:25 -0800
commit121c37751c49adb4389396cf2692af337030b2ec (patch)
tree7e6aadaf2f09c4d714519e46f6ada631c253dbc5 /mpm/python/usrp_mpm/rpc_server.py
parentacd1f6d91e7cb0c2d3dd76581ec8ee4b7acd9a4b (diff)
downloaduhd-121c37751c49adb4389396cf2692af337030b2ec.tar.gz
uhd-121c37751c49adb4389396cf2692af337030b2ec.tar.bz2
uhd-121c37751c49adb4389396cf2692af337030b2ec.zip
mpm: Add API to read back log buffer
Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
Diffstat (limited to 'mpm/python/usrp_mpm/rpc_server.py')
-rw-r--r--mpm/python/usrp_mpm/rpc_server.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py
index cf3f4a21b..076103aa9 100644
--- a/mpm/python/usrp_mpm/rpc_server.py
+++ b/mpm/python/usrp_mpm/rpc_server.py
@@ -21,6 +21,7 @@ from gevent import monkey
monkey.patch_all()
from builtins import str, bytes
from builtins import range
+from six import iteritems
from mprpc import RPCServer
from usrp_mpm.mpmlog import get_main_logger
from usrp_mpm.mpmutils import to_binary_str
@@ -46,7 +47,7 @@ class MPMServer(RPCServer):
# This is a list of methods in this class which require a claim
default_claimed_methods = ['init', 'update_component', 'reclaim', 'unclaim']
# Compatibility number for MPM
- MPM_COMPAT_NUM = (1, 0)
+ MPM_COMPAT_NUM = (1, 1)
def __init__(self, state, mgr, mgr_generator=None, *args, **kwargs):
self.log = get_main_logger().getChild('RPCServer')
@@ -411,6 +412,26 @@ class MPMServer(RPCServer):
"""
return self._last_error
+ def get_log_buf(self, token):
+ """
+ Return the contents of the log buffer as a list of str -> str
+ dictionaries.
+ """
+ if not self._check_token_valid(token):
+ self.log.warning(
+ "Attempt to read logs without valid claim from {}".format(
+ self.client_host
+ )
+ )
+ err_msg = "get_log_buf() called without valid claim."
+ self._last_error = err_msg
+ raise RuntimeError(err_msg)
+ log_records = get_main_logger().get_log_buf()
+ self.log.trace("Returning %d log records.", len(log_records))
+ return [
+ {k: str(v) for k, v in iteritems(record)}
+ for record in log_records
+ ]
def _rpc_server_process(shared_state, port, mgr, mgr_generator):