mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Support value-in-range with <number> keyword
This allows syntax checking to pass for fields like vxlan-ttl/vxlan-tos which can be a number in a range OR a string value representing a special meaning (0-255 or "auto", for instance). Without this, you can only pass a --syntax-check for such fields if your value is one of those literally specified because, for instance, "64" is not "auto", "0", or "255": invalid value "64": valid attribute values: ['0', '255'] info: exit status 1 Note that _applying_ such configuration still works, because netlink's acceptance criteria are independent of ifupdown2's.
This commit is contained in:
@ -97,12 +97,14 @@ class vxlan(Addon, moduleBase):
|
|||||||
"help": "specifies the TTL value to use in outgoing packets "
|
"help": "specifies the TTL value to use in outgoing packets "
|
||||||
"(range 0..255), 0=auto",
|
"(range 0..255), 0=auto",
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"validvals": ["0", "255"],
|
"validrange": ["0", "255"],
|
||||||
|
"validvals": ["<number>", "auto"],
|
||||||
"example": ['vxlan-ttl 42'],
|
"example": ['vxlan-ttl 42'],
|
||||||
},
|
},
|
||||||
"vxlan-tos": {
|
"vxlan-tos": {
|
||||||
"help": "specifies the ToS value (range 0..255), 1=inherit",
|
"help": "specifies the ToS value (range 0..255), 1=inherit",
|
||||||
"validvals": ["inherit", "0", "255"],
|
"validrange": ["0", "255"],
|
||||||
|
"validvals": ["<number>", "inherit"],
|
||||||
"example": ['vxlan-tos 42'],
|
"example": ['vxlan-tos 42'],
|
||||||
},
|
},
|
||||||
"vxlan-mcastgrp": {
|
"vxlan-mcastgrp": {
|
||||||
|
@ -1224,7 +1224,9 @@ class ifupdownMain:
|
|||||||
|
|
||||||
def _keyword_number(self, value, validrange=None):
|
def _keyword_number(self, value, validrange=None):
|
||||||
try:
|
try:
|
||||||
int(value)
|
int_value = int(value)
|
||||||
|
if validrange is not None:
|
||||||
|
return int(validrange[0]) <= int_value <= int(validrange[1])
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.debug('keyword: number: %s' % str(e))
|
self.logger.debug('keyword: number: %s' % str(e))
|
||||||
|
Reference in New Issue
Block a user