diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-10 21:20:02 +0100 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-11 11:25:07 +0100 |
commit | 7b1a76063b15b238702cc86a71c5f0604c994920 (patch) | |
tree | fc1510be76fde5e3b7dbe799897cff3c59172f46 /src/conf_mode/interfaces-tunnel.py | |
parent | cf51589163956bb53c55493c27b177a9d2d5c806 (diff) | |
download | vyos-1x-7b1a76063b15b238702cc86a71c5f0604c994920.tar.gz vyos-1x-7b1a76063b15b238702cc86a71c5f0604c994920.zip |
dhcp: T2265: refactor DHCP class
Break the code between v4 and v6, remove need for getter/setter
as they are just exposing the underlying dict.
Move FixedDict from tunnel code and expose it to other part so
it can be used to prevent accidental change to the dhcp option if
no default exists already.
Diffstat (limited to 'src/conf_mode/interfaces-tunnel.py')
-rwxr-xr-x | src/conf_mode/interfaces-tunnel.py | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py index 28b1cf60f..19538da72 100755 --- a/src/conf_mode/interfaces-tunnel.py +++ b/src/conf_mode/interfaces-tunnel.py @@ -26,41 +26,7 @@ from vyos.ifconfig.afi import IP4, IP6 from vyos.configdict import list_diff from vyos.validate import is_ipv4, is_ipv6 from vyos import ConfigError - - -class FixedDict(dict): - """ - FixedDict: A dictionnary not allowing new keys to be created after initialisation. - - >>> f = FixedDict(**{'count':1}) - >>> f['count'] = 2 - >>> f['king'] = 3 - File "...", line ..., in __setitem__ - raise ConfigError(f'Option "{k}" has no defined default') - """ - def __init__ (self, **options): - self._allowed = options.keys() - super().__init__(**options) - - def __setitem__ (self, k, v): - """ - __setitem__ is a builtin which is called by python when setting dict values: - >>> d = dict() - >>> d['key'] = 'value' - >>> d - {'key': 'value'} - - is syntaxic sugar for - - >>> d = dict() - >>> d.__setitem__('key','value') - >>> d - {'key': 'value'} - """ - if k not in self._allowed: - raise ConfigError(f'Option "{k}" has no defined default') - super().__setitem__(k, v) - +from vyos.dicts import FixedDict class ConfigurationState(Config): """ |