]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2467] Remove the kea_connector2.py
authorSlawek Figiel <slawek@isc.org>
Tue, 27 Jun 2023 15:28:11 +0000 (17:28 +0200)
committerSlawek Figiel <slawek@isc.org>
Thu, 29 Jun 2023 11:44:08 +0000 (13:44 +0200)
configure.ac
doc/sphinx/arm/shell.rst
src/bin/shell/Makefile.am
src/bin/shell/kea-shell.in
src/bin/shell/kea_connector2.py [deleted file]

index dbf64c2477fbc9082582b3ae7e76b32c41f453ba..15b070cb1d3d5bdc06addc8521e7834962e58f3b 100644 (file)
@@ -1125,15 +1125,20 @@ fi
 
 AM_CONDITIONAL([GENERATE_PARSER], [test x$enable_generate_parser != xno])
 
-# Kea-shell is written in python. It can work with python 2.7 or any 3.x.
-# It may likely work with earlier versions, but 2.7 was the oldest one we tested
-# it with. We require python only if kea-shell was enabled. It is disabled
-# by default to not introduce hard dependency on python.
+# Kea-shell is written in python. It can work with any 3.x.
+# We require python only if kea-shell was enabled. It is disabled by default to
+# not introduce hard dependency on python.
 AC_ARG_ENABLE(shell,
   [AS_HELP_STRING([--enable-shell],
     [enable kea-shell, a text management client for Control Agent [default=no]])],
   enable_shell=$enableval, enable_shell=no)
 
+if test "x$enable_shell" != "xno"; then
+  major=`echo $PYTHON_VERSION | cut -d '.' -f 1`
+  if test "x$major" != "x3"; then
+    AC_MSG_WARN("kea-shell does not support python2")
+  fi
+fi
 
 AC_ARG_ENABLE(generate_docs,
   [AS_HELP_STRING([--enable-generate-docs],
@@ -1219,16 +1224,7 @@ if test "x${CRYPTO_NAME}" = "xBotan" && test "x$BOTAN_BOOST" = "xyes"; then
 fi
 
 # Decide if the shell TLS test can work.
-### This will be simpler when Python 2 support will be dropped.
-ca_tls_test=no
-if test "x$enable_shell" != "xno"; then
-  major=`echo $PYTHON_VERSION | cut -d '.' -f 1`
-  if test "x$major" = "x3"; then
-    ca_tls_test="$tls_support"
-  else
-    AC_MSG_WARN("python2 kea-shell does not support HTTPS")
-  fi
-fi
+ca_tls_test="$tls_support"
 AM_CONDITIONAL(CA_TLS_TEST, test x$ca_tls_test != xno)
 
 AC_ARG_WITH([sphinx],
index b723ada4763e4e1d050d7bfa7a5b1bd94111c84c..18853c82dc01ac91e367ec2330a725b232223572 100644 (file)
@@ -116,7 +116,7 @@ servers, the default empty path in the URL is not enough, so the
    $ kea-shell --host 192.0.2.1 --port 8001 --path kea ...
 
 The Kea shell requires Python to be installed on the system. It has been
-tested with Python 2.7 and various versions of Python 3, up to 3.5.
+tested with various versions of Python 3, up to 3.5.
 Since not every Kea deployment uses this feature and there are
 deployments that do not have Python, the Kea shell is not enabled by
 default. To use it, specify ``--enable-shell`` when running ``configure``
index 786d4f676a13be55d85f08be8fee71008aef0139..5dd6251610aa09e223ec63693e3403d136faf35e 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS = . tests
 
-pkgpython_PYTHON = kea_conn.py kea_connector2.py kea_connector3.py
+pkgpython_PYTHON = kea_conn.py kea_connector3.py
 
 sbin_SCRIPTS = kea-shell
 
index 62de548f8f0620c057e912e5983e74db63ad8b3c..b56812d1812488445f85b7b5999070f660b4a53f 100644 (file)
@@ -11,34 +11,25 @@ Text client for Control Agent process
 """
 
 # First, let's import the right kea_connector.
-# We have two versions: one for python 2.x and another for python 3.x.
+# Only the python 3.x is supported.
 # Sadly, there's no unified way to handle http connections. The recommended
 # way is to use Requests (http://docs.python-requests.org/en/master/), but
 # that's a stand alone package that requires separate installation. One of
 # the design requirements was to not require any additional packages, so
 # the code uses standard libraries available in python. Hence two versions.
-import sys
-import signal
 import argparse
+import signal
+import sys
 from base64 import b64encode
 
 sys.path.append('@PKGPYTHONDIR@')
 
+import kea_connector3 as kea_connector
 from kea_conn import CARequest # CAResponse
 
-if sys.version_info[0] == 2:
-    # This is Python 2.x
-    import kea_connector2 as kea_connector
-    def auth8(string):
-        """Convert str into unicode"""
-        return unicode(string, 'utf-8')
-elif sys.version_info[0] == 3:
-    # This is Python 3.x
-    import kea_connector3 as kea_connector
-    auth8 = str
-else:
-    # This is... have no idea what it is.
-    raise SystemExit("Unknown python version:" + str(sys.version_info[0]))
+
+VERSION = "@PACKAGE_VERSION@"
+
 
 def timeout_handler(signum, frame):
     """Connection timeout handler"""
@@ -46,7 +37,6 @@ def timeout_handler(signum, frame):
     print("Connection timeout")
     sys.exit(1)
 
-VERSION = "@PACKAGE_VERSION@"
 
 def shell_body():
     """
@@ -82,9 +72,9 @@ def shell_body():
     parser.add_argument('--service', nargs="?", action="append",
                         help='target specified service. If not specified,'
                         'control agent will receive command.')
-    parser.add_argument('--auth-user', type=auth8, default='',
+    parser.add_argument('--auth-user', type=str, default='',
                         help='Basic HTTP authentication user')
-    parser.add_argument('--auth-password', type=auth8, default='',
+    parser.add_argument('--auth-password', type=str, default='',
                         help='Basic HTTP authentication password')
     parser.add_argument('command', type=str, nargs="?",
                         default='list-commands',
@@ -160,5 +150,6 @@ def shell_body():
 
     sys.exit(0)
 
+
 if __name__ == "__main__":
     shell_body()
diff --git a/src/bin/shell/kea_connector2.py b/src/bin/shell/kea_connector2.py
deleted file mode 100644 (file)
index fcd9d9b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-"""
-This is PYTHON 2.x version of HTTP connection establishment
-"""
-
-import httplib
-
-from kea_conn import CAResponse # CARequest
-
-def send_to_control_agent(params):
-    """ Sends a request to Control Agent, receives a response and returns it."""
-
-    # No HTTP support.
-    if params.scheme == 'https':
-        raise NotImplementedError('python2 kea-shell does not support HTTPS')
-
-    # Establish HTTP connection first.
-    conn = httplib.HTTPConnection(params.http_host, params.http_port)
-    conn.connect()
-
-    # Use POST to send it
-    _ = conn.putrequest('POST', params.path)
-
-    # Send the headers first
-    for k in params.headers:
-        conn.putheader(k, params.headers[k])
-    conn.endheaders()
-
-    # Send the body (i.e. the actual content)
-    conn.send(params.content)
-
-    # Now get the response
-    resp = conn.getresponse()
-
-    # Now get the response details, put it in CAResponse and
-    # return it
-    result = CAResponse(resp.status, resp.reason, resp.read())
-    conn.close()
-
-    return result