From 615169cd697a95ac87924e355c82520e80be3dab Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 25 Sep 2018 01:47:29 -0400 Subject: [PATCH] Properly support limit --- client-common/client_lib/network.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/client-common/client_lib/network.py b/client-common/client_lib/network.py index cd633b6f..c665d9c9 100644 --- a/client-common/client_lib/network.py +++ b/client-common/client_lib/network.py @@ -35,6 +35,7 @@ import configparser import kazoo.client import client_lib.ansiiprint as ansiiprint +import client_lib.zkhandler as zkhandler import client_lib.common as common # @@ -214,9 +215,19 @@ def get_info(zk_conn, network, long_output): return True, '' def get_list(zk_conn, limit): - net_list = zk_conn.get_children('/networks') - net_list_output = [] + net_list = [] + full_net_list = zk_conn.get_children('/networks') + for net in full_net_list: + description = zkhandler.readdata(zk_conn, '/networks/{}'.format(net)) + if limit != None: + try: + if not re.match(limit, net) or not re.match(limit, description): + continue + except Exception as e: + return False, 'Regex Error: {}'.format(e) + net_list.append(net) + net_list_output = [] description = {} ip_network = {} ip_gateway = {}