diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-03-19 16:02:08 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-03-19 17:24:53 +0100 |
| commit | 653857bfa8dcf8290da0daddfe231127befc271b (patch) | |
| tree | 475f27e8c043f32ffe8350e121dae337da3ba6a0 /python | |
| parent | 7957857e6b5d6572d2c9831e0e66dac80e7a415e (diff) | |
| download | vyos-1x-653857bfa8dcf8290da0daddfe231127befc271b.tar.gz vyos-1x-653857bfa8dcf8290da0daddfe231127befc271b.zip | |
vyos.ifconfig: T8047: add optional get_config_path() delimiter
If we would like to get the CLI config path as a dot delimited string (instead
of whitespace) we can now request it. This is usefull when feeding in the result
of get_config_path() into dict_search().
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/ifconfig/section.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python/vyos/ifconfig/section.py b/python/vyos/ifconfig/section.py index 7f110de04..c3f803c76 100644 --- a/python/vyos/ifconfig/section.py +++ b/python/vyos/ifconfig/section.py @@ -186,7 +186,7 @@ class Section: return list(cls._prefixes.keys()) @classmethod - def get_config_path(cls, name): + def get_config_path(cls, name, delimiter=' '): """ get config path to interface with .vif or .vif-s.vif-c example: eth0.1.2 -> 'ethernet eth0 vif-s 1 vif-c 2' @@ -195,11 +195,11 @@ class Section: sect = cls.section(name) if sect: splinterface = name.split('.') - intfpath = f'{sect} {splinterface[0]}' + intfpath = f'{sect}{delimiter}{splinterface[0]}' if len(splinterface) == 2: - intfpath += f' vif {splinterface[1]}' + intfpath += f'{delimiter}vif{delimiter}{splinterface[1]}' elif len(splinterface) == 3: - intfpath += f' vif-s {splinterface[1]} vif-c {splinterface[2]}' + intfpath += f'{delimiter}vif-s{delimiter}{splinterface[1]}{delimiter}vif-c{delimiter}{splinterface[2]}' return intfpath else: return False |
