mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
sort routers by display_name
This commit is contained in:
@ -187,8 +187,8 @@ class Routers(HyperglassModelExtra):
|
||||
networks = set()
|
||||
display_vrfs = set()
|
||||
vrf_objects = set()
|
||||
router_objects = []
|
||||
routers = Routers()
|
||||
routers.routers = []
|
||||
routers.hostnames = []
|
||||
routers.vrfs = []
|
||||
routers.display_vrfs = []
|
||||
@ -206,7 +206,7 @@ class Routers(HyperglassModelExtra):
|
||||
# list with `devices.hostnames`, same for all router
|
||||
# classes, for when iteration over all routers is required.
|
||||
routers.hostnames.append(router.name)
|
||||
routers.routers.append(router)
|
||||
router_objects.append(router)
|
||||
|
||||
for vrf in router.vrfs:
|
||||
# For each configured router VRF, add its name and
|
||||
@ -242,4 +242,7 @@ class Routers(HyperglassModelExtra):
|
||||
routers.vrf_objects = list(vrf_objects)
|
||||
routers.networks = list(networks)
|
||||
|
||||
# Sort router list by router name attribute
|
||||
routers.routers = sorted(router_objects, key=lambda x: x.display_name)
|
||||
|
||||
return routers
|
||||
|
Reference in New Issue
Block a user