Commit 84d78a08 authored by Senthil Kumaran S's avatar Senthil Kumaran S Committed by Neil Williams

LAVA-1229 - read-feedback: failed on DUTs without telnet or ssh

 * Add LxcSession connection that will support disconnect and finalise
 * Disconnect LxcSession connections using an 'exit'
 * Close raw_connection that cannot be killed

Change-Id: I9d7df6e82f19cb91c9cabba2cae8dccd3336d500
parent 1621ea5b
......@@ -168,6 +168,10 @@ class Connection(object):"Disconnecting from ssh: %s", reason)
self.sendline('', disconnecting=True)
self.sendline('~.', disconnecting=True)
elif == "LxcSession":"Disconnecting from lxc: %s", reason)
self.sendline('', disconnecting=True)
self.sendline('exit', disconnecting=True)
raise LAVABug("'disconnect' not supported for %s" % self.tags)
except ValueError: # protection against file descriptor == -1
......@@ -179,7 +183,7 @@ class Connection(object):
def finalise(self):
logger = logging.getLogger('dispatcher')
if self.raw_connection:
if self.tags:
if self.tags or == "LxcSession":
if self.raw_connection:
......@@ -188,7 +192,10 @@ class Connection(object):
except OSError:
# self.logger.debug("Finalizing child process with PID %d" %
self.connected = False
self.raw_connection = None
class Protocol(object):
......@@ -28,6 +28,23 @@ from import ShellCommand, ShellSession
# pylint: disable=too-many-public-methods
class LxcSession(ShellSession):
"""Extends a ShellSession to include the ability to disconnect and finalise
def __init__(self, job, shell_command):
super(LxcSession, self).__init__(job, shell_command) = "LxcSession"
def finalise(self):
super(LxcSession, self).finalise()
def disconnect(self, reason=''):
self.sendline('exit', disconnecting=True)
self.connected = False
class ConnectLxc(Action):
Class to make a lxc shell connection to the container.
......@@ -37,7 +54,7 @@ class ConnectLxc(Action): = "connect-lxc"
self.summary = "run connection command"
self.description = "connect to the lxc container"
self.session_class = ShellSession
self.session_class = LxcSession
self.shell_class = ShellCommand
def validate(self):
......@@ -69,7 +86,7 @@ class ConnectLxc(Action):
raise JobError("%s command exited %d: %s" % (cmd,
# ShellSession monitors the pexpect
# LxcSession monitors the pexpect
connection = self.session_class(self.job, shell)
connection.connected = True
connection = super(ConnectLxc, self).run(connection, max_end_time, args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment