Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Allow variables in mac address patterns in schema.py #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

DEFAULT_FILE_MODE = '0644'
X509_FILE_MODE = '0600'
VAR_PATTERN = '([{]{2}.*[}]{2})'
MAC_PATTERN = '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})'
MAC_PATTERN_BLANK = '^({0}|)$'.format(MAC_PATTERN)
MAC_VAR_PATTERN = '^({0}|{1})$'.format(MAC_PATTERN, VAR_PATTERN)
MAC_VAR_BLANK_PATTERN = '^({0}|)$'.format(MAC_VAR_PATTERN)

schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
Expand Down Expand Up @@ -140,8 +142,7 @@
"type": "string",
"title": "MAC address",
"description": "if specified overrides default macaddress for this interface",
"pattern": MAC_PATTERN_BLANK, # can be empty
"maxLength": 17,
lpalgarvio marked this conversation as resolved.
Show resolved Hide resolved
"pattern": MAC_VAR_BLANK_PATTERN, # can be empty
"propertyOrder": 3,
},
"autostart": {
Expand Down Expand Up @@ -318,8 +319,7 @@
"bssid": {
"type": "string",
"title": "BSSID",
"pattern": MAC_PATTERN_BLANK,
"maxLength": 17,
"pattern": MAC_VAR_BLANK_PATTERN, # can be empty
"propertyOrder": 4,
},
}
Expand Down Expand Up @@ -846,7 +846,7 @@
"required": ["bssid"],
"properties": {
"mode": {"enum": ["adhoc"]},
"bssid": {"pattern": MAC_PATTERN, "minLength": 17},
"bssid": {"pattern": MAC_VAR_PATTERN},
},
},
{"$ref": "#/definitions/base_wireless_settings"},
Expand Down