diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-10-17 14:53:10 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-11-05 09:47:55 -0600 |
| commit | a02b7d54c561368d8a9a22a0643a1b4fb1e90345 (patch) | |
| tree | d2ea48159b34c35d049633f9df49f8cea79840be /python | |
| parent | cad2c08ee6f273ff4b9a0917825ca52ce25bfefa (diff) | |
| download | vyos-1x-a02b7d54c561368d8a9a22a0643a1b4fb1e90345.tar.gz vyos-1x-a02b7d54c561368d8a9a22a0643a1b4fb1e90345.zip | |
T7910: add call show_sessions
show_sessions returns a list of dicts of the internal session record
structure for each live session. As this call is itself mediated by a
session one can specify exclude_self=True, resp., exclude_other=True.
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/vyconf_session.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/python/vyos/vyconf_session.py b/python/vyos/vyconf_session.py index 461b225a8..5748ab2dd 100644 --- a/python/vyos/vyconf_session.py +++ b/python/vyos/vyconf_session.py @@ -18,6 +18,7 @@ import os import weakref import tempfile +import json from functools import wraps from typing import Type @@ -127,6 +128,21 @@ class VyconfSession: raise VyconfSessionError(self.output(out)) return out.output + def show_sessions( + self, exclude_self: bool = False, exclude_other: bool = False + ) -> list | dict: + out = vyconf_client.send_request( + 'show_sessions', + token=self.__token, + exclude_self=exclude_self, + exclude_other=exclude_other, + ) + + lst = json.loads(out.output) + if len(lst) == 1: + return lst[0] + return lst + @staticmethod def config_mode(f): @wraps(f) |
