Commit 40215758 authored by Mylène Josserand's avatar Mylène Josserand Committed by Douglas Targett
Browse files

dispatcher: connection: Add shell tag to implement disconnect

Add a 'shell' tag and a recognized name to implement the
disconnect function for shell's connection.
Signed-off-by: Mylène Josserand's avatarMylène Josserand <>
parent eed02931
......@@ -36,8 +36,8 @@ from lava_dispatcher.actions.boot import (
from lava_common.constants import BOOTLOADER_DEFAULT_CMD_TIMEOUT
from lava_dispatcher.actions.boot.environment import ExportDeviceEnvironment
from lava_dispatcher.connections.serial import ConnectDevice
from lava_dispatcher.logical import Boot
from lava_dispatcher.connections.serial import ResetConnection
from lava_dispatcher.logical import Boot, RetryAction
from lava_dispatcher.power import ResetDevice
from import ExpectShellSession
from lava_dispatcher.utils.strings import substitute
......@@ -180,7 +180,6 @@ class DepthchargeAction(Action):
def populate(self, parameters):
self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -192,6 +191,7 @@ class DepthchargeRetry(BootAction):
def populate(self, parameters):
self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -105,7 +105,7 @@ class Connection:
self.connected = True
self.check_char = "#"
self.tags = []
self.recognized_names = ["LxcSession", "QemuSession"]
self.recognized_names = ["LxcSession", "QemuSession", "ShellSession"]
def corruption_check(self):
......@@ -154,8 +154,8 @@ class Connection:"Disconnecting from lxc: %s", reason)
self.sendline("", disconnecting=True)
self.sendline("exit", disconnecting=True)
elif == "QemuSession":"Disconnecting from qemu: %s", reason)
elif == "QemuSession" or == "ShellSession":"Disconnecting from qemu/shell: %s", reason)
raise LAVABug("'disconnect' not supported for %s" % self.tags)
except ValueError: # protection against file descriptor == -1
......@@ -20,7 +20,8 @@
from lava_dispatcher.connection import RECOGNIZED_TAGS
from import which
from lava_dispatcher.action import Action
from lava_dispatcher.logical import RetryAction
from lava_dispatcher.action import Action, Pipeline
from lava_common.exceptions import JobError, InfrastructureError
from import ShellCommand, ShellSession
......@@ -254,7 +255,6 @@ class DisconnectDevice(ConnectDevice):
def validate(self):
if "connections" not in self.job.device["commands"]:
self.errors = "Unable to connect to shell - missing connections block."
primary_connection_has_correct_tags = False
for connection in self.job.device["commands"]["connections"]:
......@@ -302,3 +302,20 @@ class DisconnectDevice(ConnectDevice):
self.logger.debug("Not connected, no need to disconnect.")
return connection
class ResetConnection(RetryAction):
Used within a RetryAction - Perform a reset of the connection by
disconnecting and connecting the device to have a new serial link.
name = "reset-connection"
description = "Disconnect and connect the serial"
summary = "Reset the connection"
reason = "reset"
def populate(self, parameters):
self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -202,6 +202,7 @@ class ShellSession(Connection):
self.__runner__ = None
self.timeout = shell_command.lava_timeout
self.__logger__ = None
self.tags = ["shell"]
def logger(self):
......@@ -210,7 +211,6 @@ class ShellSession(Connection):
return self.__logger__
def disconnect(self, reason=""):
self.logger.debug("Disconnecting %s",
# FIXME: rename prompt_str to indicate it can be a list or str
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