Skip to content

Commit 486fdc6

Browse files
committed
[airos] added draft for sshd property schema and sshd converter
1 parent 22c89ce commit 486fdc6

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

netjsonconfig/backends/airos/converters.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,21 @@ def to_intermediate(self):
501501

502502

503503
class Sshd(AirOsConverter):
504-
netjson_key = 'general'
504+
netjson_key = 'sshd'
505505

506506
def to_intermediate(self):
507+
def status(original, key='enabled'):
508+
if original.get(key, True):
509+
return 'enabled'
510+
else:
511+
return 'disabled'
512+
507513
result = []
514+
original = get_copy(self.netjson, self.netjson_key)
508515
result.append({
509-
'auth': {'passwd': 'enabled'},
510-
'port': 22,
511-
'status': 'enabled',
516+
'auth': {'passwd': status(original, 'password_auth')},
517+
'port': original.get('port', 22),
518+
'status': status(original, 'enabled'),
512519
})
513520
return (('sshd', result),)
514521

netjsonconfig/backends/airos/schema.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,45 @@
123123
}
124124
}
125125
},
126+
"sshd": {
127+
"type": "object",
128+
"title": "SSHd settings",
129+
"additionalProperties": True,
130+
"properties": {
131+
"port": {
132+
"type": "integer",
133+
"default": 22,
134+
},
135+
"enabled": {
136+
"type": "boolean",
137+
"default": True,
138+
},
139+
"password_auth": {
140+
"type": "boolean",
141+
"default": True,
142+
},
143+
"keys": {
144+
"type": "array",
145+
"items": {
146+
"type": "object",
147+
"properties": {
148+
"type": {
149+
"type": "string",
150+
},
151+
"key": {
152+
"type": "string",
153+
},
154+
"comment": {
155+
"type": "string",
156+
},
157+
"enabled": {
158+
"type": "boolean",
159+
},
160+
}
161+
}
162+
},
163+
},
164+
},
126165
"user": {
127166
"additionalProperties": True,
128167
"properties": {

0 commit comments

Comments
 (0)