Config mode scripts vary in the level of control required when merging default values; this adds a middle level of control between automatic merging and explicit merging (example 2, below):
(1) automatic
```
def get_config(config=None):
...
base = ['system', 'conntrack']
conntrack = conf.get_config_dict(base, key_mangling=('-', '_'),
get_first_key=True,
with_recursive_defaults=True)
return conntrack
```
(2) conditional
```
def get_config(config=None):
...
base = ['load-balancing', 'reverse-proxy']
lb = conf.get_config_dict(base,
get_first_key=True,
key_mangling=('-', '_'),
no_tag_node_value_mangle=True)
...
if lb:
lb = conf.merge_defaults(lb, recursive=True)
return lb
```
(3) explicit
```
def get_config(config=Nnone):
...
base = ['some'ystem', 'path''flow-accounting']
d =if not conf.get_config_dict(base, ...)
exists(base):
return None
...flow_accounting = conf.get_config_dict(base, key_mangling=('-', '_'), conditional bail out or additions ...get_first_key=True)
default_values = conf.get_config_defaults(**dflow_accounting.options,
recursive=True)
... modification as needed ...
# delete individual flow type defaults - should only be added if user
d = config_dict_merge(defaults, d)# sets this feature
return dfor flow_type in ['sflow', 'netflow']:
if flow_type not in flow_accounting and flow_type in default_values:
del default_values[flow_type]
flow_accounting = config_dict_merge(default_values, flow_accounting)
```
This has been tested and will be part of the PR for T5319.