Skip to content

Commit d25fe1b

Browse files
lpalgarviopandafy
andcommitted
Allow variables in mac address patterns in schema.py (Closes #238)
- Adds BLANK and VAR patterns - Patches MAC patterns - Removes usage of maxLength and minLength in mac and bssid properties Co-authored-by: Gagan Deep <the.one.above.all.titan@gmail.com>
1 parent 6db272c commit d25fe1b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

netjsonconfig/schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
DEFAULT_FILE_MODE = '0644'
1010
X509_FILE_MODE = '0600'
11+
VAR_PATTERN = '([{]{2}.*[}]{2})'
1112
MAC_PATTERN = '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})'
12-
MAC_PATTERN_BLANK = '^({0}|)$'.format(MAC_PATTERN)
13+
MAC_VAR_PATTERN = '^({0}|{1})$'.format(MAC_PATTERN, VAR_PATTERN)
14+
MAC_VAR_BLANK_PATTERN = '^({0}|)$'.format(MAC_VAR_PATTERN)
1315

1416
schema = {
1517
"$schema": "http://json-schema.org/draft-04/schema#",
@@ -140,8 +142,7 @@
140142
"type": "string",
141143
"title": "MAC address",
142144
"description": "if specified overrides default macaddress for this interface",
143-
"pattern": MAC_PATTERN_BLANK, # can be empty
144-
"maxLength": 17,
145+
"pattern": MAC_VAR_BLANK_PATTERN, # can be empty
145146
"propertyOrder": 3,
146147
},
147148
"autostart": {
@@ -318,8 +319,7 @@
318319
"bssid": {
319320
"type": "string",
320321
"title": "BSSID",
321-
"pattern": MAC_PATTERN_BLANK,
322-
"maxLength": 17,
322+
"pattern": MAC_VAR_BLANK_PATTERN, # can be empty
323323
"propertyOrder": 4,
324324
},
325325
}
@@ -846,7 +846,7 @@
846846
"required": ["bssid"],
847847
"properties": {
848848
"mode": {"enum": ["adhoc"]},
849-
"bssid": {"pattern": MAC_PATTERN, "minLength": 17},
849+
"bssid": {"pattern": MAC_VAR_PATTERN},
850850
},
851851
},
852852
{"$ref": "#/definitions/base_wireless_settings"},

0 commit comments

Comments
 (0)