summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-04-25 17:31:23 +0200
committerGitHub <noreply@github.com>2024-04-25 17:31:23 +0200
commitb8c5c0c3b74fff00f998a22eae0e3a491af3fa6d (patch)
tree7fa27b7290df32cc6d68e7f2a6993ba6c3eb4278 /src/conf_mode
parent13af058504c67dfabced5c8a1762e04ffde119ce (diff)
parentda40bd2b2a826986de128354ea1bfc041ada0016 (diff)
downloadvyos-1x-b8c5c0c3b74fff00f998a22eae0e3a491af3fa6d.tar.gz
vyos-1x-b8c5c0c3b74fff00f998a22eae0e3a491af3fa6d.zip
Merge pull request #3316 from HollyGurza/T4248
qos: T4248: Allow to remove the only rule from the qos class
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/qos.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py
index 3dfb4bab8..ccfc8f6b8 100755
--- a/src/conf_mode/qos.py
+++ b/src/conf_mode/qos.py
@@ -70,6 +70,22 @@ def get_shaper(qos, interface_config, direction):
return (map_vyops_tc[shaper_type], shaper_config)
+
+def _clean_conf_dict(conf):
+ """
+ Delete empty nodes from config e.g.
+ match ADDRESS30 {
+ ip {
+ source {}
+ }
+ }
+ """
+ if isinstance(conf, dict):
+ return {node: _clean_conf_dict(val) for node, val in conf.items() if val != {} and _clean_conf_dict(val) != {}}
+ else:
+ return conf
+
+
def get_config(config=None):
if config:
conf = config
@@ -120,6 +136,13 @@ def get_config(config=None):
if 'queue_limit' not in qos['policy'][policy][p_name]['precedence'][precedence]:
qos['policy'][policy][p_name]['precedence'][precedence]['queue_limit'] = \
str(int(4 * max_thr))
+ # cleanup empty match config
+ if 'class' in p_config:
+ for cls, cls_config in p_config['class'].items():
+ if 'match' in cls_config:
+ cls_config['match'] = _clean_conf_dict(cls_config['match'])
+ if cls_config['match'] == {}:
+ del cls_config['match']
return qos