File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
netjsonconfig/backends/airos Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -440,10 +440,35 @@ def to_intermediate(self):
440440class Route (AirOsConverter ):
441441 netjson_key = 'routes'
442442
443+ def default_routes (self ):
444+ def is_default_route (interface ):
445+ try :
446+ t = [addr .get ('gateway' , '' ) for addr in interface ['addresses' ]]
447+ return any (t )
448+ except KeyError :
449+ return False
450+
451+ result = []
452+ original = [x for x in get_copy (self .netjson , 'interfaces' , []) if is_default_route (x )]
453+ for interface in original :
454+ for address in interface ['addresses' ]:
455+ try :
456+ result .append ({
457+ 'devname' : interface ['name' ],
458+ 'gateway' : address ['gateway' ],
459+ 'ip' : '0.0.0.0' ,
460+ 'netmask' : 0 ,
461+ 'status' : 'enabled' ,
462+ })
463+ except KeyError :
464+ pass
465+ return result
466+
443467 def to_intermediate (self ):
444468 result = []
445- original = get_copy (self .netjson , self .netjson_key , [])
446469 routes = []
470+ routes = self .default_routes ()
471+ original = get_copy (self .netjson , self .netjson_key , [])
447472 for r in original :
448473 network = ip_interface (r ['destination' ])
449474 temp = {}
You can’t perform that action at this time.
0 commit comments