Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 5.11.1 and Python 3 fixes #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions RestApi/Python/exportConfig.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

################################################################################
#
Expand All @@ -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.
Expand Down Expand Up @@ -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 <username> -p <password> [-h <host> | -f <host_file>] [-r port]'
print ('import_config.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)
for opt, arg in opts:
if opt in ("-u", "--username"):
Expand All @@ -80,15 +83,15 @@ def exportConfig(host_ip, port, username, password, timestamp):
config_file = arg

if username == '':
print 'exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]'
print ('exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

if password == '':
print 'exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]'
print ('exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

if (host == '') and (hosts_file == ''):
print 'exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]'
print ('exportConfig.py -u <username> -p <password> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

timestamp = time.strftime('%Y-%m-%d-%H-%M-%S')
Expand Down Expand Up @@ -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 ("")
19 changes: 11 additions & 8 deletions RestApi/Python/importConfig.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

#################################################################################
#
Expand All @@ -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.
Expand Down Expand Up @@ -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 <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]'
print ('importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)
for opt, arg in opts:
if opt in ("-u", "--username"):
Expand All @@ -79,19 +82,19 @@ def importConfig(host_ip, port, username, password, config_file):
config_file = arg

if username == '':
print 'importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]'
print ('importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

if password == '':
print 'importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]'
print ('importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

if (host == '') and (hosts_file == ''):
print 'importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]'
print ('importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

if config_file == '':
print 'importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]'
print ('importConfig.py -u <username> -p <password> -c <config_file> [-h <host> | -f <host_file>] [-r port]')
sys.exit(2)

hosts_list = []
Expand Down Expand Up @@ -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 ("")
5 changes: 4 additions & 1 deletion RestApi/Python/ksvisionlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3344,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', None, False)

###################################################
# Line Boards
Expand Down
19 changes: 11 additions & 8 deletions RestApi/Python/mkfilter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

################################################################################
#
Expand All @@ -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
Expand Down Expand Up @@ -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 <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('0mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)
for opt, arg in opts:
if opt in ("-u", "--username"):
Expand All @@ -117,27 +120,27 @@ def ipAddress (bits, version):
port = arg

if username == '':
print '1mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('1mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)

if password == '':
print '2mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('2mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)

if (host == ''):
print '3mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('3mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)

if length == '':
print '4mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('4mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)

if offset == '':
print '5mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('5mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)

if version == '':
print '6mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]'
print ('6mkfilters.py -u <username> -p <password> -h <host> -l <length> -o <offset> -v <version> [-r <port>]')
sys.exit(2)


Expand Down