From a02b7d54c561368d8a9a22a0643a1b4fb1e90345 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Fri, 17 Oct 2025 14:53:10 -0500 Subject: 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. --- python/vyos/vyconf_session.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'python') 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) -- cgit v1.2.3