diff --git a/hyperglass/configuration/models/routers.py b/hyperglass/configuration/models/routers.py index fd38e47..7ec8873 100644 --- a/hyperglass/configuration/models/routers.py +++ b/hyperglass/configuration/models/routers.py @@ -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