Skip to content

Commit

Permalink
[airos] added schema and handler for autoneg and flowcontrol property
Browse files Browse the repository at this point in the history
  • Loading branch information
edoput committed Jul 24, 2017
1 parent 0237f7d commit eada34c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
32 changes: 23 additions & 9 deletions netjsonconfig/backends/airos/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,26 @@ def type_to_role(self, typestr):
}
return roles.get(typestr, '')

def autoneg_status(self, interface):
if interface.get('autoneg'):
return 'enabled'
else:
return 'disabled'

def flowcontrol_status(self, interface):
if interface.get('flowcontrol'):
status = 'enabled'
else:
status = 'disabled'
return {
'rx': {
'status': status,
},
'tx': {
'status': status,
},
}

def to_intermediate(self):
result = []
interfaces = []
Expand All @@ -282,15 +302,9 @@ def to_intermediate(self):
}
# handle interface type quirks
if interface['type'] == 'ethernet' and '.' not in interface['name']:
base['autoneg'] = 'enabled'
base['flowcontrol'] = {
'rx': {
'status': 'enabled',
},
'tx': {
'status': 'enabled',
},
}
base['autoneg'] = self.autoneg_status(interface)

base['flowcontrol'] = self.flowcontrol_status(interface)

if interface['type'] == 'wireless':
base['devname'] = interface['wireless']['radio']
Expand Down
10 changes: 10 additions & 0 deletions netjsonconfig/backends/airos/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
},
},
},
"interface_settings": {
"properties": {
"authoneg": {
"type": "boolean",
},
"flowcontrol": {
"type": "boolean",
}
}
}
},
"properties": {
"netmode": {
Expand Down

0 comments on commit eada34c

Please sign in to comment.