From f07a0e333fbeb2b8e14073ffc2ae01d04f07cd49 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 20 Oct 2017 15:15:59 -0400 Subject: [PATCH] Use natural sort in parts of macmap api It was hard to traverse things through default sort, provide natural sort to node names and port names. --- confluent_server/confluent/networking/macmap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/networking/macmap.py b/confluent_server/confluent/networking/macmap.py index 21269a69..58036d58 100644 --- a/confluent_server/confluent/networking/macmap.py +++ b/confluent_server/confluent/networking/macmap.py @@ -392,7 +392,7 @@ def handle_read_api_request(pathcomponents, configmanager): # TODO: should be list of node names, and then under that 'by-mac' if len(pathcomponents) == 3: return [msg.ChildCollection(x.replace(':', '-')) - for x in sorted(list(_nodesbymac))] + for x in util.natural_sort(list(_nodesbymac))] elif len(pathcomponents) == 4: macaddr = pathcomponents[-1].replace('-', ':') return dump_macinfo(macaddr) @@ -414,7 +414,7 @@ def handle_read_api_request(pathcomponents, configmanager): raise exc.NotFoundException( 'No known macs for switch {0}'.format(switchname)) return [msg.ChildCollection(x.replace('/', '-') + '/') - for x in sorted(list(_macsbyswitch[switchname]))] + for x in util.natural_sort(list(_macsbyswitch[switchname]))] if len(pathcomponents) == 6: return [msg.ChildCollection('by-mac/')] if len(pathcomponents) == 7: