Skip to content

Commit eb40826

Browse files
committed
[airos] merged multiple schema overrides into one
1 parent 5985e1e commit eb40826

File tree

1 file changed

+36
-64
lines changed

1 file changed

+36
-64
lines changed

netjsonconfig/backends/airos/schema.py

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
from ...utils import merge_config
77

88

9-
def merge_list(schema_list):
10-
schema = default_schema
11-
for s in schema_list:
12-
schema = merge_config(schema, s)
13-
return schema
14-
15-
169
"""
1710
This defines a new property in the ``Interface``.
1811
@@ -23,7 +16,7 @@ def merge_list(schema_list):
2316
on a bridge
2417
"""
2518

26-
netconf_schema = {
19+
override_schema = {
2720
"type": "object",
2821
"addtionalProperties": True,
2922
"definitions": {
@@ -34,19 +27,38 @@ def merge_list(schema_list):
3427
"default": False,
3528
}
3629
}
37-
}
38-
}
39-
}
40-
41-
42-
"""
43-
This schema defines a new property for netjson
44-
45-
As the antenna can be in ``bridge`` or ``router`` mode
46-
this mode can be selected from this property
47-
"""
48-
netmode_schema = {
49-
"type": "object",
30+
},
31+
"encryption_wireless_property_ap": {
32+
"properties": {
33+
"encryption": {
34+
"type": "object",
35+
"title": "Encryption",
36+
"required": "protocol",
37+
"propertyOrder": 20,
38+
"oneOf": [
39+
{"$ref": "#/definitions/encryption_none"},
40+
{"$ref": "#/definitions/encryption_wpa_personal"},
41+
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
42+
],
43+
},
44+
},
45+
},
46+
"encryption_wireless_property_sta": {
47+
"properties": {
48+
"encryption": {
49+
"type": "object",
50+
"title": "Encryption",
51+
"required": "protocol",
52+
"propertyOrder": 20,
53+
"oneOf": [
54+
{"$ref": "#/definitions/encryption_none"},
55+
{"$ref": "#/definitions/encryption_wpa_personal"},
56+
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
57+
],
58+
},
59+
},
60+
},
61+
},
5062
"properties": {
5163
"netmode": {
5264
"enum": [
@@ -59,49 +71,9 @@ def merge_list(schema_list):
5971
},
6072
}
6173

62-
63-
"""
64-
This schema override the possible encryption for AirOS from the default schema
65-
"""
66-
wpasupplicant_schema = {
67-
"encryption_wireless_property_sta": {
68-
"properties": {
69-
"encryption": {
70-
"type": "object",
71-
"title": "Encryption",
72-
"required": "protocol",
73-
"propertyOrder": 20,
74-
"oneOf": [
75-
{"$ref": "#/definitions/encryption_none"},
76-
{"$ref": "#/definitions/encryption_wpa_personal"},
77-
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
78-
],
79-
},
80-
},
81-
},
82-
"encryption_wireless_property_ap": {
83-
"properties": {
84-
"encryption": {
85-
"type": "object",
86-
"title": "Encryption",
87-
"required": "protocol",
88-
"propertyOrder": 20,
89-
"oneOf": [
90-
{"$ref": "#/definitions/encryption_none"},
91-
{"$ref": "#/definitions/encryption_wpa_personal"},
92-
{"$ref": "#/definitions/encryption_wpa_enterprise_sta"},
93-
],
94-
},
95-
},
96-
},
97-
}
98-
99-
100-
schema = merge_list([
74+
schema = merge_config(
10175
default_schema,
102-
netconf_schema,
103-
netmode_schema,
104-
wpasupplicant_schema,
105-
])
76+
override_schema
77+
)
10678

10779
__all__ = [schema]

0 commit comments

Comments
 (0)