summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-10-28 15:01:52 +0100
committerDaniil Baturin <daniil@baturin.org>2019-10-28 15:01:52 +0100
commitaac75107bc9988ecb599265da029827ff09bf713 (patch)
treea3d7d8f8837f7c94bcfe3c30df885723f6169320 /python
parent8d57656ae0417af0f28ec2fac476b86e72dde110 (diff)
downloadvyos-1x-aac75107bc9988ecb599265da029827ff09bf713.tar.gz
vyos-1x-aac75107bc9988ecb599265da029827ff09bf713.zip
Add a function for retrieving config dicts.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/config.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py
index 5c2fc7285..13b2c107e 100644
--- a/python/vyos/config.py
+++ b/python/vyos/config.py
@@ -65,6 +65,7 @@ In operational mode, all functions return values from the running config.
import os
import re
+import json
import subprocess
import vyos.configtree
@@ -225,7 +226,7 @@ class Config(object):
def show_config(self, path=[], default=None):
"""
Args:
- path (str): Configuration tree path, or empty
+ path (str list): Configuration tree path, or empty
default (str): Default value to return
Returns:
@@ -239,6 +240,16 @@ class Config(object):
except VyOSError:
return(default)
+ def get_config_dict(self, path=[], effective=False):
+ """
+ Args: path (str list): Configuration tree path, can be empty
+ Returns: a dict representation of the config
+ """
+ res = self.show_config(self._make_path(path))
+ config_tree = vyos.configtree.ConfigTree(res)
+ config_dict = json.loads(config_tree.to_json())
+ return config_dict
+
def is_multi(self, path):
"""
Args: