diff options
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) |
