module

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2025 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package module provides a plugin system for the DUT package. Modules are the building blocks of a command and host the actual implementation of the steps that are executed on a device-under-test (DUT). The core of the plugin system is the Module interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r Record)

Register registers a module for use in dutagent.

Types

type Module

type Module interface {
	// Help provides usage information.
	// The returned string should contain a description of the module the supported
	// command line arguments and any other information required to interact with the module.
	// The returned string should be formatted in a way that it can be displayed to the user.
	//
	// Implementations should consider the module's concrete configuration and potentially
	// return individual help messages based on the configuration. It is not the purpose
	// of this method to provide a generic help message for all possible configurations,
	// but rather usage information for the current configuration.
	Help() string
	// Init is called once when the dutagent services is started.
	// It's a good place to establish connections or allocate resources and check whether
	// the module is configured functional. It is also called when a command containing this
	// module is called as a dry-run to check the configuration.
	Init() error
	// Deinit is called when the module is unloaded by dutagent or an internal error occurs.
	// It is used to clean up any resources that were allocated during the Init phase and
	// shall guarantee a graceful shutdown of the service.
	Deinit() error
	// Run is the entry point and executes the module with the given arguments.
	Run(ctx context.Context, s Session, args ...string) error
}

Module is a building block of a command running on a device-under-test (DUT). Implementations of this interface are the actual steps that are executed on a DUT.

func New

func New(name string) (Module, error)

New creates a new instance of a former registered module by its unique name.

type Record added in v0.2.0

type Record struct {
	// ID is the unique identifier of the module.
	// It is used to reference the module in the dutagent configuration.
	ID string
	// New is the factory function that creates a new instance of the module.
	// Most of the time, this function will return a pointer to a newly allocated struct
	// that implements the Module interface. It is not supposed to run initialization code
	// with side effects. The actual initialization should be done in the Init method of the Module.
	// Instead the factory function may serve as a constructor for the module and can be used to
	// allocate internal resources, like maps and slices or set up the initial state of the module.
	New func() Module
}

Record holds the information required to register a module.

type Session

type Session interface {
	Print(text string)
	Console() (stdin io.Reader, stdout, stderr io.Writer)
	RequestFile(name string) (io.Reader, error)
	SendFile(name string, r io.Reader) error
}

Session provides an environment / a context for a module. Via the Session interface, modules can interact with the client during execution.

Directories

Path Synopsis
Package flash provides a dutagent module that reads or writes the SPI flash on the DUT.
Package flash provides a dutagent module that reads or writes the SPI flash on the DUT.
The gpio package provides two modules that simulate buttons and switches respectively, using the GPIO pins of the Raspberry Pi.
The gpio package provides two modules that simulate buttons and switches respectively, using the GPIO pins of the Raspberry Pi.
Package IPMI provides a dutagent module that allows IPMI commands to be sent to a DUT's BMC.
Package IPMI provides a dutagent module that allows IPMI commands to be sent to a DUT's BMC.
Package pdu provides a dutagent module that allows power control of a PDU via HTTP requests.
Package pdu provides a dutagent module that allows power control of a PDU via HTTP requests.
Package serial provides a dutagent module that listens on a defined COM port.
Package serial provides a dutagent module that listens on a defined COM port.
Package shell provides a dutagent module that executes shell commands.
Package shell provides a dutagent module that executes shell commands.
Package ssh provides a dutagent module that connects to the DUT via Secure Shell and executes commands that are passed to the module from the dutctl client.
Package ssh provides a dutagent module that connects to the DUT via Secure Shell and executes commands that are passed to the module from the dutctl client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL