Commit f672dcc0 authored by Rémi Duraffort's avatar Rémi Duraffort Committed by Neil Williams

Move name, description and summary as class variable

This also fix the name when calling parent __init__ function.

Change-Id: I302c3920eed9ef51232e22d75d555f0d34abf510
(cherry picked from commit 377e6704)
parent 9c1165f8
......@@ -358,20 +358,21 @@ class Action(object): # pylint: disable=too-many-instance-attributes,too-many-p
self.max_retries = 1 # unless the strategy or the job parameters change this, do not retry
self.diagnostics = []
self.protocols = [] # list of protocol objects supported by this action, full list in job.protocols
self.section = None
self.connection_timeout = Timeout(self.name)
self.character_delay = 0
self.force_prompt = False
# Section
section = None
# public actions (i.e. those who can be referenced from a job file) must
# declare a 'class-type' name so they can be looked up.
# summary and description are used to identify instances.
name = None
# Used in the pipeline to explain what the commands will attempt to do.
description = None
# A short summary of this instance of a class inheriting from Action. May
# be None.
summary = None
# Used in the pipeline to explain what the commands will attempt to do.
description = None
@property
def data(self):
......@@ -435,8 +436,6 @@ class Action(object): # pylint: disable=too-many-instance-attributes,too-many-p
except ValueError:
raise LAVABug("Action parameters need to be a dictionary")
# Set the timeout name now
self.timeout.name = self.name
# Overide the duration if needed
if 'timeout' in self.parameters:
# preserve existing overrides
......
......@@ -113,11 +113,9 @@ class SecondaryShell(Boot):
class SecondaryShellAction(BootAction):
def __init__(self):
super(SecondaryShellAction, self).__init__()
self.name = "secondary-shell-action"
self.description = "Connect to a secondary shell on specified hardware"
self.summary = "connect to a specified second shell"
name = "secondary-shell-action"
description = "Connect to a secondary shell on specified hardware"
summary = "connect to a specified second shell"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -140,11 +138,13 @@ class AutoLoginAction(Action):
This Action expect POSIX-compatible support of PS1 from shell
"""
name = 'auto-login-action'
description = "automatically login after boot using job parameters and checking for messages."
summary = "Auto-login after boot with support for kernel messages."
def __init__(self):
super(AutoLoginAction, self).__init__()
self.name = 'auto-login-action'
self.description = "automatically login after boot using job parameters and checking for messages."
self.summary = "Auto-login after boot with support for kernel messages."
self.check_prompt_characters_warning = (
"The string '%s' does not look like a typical prompt and"
" could match status messages instead. Please check the"
......@@ -368,11 +368,12 @@ class BootloaderCommandOverlay(Action):
server_ip is calculated at runtime
filenames are determined from the download Action.
"""
name = "bootloader-overlay"
description = "substitute job data into bootloader command list"
summary = "replace placeholders with job data"
def __init__(self):
super(BootloaderCommandOverlay, self).__init__()
self.name = "bootloader-overlay"
self.summary = "replace placeholders with job data"
self.description = "substitute job data into bootloader command list"
self.commands = None
self.method = ""
self.use_bootscript = False
......@@ -513,11 +514,10 @@ class BootloaderSecondaryMedia(Action):
"""
Generic class for secondary media substitutions
"""
def __init__(self):
super(BootloaderSecondaryMedia, self).__init__()
self.name = "bootloader-from-media"
self.summary = "set bootloader strings for deployed media"
self.description = "let bootloader know where to find the kernel in the image on secondary media"
name = "bootloader-from-media"
description = "let bootloader know where to find the kernel in the image on secondary media"
summary = "set bootloader strings for deployed media"
def validate(self):
super(BootloaderSecondaryMedia, self).validate()
......@@ -551,11 +551,13 @@ class OverlayUnpack(Action):
not matter for this action - the file will be downloaded from the
worker tmp dir using the default apache config.
"""
name = 'overlay-unpack'
description = 'transfer and unpack overlay to persistent rootfs after login'
summary = 'transfer and unpack overlay'
def __init__(self):
super(OverlayUnpack, self).__init__()
self.name = 'overlay-unpack'
self.description = 'transfer and unpack overlay to persistent rootfs after login'
self.summary = 'transfer and unpack overlay'
self.url = None
def cleanup(self, connection):
......@@ -597,11 +599,13 @@ class BootloaderInterruptAction(Action):
"""
Support for interrupting the bootloader.
"""
name = "bootloader-interrupt"
description = "interrupt bootloader"
summary = "interrupt bootloader to get an interactive shell"
def __init__(self):
super(BootloaderInterruptAction, self).__init__()
self.name = "bootloader-interrupt"
self.description = "interrupt bootloader"
self.summary = "interrupt bootloader to get an interactive shell"
self.params = {}
self.method = None
self.needs_interrupt = False
......@@ -657,11 +661,13 @@ class BootloaderCommandsAction(Action):
"""
Send the boot commands to the bootloader
"""
name = "bootloader-commands"
description = "send commands to bootloader"
summary = "interactive bootloader"
def __init__(self):
super(BootloaderCommandsAction, self).__init__()
self.name = "bootloader-commands"
self.description = "send commands to bootloader"
self.summary = "interactive bootloader"
self.params = None
self.timeout = Timeout(self.name, BOOTLOADER_DEFAULT_CMD_TIMEOUT)
self.method = ""
......
......@@ -63,11 +63,9 @@ class CMSIS(Boot):
class BootCMSIS(BootAction):
def __init__(self):
super(BootCMSIS, self).__init__()
self.name = 'boot-cmsis'
self.description = "boot cmsis usb image"
self.summary = "boot cmsis usb image"
name = "boot-cmsis"
description = "boot cmsis usb image"
summary = "boot cmsis usb image"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -76,11 +74,9 @@ class BootCMSIS(BootAction):
class BootCMSISRetry(RetryAction):
def __init__(self):
super(BootCMSISRetry, self).__init__()
self.name = 'boot-cmsis-retry'
self.description = "boot cmsis usb image with retry"
self.summary = "boot cmsis usb image with retry"
name = "boot-cmsis-retry"
description = "boot cmsis usb image with retry"
summary = "boot cmsis usb image with retry"
def validate(self):
super(BootCMSISRetry, self).validate()
......@@ -105,11 +101,12 @@ class BootCMSISRetry(RetryAction):
class FlashCMSISAction(Action):
name = "flash-cmsis"
description = "flash cmsis to usb mass storage"
summary = "flash cmsis to usb mass storage"
def __init__(self):
super(FlashCMSISAction, self).__init__()
self.name = "flash-cmsis"
self.description = "flash cmsis to usb mass storage"
self.summary = "flash cmsis to usb mass storage"
self.filelist = []
self.usb_mass_device = None
......
......@@ -77,9 +77,11 @@ class DepthchargeCommandOverlay(BootloaderCommandOverlay):
"""
Create the cmdline file and substitute {CMDLINE} with the TFTP path.
"""
name = "depthcharge-overlay"
def __init__(self):
super(DepthchargeCommandOverlay, self).__init__()
self.name = "depthcharge-overlay"
self.cmdline = None
def validate(self):
......@@ -151,11 +153,10 @@ class DepthchargeAction(BootAction):
Wraps the Retry Action to allow for actions which precede the reset,
e.g. Connect.
"""
def __init__(self):
super(DepthchargeAction, self).__init__()
self.name = "depthcharge-action"
self.description = "interactive Depthcharge action"
self.summary = "sets up boot with Depthcharge"
name = "depthcharge-action"
description = "interactive Depthcharge action"
summary = "sets up boot with Depthcharge"
def populate(self, parameters):
self.internal_pipeline = Pipeline(
......@@ -167,11 +168,9 @@ class DepthchargeAction(BootAction):
class DepthchargeRetry(BootAction):
def __init__(self):
super(DepthchargeRetry, self).__init__()
self.name = "depthcharge-retry"
self.description = "interactive depthcharge retry action"
self.summary = "depthcharge commands with retry"
name = "depthcharge-retry"
description = "interactive depthcharge retry action"
summary = "depthcharge commands with retry"
def populate(self, parameters):
self.internal_pipeline = Pipeline(
......@@ -199,11 +198,13 @@ class DepthchargeStart(Action):
"""
Wait for the Depthcharge command line interface prompt.
"""
name = "depthcharge-start"
description = "wait for Depthcharge to start"
summary = "Depthcharge start"
def __init__(self):
super(DepthchargeStart, self).__init__()
self.name = "depthcharge-start"
self.description = "wait for Depthcharge to start"
self.summary = "Depthcharge start"
self.start_message = None
def validate(self):
......
......@@ -59,11 +59,9 @@ class DFU(Boot):
class BootDFU(BootAction):
def __init__(self):
super(BootDFU, self).__init__()
self.name = 'boot-dfu-image'
self.description = "boot dfu image with retry"
self.summary = "boot dfu image with retry"
name = 'boot-dfu-image'
description = "boot dfu image with retry"
summary = "boot dfu image with retry"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -72,11 +70,9 @@ class BootDFU(BootAction):
class BootDFURetry(RetryAction):
def __init__(self):
super(BootDFURetry, self).__init__()
self.name = 'boot-dfu-retry'
self.description = "boot dfu image using the command line interface"
self.summary = "boot dfu image"
name = 'boot-dfu-retry'
description = "boot dfu image using the command line interface"
summary = "boot dfu image"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -88,11 +84,12 @@ class BootDFURetry(RetryAction):
class FlashDFUAction(Action):
name = "flash-dfu"
description = "use dfu to flash the images"
summary = "use dfu to flash the images"
def __init__(self):
super(FlashDFUAction, self).__init__()
self.name = "flash-dfu"
self.description = "use dfu to flash the images"
self.summary = "use dfu to flash the images"
self.base_command = []
self.exec_list = []
self.board_id = '0000000000'
......
......@@ -55,11 +55,9 @@ class BootDocker(Boot):
class BootDockerAction(BootAction):
def __init__(self):
super(BootDockerAction, self).__init__()
self.name = 'boot-docker'
self.description = "boot docker image"
self.summary = "boot docker image"
name = 'boot-docker'
description = "boot docker image"
summary = "boot docker image"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -72,11 +70,9 @@ class BootDockerAction(BootAction):
class BootDockerRetry(RetryAction):
def __init__(self):
super(BootDockerRetry, self).__init__()
self.name = 'boot-docker-retry'
self.description = "boot docker image with retry"
self.summary = "boot docker image"
name = 'boot-docker-retry'
description = "boot docker image with retry"
summary = "boot docker image"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -85,11 +81,12 @@ class BootDockerRetry(RetryAction):
class CallDockerAction(Action):
name = "docker-run"
description = "call docker run on the image"
summary = "call docker run"
def __init__(self):
super(CallDockerAction, self).__init__()
self.name = "docker-run"
self.description = "call docker run on the image"
self.summary = "call docker run"
self.cleanup_required = False
self.extra_options = ''
......
......@@ -26,11 +26,12 @@ class ExportDeviceEnvironment(Action):
Exports environment variables found in common data on to the device.
"""
name = "export-device-env"
description = "Exports environment variables to the device"
summary = "Exports environment variables action"
def __init__(self):
super(ExportDeviceEnvironment, self).__init__()
self.name = "export-device-env"
self.summary = "Exports environment variables action"
self.description = "Exports environment variables to the device"
self.env = []
def validate(self):
......
......@@ -80,11 +80,9 @@ class BootFastbootAction(BootAction):
Provide for auto_login parameters in this boot stanza and re-establish the
connection after boot.
"""
def __init__(self):
super(BootFastbootAction, self).__init__()
self.name = "fastboot-boot"
self.summary = "fastboot boot"
self.description = "fastboot boot into the system"
name = "fastboot-boot"
description = "fastboot boot into the system"
summary = "fastboot boot"
def validate(self):
super(BootFastbootAction, self).validate()
......@@ -137,11 +135,12 @@ class WaitFastBootInterrupt(Action):
from the deployment parameters.
"""
name = 'wait-fastboot-interrupt'
description = "Check for prompt and pass the interrupt string to exit fastboot."
summary = "watch output and try to interrupt fastboot"
def __init__(self, type):
super(WaitFastBootInterrupt, self).__init__()
self.name = 'wait-fastboot-interrupt'
self.summary = "watch output and try to interrupt fastboot"
self.description = "Check for prompt and pass the interrupt string to exit fastboot."
self.type = type
self.prompt = None
self.string = None
......@@ -181,11 +180,9 @@ class FastbootBootAction(Action):
This action calls fastboot to boot into the system.
"""
def __init__(self):
super(FastbootBootAction, self).__init__()
self.name = "boot-fastboot"
self.summary = "attempt to fastboot boot"
self.description = "fastboot boot into system"
name = "boot-fastboot"
description = "fastboot boot into system"
summary = "attempt to fastboot boot"
def validate(self):
super(FastbootBootAction, self).validate()
......@@ -241,11 +238,9 @@ class FastbootRebootAction(Action):
This action calls fastboot to reboot into the system.
"""
def __init__(self):
super(FastbootRebootAction, self).__init__()
self.name = "fastboot-reboot"
self.summary = "attempt to fastboot reboot"
self.description = "fastboot reboot into system"
name = "fastboot-reboot"
description = "fastboot reboot into system"
summary = "attempt to fastboot reboot"
def validate(self):
super(FastbootRebootAction, self).validate()
......@@ -289,11 +284,9 @@ class EnterFastbootAction(Action):
Enters fastboot bootloader.
"""
def __init__(self):
super(EnterFastbootAction, self).__init__()
self.name = "enter-fastboot-action"
self.description = "enter fastboot bootloader"
self.summary = "enter fastboot"
name = "enter-fastboot-action"
description = "enter fastboot bootloader"
summary = "enter fastboot"
def validate(self):
super(EnterFastbootAction, self).validate()
......
......@@ -129,11 +129,12 @@ def _grub_sequence_map(sequence):
class GrubSequenceAction(BootAction):
name = "grub-sequence-action"
description = "grub boot sequence"
summary = "run grub boot using specified sequence of actions"
def __init__(self):
super(GrubSequenceAction, self).__init__()
self.name = "grub-sequence-action"
self.description = "grub boot sequence"
self.summary = "run grub boot using specified sequence of actions"
self.expect_shell = False
def validate(self):
......@@ -172,11 +173,13 @@ class GrubSequenceAction(BootAction):
class GrubMainAction(BootAction):
name = "grub-main-action"
description = "main grub boot action"
summary = "run grub boot from power to system"
def __init__(self):
super(GrubMainAction, self).__init__()
self.name = "grub-main-action"
self.description = "main grub boot action"
self.summary = "run grub boot from power to system"
self.expect_shell = True
def populate(self, parameters):
......@@ -219,11 +222,12 @@ class GrubMainAction(BootAction):
class GrubMenuSelector(UefiMenuSelector): # pylint: disable=too-many-instance-attributes
name = 'grub-efi-menu-selector'
description = 'select specified grub-efi menu items'
summary = 'select grub options in the efi menu'
def __init__(self):
super(GrubMenuSelector, self).__init__()
self.name = 'grub-efi-menu-selector'
self.summary = 'select grub options in the efi menu'
self.description = 'select specified grub-efi menu items'
self.selector.prompt = "Start:"
self.commands = []
self.boot_message = None
......@@ -256,11 +260,13 @@ class InstallerWait(Action):
"""
Wait for the non-interactive installer to finished
"""
name = "installer-wait"
description = "installer wait"
summary = "wait for task to finish match arbitrary string"
def __init__(self):
super(InstallerWait, self).__init__()
self.name = "installer-wait"
self.description = "installer wait"
self.summary = "wait for task to finish match arbitrary string"
self.type = "grub"
def validate(self):
......
......@@ -78,11 +78,10 @@ class BootloaderAction(BootAction):
Wraps the Retry Action to allow for actions which precede
the reset, e.g. Connect.
"""
def __init__(self):
super(BootloaderAction, self).__init__()
self.name = "bootloader-action"
self.description = "interactive bootloader action"
self.summary = "pass boot commands"
name = "bootloader-action"
description = "interactive bootloader action"
summary = "pass boot commands"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -94,11 +93,12 @@ class BootloaderAction(BootAction):
class BootloaderRetry(BootAction):
name = "bootloader-retry"
description = "interactive uboot retry action"
summary = "uboot commands with retry"
def __init__(self):
super(BootloaderRetry, self).__init__()
self.name = "bootloader-retry"
self.description = "interactive uboot retry action"
self.summary = "uboot commands with retry"
self.type = "ipxe"
self.force_prompt = False
......
......@@ -61,11 +61,9 @@ class BootIsoInstaller(Boot):
class BootIsoInstallerAction(BootAction):
def __init__(self):
super(BootIsoInstallerAction, self).__init__()
self.name = 'boot-installer-iso'
self.description = "boot installer with preseed"
self.summary = "boot installer iso image"
name = 'boot-installer-iso'
description = "boot installer with preseed"
summary = "boot installer iso image"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -88,11 +86,9 @@ class IsoCommandLine(Action): # pylint: disable=too-many-instance-attributes
-append "\"${BASE} ${LOCALE} ${CONSOLE} ${KEYMAPS} ${NETCFG} preseed/url=${PRESEED_URL} --- ${CONSOLE}\"" \
"""
def __init__(self):
super(IsoCommandLine, self).__init__()
self.name = 'execute-installer-command'
self.summary = 'include downloaded locations and call qemu'
self.description = 'add dynamic data values to command line and execute'
name = 'execute-installer-command'
description = 'add dynamic data values to command line and execute'
summary = 'include downloaded locations and call qemu'
def run(self, connection, max_end_time, args=None):
# substitutions
......@@ -136,13 +132,14 @@ class MonitorInstallerSession(Action):
The shell connection can be over any particular connection,
all that is needed is a prompt.
"""
compatibility = 3
name = "monitor-installer-connection"
description = "Monitor installer operation"
summary = "Watch for error strings or end of install"
def __init__(self):
super(MonitorInstallerSession, self).__init__()
self.name = "monitor-installer-connection"
self.summary = "Watch for error strings or end of install"
self.description = "Monitor installer operation"
self.force_prompt = True
def validate(self):
......@@ -158,11 +155,12 @@ class MonitorInstallerSession(Action):
class IsoRebootAction(Action):
name = 'reboot-into-installed'
description = 'reboot and login to the new system'
summary = 'reboot into installed image'
def __init__(self):
super(IsoRebootAction, self).__init__()
self.name = 'reboot-into-installed'
self.summary = 'reboot into installed image'
self.description = 'reboot and login to the new system'
self.sub_command = None
def validate(self):
......
......@@ -57,11 +57,10 @@ class BootKexecAction(BootAction):
"""
Provide for auto_login parameters in this boot stanza and re-establish the connection after boot
"""
def __init__(self):
super(BootKexecAction, self).__init__()
self.name = "kexec-boot"
self.summary = "kexec a new kernel"
self.description = "replace current kernel using kexec"
name = "kexec-boot"
summary = "kexec a new kernel"
description = "replace current kernel using kexec"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......@@ -80,11 +79,12 @@ class KexecAction(Action):
attempts to reestablish the shell connection after boot.
"""
name = "call-kexec"
summary = "attempt to kexec new kernel"
description = "call kexec with specified arguments"
def __init__(self):
super(KexecAction, self).__init__()
self.name = "call-kexec"
self.summary = "attempt to kexec new kernel"
self.description = "call kexec with specified arguments"
self.command = ''
self.load_command = ''
......
......@@ -64,11 +64,9 @@ class BootLxcAction(BootAction):
Provide for auto_login parameters in this boot stanza and re-establish the
connection after boot.
"""
def __init__(self):
super(BootLxcAction, self).__init__()
self.name = "lxc-boot"
self.summary = "lxc boot"
self.description = "lxc boot into the system"
name = "lxc-boot"
description = "lxc boot into the system"
summary = "lxc boot"
def validate(self):
super(BootLxcAction, self).validate()
......@@ -92,11 +90,9 @@ class LxcAddStaticDevices(Action):
worker.
"""
def __init__(self):
super(LxcAddStaticDevices, self).__init__()
self.name = 'lxc-add-static'
self.description = 'Add devices which are permanently powered by the worker to the LXC'
self.summary = 'Add static devices to the LXC'
name = 'lxc-add-static'
description = 'Add devices which are permanently powered by the worker to the LXC'
summary = 'Add static devices to the LXC'
def get_usb_devices(self):
"""
......@@ -152,11 +148,12 @@ class LxcStartAction(Action):
This action calls lxc-start to get into the system.
"""
name = "boot-lxc"
description = "boot into lxc container"
summary = "attempt to boot"
def __init__(self):
super(LxcStartAction, self).__init__()
self.name = "boot-lxc"
self.summary = "attempt to boot"
self.description = "boot into lxc container"
self.sleep = 10
def validate(self):
......@@ -198,11 +195,9 @@ class LxcStopAction(Action):
This action calls lxc-stop to stop the container.
"""
def __init__(self):
super(LxcStopAction, self).__init__()
self.name = "lxc-stop"
self.summary = "stop lxc"
self.description = "stop the lxc container"
name = "lxc-stop"
description = "stop the lxc container"
summary = "stop lxc"
def validate(self):
super(LxcStopAction, self).validate()
......
......@@ -57,11 +57,9 @@ class Minimal(Boot):
class MinimalBoot(BootAction):
def __init__(self):
super(MinimalBoot, self).__init__()
self.name = 'minimal-boot'
self.description = "connect and reset device"
self.summary = "connect and reset device"
name = 'minimal-boot'
description = "connect and reset device"
summary = "connect and reset device"
def populate(self, parameters):
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
......
......@@ -58,11 +58,9 @@ class PyOCD(Boot):
class BootPyOCD(BootAction):
def __init__<