From 0e7bfe4f40d45febe9e22d66421c2a09c9ec4777 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Nov 2018 14:17:12 -0500 Subject: [PATCH] Use scanning status to control rescan behaviors This causes the manual assignment to sleep less and for the rescan command to meaningfully slow down shell requests to provide better sense of when scan completes. --- confluent_client/bin/nodediscover | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index b6bd07f0..1ab24afc 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -170,9 +170,7 @@ def import_csv(options, session): if not datum_complete(nodedatum): sys.exit(1) if not search_record(nodedatum, options, session): - list(session.update('/discovery/rescan', - {'rescan': 'start'})) - time.sleep(5) + blocking_scan(session) if not search_record(nodedatum, options, session): sys.stderr.write( "Could not match the following data: " + @@ -285,6 +283,10 @@ def assign_discovery(options, session): else: print(repr(res)) +def blocking_scan(session): + list(session.update('/discovery/rescan', {'rescan': 'start'})) + while(list(session.read('/discovery/rescan'))[0].get('scanning', False)): + time.sleep(0.5) def main(): @@ -338,8 +340,8 @@ def main(): if args[0] == 'assign': assign_discovery(options, session) if args[0] == 'rescan': - list(session.update('/discovery/rescan', {'rescan': 'start'})) - print("Rescan initiated") + blocking_scan(session) + print("Rescan complete") if __name__ == '__main__':