Skip to content

Commit

Permalink
[airos] merged multiple schema overrides into one
Browse files Browse the repository at this point in the history
  • Loading branch information
edoput committed Jul 17, 2017
1 parent 5985e1e commit eb40826
Showing 1 changed file with 36 additions and 64 deletions.
100 changes: 36 additions & 64 deletions netjsonconfig/backends/airos/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
from ...utils import merge_config


def merge_list(schema_list):
schema = default_schema
for s in schema_list:
schema = merge_config(schema, s)
return schema


"""
This defines a new property in the ``Interface``.
Expand All @@ -23,7 +16,7 @@ def merge_list(schema_list):
on a bridge
"""

netconf_schema = {
override_schema = {
"type": "object",
"addtionalProperties": True,
"definitions": {
Expand All @@ -34,19 +27,38 @@ def merge_list(schema_list):
"default": False,
}
}
}
}
}


"""
This schema defines a new property for netjson
As the antenna can be in ``bridge`` or ``router`` mode
this mode can be selected from this property
"""
netmode_schema = {
"type": "object",
},
"encryption_wireless_property_ap": {
"properties": {
"encryption": {
"type": "object",
"title": "Encryption",
"required": "protocol",
"propertyOrder": 20,
"oneOf": [
{"$ref": "#/definitions/encryption_none"},
{"$ref": "#/definitions/encryption_wpa_personal"},
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
],
},
},
},
"encryption_wireless_property_sta": {
"properties": {
"encryption": {
"type": "object",
"title": "Encryption",
"required": "protocol",
"propertyOrder": 20,
"oneOf": [
{"$ref": "#/definitions/encryption_none"},
{"$ref": "#/definitions/encryption_wpa_personal"},
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
],
},
},
},
},
"properties": {
"netmode": {
"enum": [
Expand All @@ -59,49 +71,9 @@ def merge_list(schema_list):
},
}


"""
This schema override the possible encryption for AirOS from the default schema
"""
wpasupplicant_schema = {
"encryption_wireless_property_sta": {
"properties": {
"encryption": {
"type": "object",
"title": "Encryption",
"required": "protocol",
"propertyOrder": 20,
"oneOf": [
{"$ref": "#/definitions/encryption_none"},
{"$ref": "#/definitions/encryption_wpa_personal"},
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
],
},
},
},
"encryption_wireless_property_ap": {
"properties": {
"encryption": {
"type": "object",
"title": "Encryption",
"required": "protocol",
"propertyOrder": 20,
"oneOf": [
{"$ref": "#/definitions/encryption_none"},
{"$ref": "#/definitions/encryption_wpa_personal"},
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
],
},
},
},
}


schema = merge_list([
schema = merge_config(
default_schema,
netconf_schema,
netmode_schema,
wpasupplicant_schema,
])
override_schema
)

__all__ = [schema]

0 comments on commit eb40826

Please sign in to comment.