Commit 1b970f2c authored by Douglas Targett's avatar Douglas Targett
Browse files

Merge branch 'T26579_console_reset' into 'collabora/production'

T26579 - Implement console reset

See merge request !13
parents eed02931 40215758
Pipeline #24191 failed with stages
in 1 minute and 4 seconds
...@@ -36,8 +36,8 @@ from lava_dispatcher.actions.boot import ( ...@@ -36,8 +36,8 @@ from lava_dispatcher.actions.boot import (
) )
from lava_common.constants import BOOTLOADER_DEFAULT_CMD_TIMEOUT from lava_common.constants import BOOTLOADER_DEFAULT_CMD_TIMEOUT
from lava_dispatcher.actions.boot.environment import ExportDeviceEnvironment from lava_dispatcher.actions.boot.environment import ExportDeviceEnvironment
from lava_dispatcher.connections.serial import ConnectDevice from lava_dispatcher.connections.serial import ResetConnection
from lava_dispatcher.logical import Boot from lava_dispatcher.logical import Boot, RetryAction
from lava_dispatcher.power import ResetDevice from lava_dispatcher.power import ResetDevice
from lava_dispatcher.shell import ExpectShellSession from lava_dispatcher.shell import ExpectShellSession
from lava_dispatcher.utils.strings import substitute from lava_dispatcher.utils.strings import substitute
...@@ -180,7 +180,6 @@ class DepthchargeAction(Action): ...@@ -180,7 +180,6 @@ class DepthchargeAction(Action):
def populate(self, parameters): def populate(self, parameters):
self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters) self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
self.pipeline.add_action(DepthchargeCommandOverlay()) self.pipeline.add_action(DepthchargeCommandOverlay())
self.pipeline.add_action(ConnectDevice())
self.pipeline.add_action(DepthchargeRetry()) self.pipeline.add_action(DepthchargeRetry())
...@@ -192,6 +191,7 @@ class DepthchargeRetry(BootAction): ...@@ -192,6 +191,7 @@ class DepthchargeRetry(BootAction):
def populate(self, parameters): def populate(self, parameters):
self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters) self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
self.pipeline.add_action(ResetConnection())
self.pipeline.add_action(ResetDevice()) self.pipeline.add_action(ResetDevice())
self.pipeline.add_action(DepthchargeStart()) self.pipeline.add_action(DepthchargeStart())
self.pipeline.add_action(BootloaderCommandsAction()) self.pipeline.add_action(BootloaderCommandsAction())
......
...@@ -105,7 +105,7 @@ class Connection: ...@@ -105,7 +105,7 @@ class Connection:
self.connected = True self.connected = True
self.check_char = "#" self.check_char = "#"
self.tags = [] self.tags = []
self.recognized_names = ["LxcSession", "QemuSession"] self.recognized_names = ["LxcSession", "QemuSession", "ShellSession"]
def corruption_check(self): def corruption_check(self):
self.sendline(self.check_char) self.sendline(self.check_char)
...@@ -154,8 +154,8 @@ class Connection: ...@@ -154,8 +154,8 @@ class Connection:
logger.info("Disconnecting from lxc: %s", reason) logger.info("Disconnecting from lxc: %s", reason)
self.sendline("", disconnecting=True) self.sendline("", disconnecting=True)
self.sendline("exit", disconnecting=True) self.sendline("exit", disconnecting=True)
elif self.name == "QemuSession": elif self.name == "QemuSession" or self.name == "ShellSession":
logger.info("Disconnecting from qemu: %s", reason) logger.info("Disconnecting from qemu/shell: %s", reason)
else: else:
raise LAVABug("'disconnect' not supported for %s" % self.tags) raise LAVABug("'disconnect' not supported for %s" % self.tags)
except ValueError: # protection against file descriptor == -1 except ValueError: # protection against file descriptor == -1
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
from lava_dispatcher.connection import RECOGNIZED_TAGS from lava_dispatcher.connection import RECOGNIZED_TAGS
from lava_dispatcher.utils.shell import which from lava_dispatcher.utils.shell 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 lava_common.exceptions import JobError, InfrastructureError
from lava_dispatcher.shell import ShellCommand, ShellSession from lava_dispatcher.shell import ShellCommand, ShellSession
...@@ -254,7 +255,6 @@ class DisconnectDevice(ConnectDevice): ...@@ -254,7 +255,6 @@ class DisconnectDevice(ConnectDevice):
def validate(self): def validate(self):
super().validate() super().validate()
if "connections" not in self.job.device["commands"]: if "connections" not in self.job.device["commands"]:
self.errors = "Unable to connect to shell - missing connections block."
return return
primary_connection_has_correct_tags = False primary_connection_has_correct_tags = False
for connection in self.job.device["commands"]["connections"]: for connection in self.job.device["commands"]["connections"]:
...@@ -302,3 +302,20 @@ class DisconnectDevice(ConnectDevice): ...@@ -302,3 +302,20 @@ class DisconnectDevice(ConnectDevice):
else: else:
self.logger.debug("Not connected, no need to disconnect.") self.logger.debug("Not connected, no need to disconnect.")
return connection 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)
self.pipeline.add_action(DisconnectDevice())
self.pipeline.add_action(ConnectDevice())
...@@ -202,6 +202,7 @@ class ShellSession(Connection): ...@@ -202,6 +202,7 @@ class ShellSession(Connection):
self.__runner__ = None self.__runner__ = None
self.timeout = shell_command.lava_timeout self.timeout = shell_command.lava_timeout
self.__logger__ = None self.__logger__ = None
self.tags = ["shell"]
@property @property
def logger(self): def logger(self):
...@@ -210,7 +211,6 @@ class ShellSession(Connection): ...@@ -210,7 +211,6 @@ class ShellSession(Connection):
return self.__logger__ return self.__logger__
def disconnect(self, reason=""): def disconnect(self, reason=""):
self.logger.debug("Disconnecting %s", self.name)
super().disconnect(reason) super().disconnect(reason)
# FIXME: rename prompt_str to indicate it can be a list or str # 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