if test "x$enable_shell" != xno ; then
# If kea-shell is enabled, we really need python. 2.7 or anything newer will do.
+# We try to find 3.x first. If not found, we can do with 2.7.
AM_PATH_PYTHON([3], [found="yes"], [found="no"])
if test "x$found" = xno ; then
AM_PATH_PYTHON([2.7])
print(VERSION)
exit(0)
- # Ok, now time to put the parameters parsed into the structure to be
+ # Ok, now it's time to put the parameters parsed into the structure to be
# used by the connection.
params = CARequest()
params.command = cmd_args.command
from kea_conn import CAResponse # CARequest
def send_to_control_agent(params):
- """Establish HTTP connection first."""
+ """ Sends a request to Control Agent, receives a response and returns it."""
+
+ # Establish HTTP connection first.
conn = httplib.HTTPConnection(params.http_host, params.http_port)
conn.connect()
conn.putheader(k, params.headers[k])
conn.endheaders()
- # Send the content
+ # Send the body (i.e. the actual content)
conn.send(params.content)
# Now get the response
from kea_conn import CAResponse # CARequest
def send_to_control_agent(params):
- """Establish HTTP connection first."""
+ """ Sends a request to Control Agent, receives a response and returns it."""
+
+ # First, create the URL
url = "http://" + params.http_host + ":"
url += str(params.http_port) + str(params.path)
+ # Now preprare the request (URL, headers and body)
req = urllib.request.Request(url=url,
data=str.encode(params.content),
headers=params.headers)
+
+ # Establish connection, send the request.
resp = urllib.request.urlopen(req)
# Now get the response details, put it in CAResponse and return it