From 985de268d080470004bb818dba2a6b45ab9a0843 Mon Sep 17 00:00:00 2001 From: Martin Brazdil Date: Wed, 13 Jul 2022 11:35:50 +0200 Subject: [PATCH 1/3] Update to 5.11.1 API and Python 3 --- RestApi/Python/exportConfig.py | 17 ++++++++++------- RestApi/Python/importConfig.py | 19 +++++++++++-------- RestApi/Python/ksvisionlib.py | 3 +++ RestApi/Python/mkfilter.py | 19 +++++++++++-------- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/RestApi/Python/exportConfig.py b/RestApi/Python/exportConfig.py index c4cb970..4eb1d91 100755 --- a/RestApi/Python/exportConfig.py +++ b/RestApi/Python/exportConfig.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 ################################################################################ # @@ -11,6 +11,9 @@ # - Updated copyright note. # - Use the ksvisionlib library. # +# July 13, 2022: +# - Change the script to Python 3. +# # Description: # This script exports the current configuration of an NTO or GSC device # to a .ata file. @@ -63,7 +66,7 @@ def exportConfig(host_ip, port, username, password, timestamp): try: opts, args = getopt.getopt(argv,"u:p:h:f:r:", ["username=", "password=", "host=", "hosts_file=", "port="]) except getopt.GetoptError: - print 'import_config.py -u -p [-h | -f ] [-r port]' + print ('import_config.py -u -p [-h | -f ] [-r port]') sys.exit(2) for opt, arg in opts: if opt in ("-u", "--username"): @@ -80,15 +83,15 @@ def exportConfig(host_ip, port, username, password, timestamp): config_file = arg if username == '': - print 'exportConfig.py -u -p [-h | -f ] [-r port]' + print ('exportConfig.py -u -p [-h | -f ] [-r port]') sys.exit(2) if password == '': - print 'exportConfig.py -u -p [-h | -f ] [-r port]' + print ('exportConfig.py -u -p [-h | -f ] [-r port]') sys.exit(2) if (host == '') and (hosts_file == ''): - print 'exportConfig.py -u -p [-h | -f ] [-r port]' + print ('exportConfig.py -u -p [-h | -f ] [-r port]') sys.exit(2) timestamp = time.strftime('%Y-%m-%d-%H-%M-%S') @@ -122,6 +125,6 @@ def exportConfig(host_ip, port, username, password, timestamp): sys.stdout.write('.') sys.stdout.flush() except KeyboardInterrupt: - print "Ctrl-c received! Sending kill to threads..." + print ("Ctrl-c received! Sending kill to threads...") sys.exit() -print "" +print ("") diff --git a/RestApi/Python/importConfig.py b/RestApi/Python/importConfig.py index 127bef1..31f29d4 100755 --- a/RestApi/Python/importConfig.py +++ b/RestApi/Python/importConfig.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 ################################################################################# # @@ -11,6 +11,9 @@ # - Updated copyright note. # - Use the ksvisionlib library. # +# July 13, 2022: +# - Change the script to Python 3. +# # Description: # This script will import a configuration (.ata) file to an NTO or an GSC # device. @@ -62,7 +65,7 @@ def importConfig(host_ip, port, username, password, config_file): try: opts, args = getopt.getopt(argv,"u:p:h:f:r:c:", ["username=", "password=", "host=", "hosts_file=", "port=", "config="]) except getopt.GetoptError: - print 'importConfig.py -u -p -c [-h | -f ] [-r port]' + print ('importConfig.py -u -p -c [-h | -f ] [-r port]') sys.exit(2) for opt, arg in opts: if opt in ("-u", "--username"): @@ -79,19 +82,19 @@ def importConfig(host_ip, port, username, password, config_file): config_file = arg if username == '': - print 'importConfig.py -u -p -c [-h | -f ] [-r port]' + print ('importConfig.py -u -p -c [-h | -f ] [-r port]') sys.exit(2) if password == '': - print 'importConfig.py -u -p -c [-h | -f ] [-r port]' + print ('importConfig.py -u -p -c [-h | -f ] [-r port]') sys.exit(2) if (host == '') and (hosts_file == ''): - print 'importConfig.py -u -p -c [-h | -f ] [-r port]' + print ('importConfig.py -u -p -c [-h | -f ] [-r port]') sys.exit(2) if config_file == '': - print 'importConfig.py -u -p -c [-h | -f ] [-r port]' + print ('importConfig.py -u -p -c [-h | -f ] [-r port]') sys.exit(2) hosts_list = [] @@ -123,6 +126,6 @@ def importConfig(host_ip, port, username, password, config_file): sys.stdout.write('.') sys.stdout.flush() except KeyboardInterrupt: - print "Ctrl-c received! Sending kill to threads..." + print ("Ctrl-c received! Sending kill to threads...") sys.exit() -print "" +print ("") diff --git a/RestApi/Python/ksvisionlib.py b/RestApi/Python/ksvisionlib.py index f822a17..ca6e81a 100644 --- a/RestApi/Python/ksvisionlib.py +++ b/RestApi/Python/ksvisionlib.py @@ -210,6 +210,9 @@ # - No changes for v5.10.1 # - Added the getLogs method # +# July 13, 2022 +# - No changes for v5.11.0 and v5.11.1 +# # COPYRIGHT 2019-2022 Keysight Technologies. # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/RestApi/Python/mkfilter.py b/RestApi/Python/mkfilter.py index 43ee1c4..dc794ab 100755 --- a/RestApi/Python/mkfilter.py +++ b/RestApi/Python/mkfilter.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 ################################################################################ # @@ -11,6 +11,9 @@ # - Updated copyright note. # - Use the ksvisionlib library. # +# July 13, 2022: +# - Change the script to Python 3. +# # Description: # This script creates 2^n filters, from 0 to 2^n-1. Where the 0th filter # contains all the source and destination IP addresses that when they are XORed @@ -98,7 +101,7 @@ def ipAddress (bits, version): try: opts, args = getopt.getopt(argv,"u:p:h:l:o:v:r:", ["username=", "password=", "host=", "length=", "offset=", "version=", "port="]) except getopt.GetoptError: - print '0mkfilters.py -u -p -h -l -o -v [-r ]' + print ('0mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) for opt, arg in opts: if opt in ("-u", "--username"): @@ -117,27 +120,27 @@ def ipAddress (bits, version): port = arg if username == '': - print '1mkfilters.py -u -p -h -l -o -v [-r ]' + print ('1mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) if password == '': - print '2mkfilters.py -u -p -h -l -o -v [-r ]' + print ('2mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) if (host == ''): - print '3mkfilters.py -u -p -h -l -o -v [-r ]' + print ('3mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) if length == '': - print '4mkfilters.py -u -p -h -l -o -v [-r ]' + print ('4mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) if offset == '': - print '5mkfilters.py -u -p -h -l -o -v [-r ]' + print ('5mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) if version == '': - print '6mkfilters.py -u -p -h -l -o -v [-r ]' + print ('6mkfilters.py -u -p -h -l -o -v [-r ]') sys.exit(2) From 04728fe39933d94bacdc08f83b98d42e1831737d Mon Sep 17 00:00:00 2001 From: Martin Brazdil Date: Wed, 13 Jul 2022 11:37:54 +0200 Subject: [PATCH 2/3] Remove args from resetFactoryDefaultKubernetesNode --- RestApi/Python/ksvisionlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RestApi/Python/ksvisionlib.py b/RestApi/Python/ksvisionlib.py index ca6e81a..cb336b2 100644 --- a/RestApi/Python/ksvisionlib.py +++ b/RestApi/Python/ksvisionlib.py @@ -3347,7 +3347,7 @@ def resetFactoryDefaultKubernetesNode(self, kubernetes_nodes_id): Reset to factory default a specific kubernetes node from the Mako card. Sample usage: """ - return self._sendRequest('POST', '/api/kubernetes_nodes/' + str(kubernetes_nodes_id) + '/reset_factory', args, False) + return self._sendRequest('POST', '/api/kubernetes_nodes/' + str(kubernetes_nodes_id) + '/reset_factory', False) ################################################### # Line Boards From cbc5e18eb29bf403cbbff48bf94756f32ae19373 Mon Sep 17 00:00:00 2001 From: Martin Brazdil Date: Wed, 13 Jul 2022 11:37:54 +0200 Subject: [PATCH 3/3] Fix removed args from resetFactoryDefaultKubernetesNode --- RestApi/Python/ksvisionlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RestApi/Python/ksvisionlib.py b/RestApi/Python/ksvisionlib.py index cb336b2..508e882 100644 --- a/RestApi/Python/ksvisionlib.py +++ b/RestApi/Python/ksvisionlib.py @@ -3347,7 +3347,7 @@ def resetFactoryDefaultKubernetesNode(self, kubernetes_nodes_id): Reset to factory default a specific kubernetes node from the Mako card. Sample usage: """ - return self._sendRequest('POST', '/api/kubernetes_nodes/' + str(kubernetes_nodes_id) + '/reset_factory', False) + return self._sendRequest('POST', '/api/kubernetes_nodes/' + str(kubernetes_nodes_id) + '/reset_factory', None, False) ################################################### # Line Boards