diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-09 18:13:16 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:05 -0800 |
commit | fb5e10a8e4cff12182403dc6af6f5d8bf7a469c0 (patch) | |
tree | 577f33f991f8c2c260cd07b3b3274372d58c1f2a /mpm | |
parent | db121800e7fb6f467db74f7776222fab0a0ab50f (diff) | |
download | uhd-fb5e10a8e4cff12182403dc6af6f5d8bf7a469c0.tar.gz uhd-fb5e10a8e4cff12182403dc6af6f5d8bf7a469c0.tar.bz2 uhd-fb5e10a8e4cff12182403dc6af6f5d8bf7a469c0.zip |
mpm: Cache connection type in PeriphManagerBase
Now, when claiming a device, the connection type will be stored as a
string in PeriphManagerBase. This way we can read out the current
connection type even when not currently inside an RPC call.
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 13 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/rpc_server.py | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 3f456fc96..100a8852a 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -394,6 +394,19 @@ class PeriphManagerBase(object): result.update(self.mboard_info) return result + @no_rpc + def set_connection_type(self, conn_type): + """ + Specify how the RPC client has connected to this MPM instance. Valid + values are "remote", "local", or None. When None is given, the value + is reset. + """ + assert conn_type in ('remote', 'local', None) + if conn_type is None: + self.mboard_info.pop('rpc_connection', None) + else: + self.mboard_info['rpc_connection'] = conn_type + @no_claim def get_dboard_info(self): """ diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index 7d7fe1758..10d37a3d7 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -221,6 +221,10 @@ class MPMServer(RPCServer): self._state.claim_token.value, self.client_host ) + if self.client_host in ["127.0.0.1", "::1"]: + self.periph_manager.set_connection_type("local") + else: + self.periph_manager.set_connection_type("remote") return self._state.claim_token.value @@ -284,6 +288,7 @@ class MPMServer(RPCServer): self.session_id = None self.periph_manager.claimed = False try: + self.periph_manager.set_connection_type(None) self.periph_manager.deinit() except Exception as ex: self._last_error = str(ex) @@ -345,7 +350,7 @@ class MPMServer(RPCServer): def _rpc_server_process(shared_state, port, mgr): """ - Start the RPC server + This is the actual process that's running the RPC server. """ connections = Pool(1000) server = StreamServer( |