API update (#128)

* adding support for api fields that can be disabled and have default value at the same time

Signed-off-by: Tomas Herfert <herfik>

* api path support: interface gre

Signed-off-by: Tomas Herfert <herfik>

* docs

Signed-off-by: Tomas Herfert <herfik>

* unit test update & yamlling fix

Signed-off-by: Tomas Herfert <herfik>

* test fix

Signed-off-by: Tomas Herfert <herfik>

* sanity fix

Signed-off-by: Tomas Herfert <herfik>

* changelog

Signed-off-by: Tomas Herfert <herfik>

* Update per suggestion

Co-authored-by: Felix Fontein <felix@fontein.de>

* api path support: interface eoip

Signed-off-by: Tomas Herfert <herfik>

* docs

Signed-off-by: Tomas Herfert <herfik>

* apply suggestion from code review

Signed-off-by: Tomas Herfert <herfik>

Signed-off-by: Tomas Herfert <herfik>
Co-authored-by: Tomas Herfert <herfik>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Tomas Herfert 2022-11-17 12:48:50 +01:00 committed by GitHub
parent 1353055fe2
commit 23b3aa3beb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 6 deletions

View file

@ -49,8 +49,10 @@ class KeyInfo(object):
def __init__(self, _dummy=None, can_disable=False, remove_value=None, absent_value=None, default=None, required=False, automatically_computed_from=None):
if _dummy is not None:
raise ValueError('KeyInfo() does not have positional arguments')
if sum([required, default is not None, automatically_computed_from is not None, can_disable]) > 1:
raise ValueError('required, default, automatically_computed_from, and can_disable are mutually exclusive')
if sum([required, default is not None or can_disable, automatically_computed_from is not None]) > 1:
raise ValueError(
'required, default, automatically_computed_from, and can_disable are mutually exclusive ' +
'besides default and can_disable which can be set together')
if not can_disable and remove_value is not None:
raise ValueError('remove_value can only be specified if can_disable=True')
if absent_value is not None and any([default is not None, automatically_computed_from is not None, can_disable]):
@ -106,6 +108,31 @@ PATHS = {
'vlan-filtering': KeyInfo(default=False),
},
),
('interface', 'eoip'): APIData(
fully_understood=True,
primary_keys=('name',),
fields={
'allow-fast-path': KeyInfo(default=True),
'arp': KeyInfo(default='enabled'),
'arp-timeout': KeyInfo(default='auto'),
'clamp-tcp-mss': KeyInfo(default=True),
'comment': KeyInfo(can_disable=True, remove_value=''),
'disabled': KeyInfo(default=False),
'dont-fragment': KeyInfo(default=False),
'dscp': KeyInfo(default='inherit'),
'ipsec-secret': KeyInfo(can_disable=True),
'keepalive': KeyInfo(default='10s,10', can_disable=True),
'local-address': KeyInfo(default='0.0.0.0'),
'loop-protect': KeyInfo(default='default'),
'loop-protect-disable-time': KeyInfo(default='5m'),
'loop-protect-send-interval': KeyInfo(default='5s'),
'mac-address': KeyInfo(),
'mtu': KeyInfo(default='auto'),
'name': KeyInfo(),
'remote-address': KeyInfo(required=True),
'tunnel-id': KeyInfo(required=True),
},
),
('interface', 'ethernet'): APIData(
fixed_entries=True,
fully_understood=True,
@ -145,6 +172,24 @@ PATHS = {
'tx-flow-control': KeyInfo(default='off'),
},
),
('interface', 'gre'): APIData(
fully_understood=True,
primary_keys=('name', ),
fields={
'allow-fast-path': KeyInfo(default=True),
'clamp-tcp-mss': KeyInfo(default=True),
'comment': KeyInfo(can_disable=True, remove_value=''),
'disabled': KeyInfo(default=False),
'dont-fragment': KeyInfo(default=False),
'dscp': KeyInfo(default='inherit'),
'ipsec-secret': KeyInfo(can_disable=True),
'keepalive': KeyInfo(default='10s,10', can_disable=True),
'local-address': KeyInfo(default='0.0.0.0'),
'mtu': KeyInfo(default='auto'),
'name': KeyInfo(),
'remote-address': KeyInfo(required=True),
},
),
('interface', 'list'): APIData(
primary_keys=('name', ),
fully_understood=True,