summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-20 12:03:11 +0200
committerGitHub <noreply@github.com>2019-08-20 12:03:11 +0200
commit8ec2d46a618bd19f9dfa7ccb08f33dc869e3b5f0 (patch)
treef0a43c79702e9ddf2a3c6e7959f4a5cb60378bac /python
parent246d2dbad9df96ac895e88c9103eefa9f4cf04d7 (diff)
parentdbdd50e96f5af8f59d884f03df1cdeed9bac39d1 (diff)
downloadvyos-1x-8ec2d46a618bd19f9dfa7ccb08f33dc869e3b5f0.tar.gz
vyos-1x-8ec2d46a618bd19f9dfa7ccb08f33dc869e3b5f0.zip
Merge pull request #110 from c-po/powerdns
Powerdns
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configtree.py8
-rw-r--r--python/vyos/interfaces.py11
2 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index a812b62ec..8832a5a63 100644
--- a/python/vyos/configtree.py
+++ b/python/vyos/configtree.py
@@ -185,6 +185,14 @@ class ConfigTree(object):
return self.__to_commands(self.__config).decode()
def set(self, path, value=None, replace=True):
+ """Set new entry in VyOS configuration.
+ path: configuration path e.g. 'system dns forwarding listen-address'
+ value: value to be added to node, e.g. '172.18.254.201'
+ replace: True: current occurance will be replaced
+ False: new value will be appended to current occurances - use
+ this for adding values to a multi node
+ """
+
check_path(path)
path_str = " ".join(map(str, path)).encode()
diff --git a/python/vyos/interfaces.py b/python/vyos/interfaces.py
index 2e8ee4feb..d69ce9d04 100644
--- a/python/vyos/interfaces.py
+++ b/python/vyos/interfaces.py
@@ -43,3 +43,14 @@ def list_interfaces_of_type(typ):
else:
r = re.compile('^{0}\d+'.format(types_data[typ]))
return list(filter(lambda i: re.match(r, i), all_intfs))
+
+def get_type_of_interface(intf):
+ with open(intf_type_data_file, 'r') as f:
+ types_data = json.load(f)
+
+ for key,val in types_data.items():
+ r = re.compile('^{0}\d+'.format(val))
+ if re.match(r, intf):
+ return key
+
+ raise ValueError("No type found for interface name: {0}".format(intf))