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],
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],
$ 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``
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
"""
# 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"""
print("Connection timeout")
sys.exit(1)
-VERSION = "@PACKAGE_VERSION@"
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',
sys.exit(0)
+
if __name__ == "__main__":
shell_body()
+++ /dev/null
-# 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