summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-04-16 11:16:36 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-05-22 13:26:48 -0500
commit8de29b3c35e4dc81ff5e4f92e666d760d251f6f0 (patch)
tree30efe06007e93b9214bd730a66196b2413fa6727 /python
parentbc6e337a13f3021ad39eb064e2452df7df77232f (diff)
downloadvyos-1x-8de29b3c35e4dc81ff5e4f92e666d760d251f6f0.tar.gz
vyos-1x-8de29b3c35e4dc81ff5e4f92e666d760d251f6f0.zip
T7363: add check for config mode that is independent from Cstore
The environment variable _OFR_CONFIGURE is used by bash completion to setup the config mode environment. We check this setting to coordinate vyconf config mode and CLI config mode, independent of the legacy backend Cstore check.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/utils/session.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/python/vyos/utils/session.py b/python/vyos/utils/session.py
new file mode 100644
index 000000000..28559dc59
--- /dev/null
+++ b/python/vyos/utils/session.py
@@ -0,0 +1,25 @@
+# Copyright 2025 VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+# pylint: disable=import-outside-toplevel
+
+
+def in_config_session():
+ """Vyatta bash completion uses the following environment variable for
+ indication of the config mode environment, independent of legacy backend
+ initialization of Cstore"""
+ from os import environ
+
+ return '_OFR_CONFIGURE' in environ