Hello LAVA community,

I'm working with LAVA for automated testing of embedded systems with BMC (Baseboard Management Controller) and I've encountered a limitation that I'd like to ask about.

My Use Case

I'm testing devices that support Redfish API for power management. I need to execute various Redfish commands (forceoff, poweron, forcerestart, etc.) from the dispatcher during test jobs. Currently, I define these as user_commands in my device dictionary:

jinja2
{% set user_commands = {
    'redfish_forceoff': {
        'do': '/opt/lava-lab/shared/lab-scripts/dispatcher_command.sh 192.168.17.111 forceoff'
    },
    'redfish_poweron': {
        'do': '/opt/lava-lab/shared/lab-scripts/dispatcher_command.sh 192.168.17.111 poweron'
    },
    # ... more commands
} %}

Then in my job file:

yaml
- command:
    name: redfish_forceoff

The Problem

Every time I need to add a new Redfish action, I must modify the device dictionary (Jinja file) to add a new user_command entry. I'd like users to be able to specify the action dynamically from the job file without requiring device configuration changes.

What I want to achieve:

yaml
# In job file - specify action dynamically
context:
  redfish_action: forceoff

actions:
  - command:
      name: redfish_command  # Generic command that uses context variable

What I've Investigated

  1. Deploy actions support variable substitution (e.g., {IMAGE}), but this is hardcoded for deploy actions only
  2. Job context variables can override device dictionary values, but only at device configuration rendering time (job parsing), not at action execution time
  3. user_commands are static strings with no runtime parameter substitution mechanism
  4. Test definitions support parameters, but they run on the DUT, not the dispatcher

I understand from the documentation that dispatcher commands are intentionally restricted for security reasons, which makes sense.

My Current Workaround

I'm using Jinja2 loops to auto-generate commands from a list:

jinja2
{% set redfish_actions = ['auth_test', 'forceoff', 'poweron', 'forcerestart'] %}
{% set user_commands = {} %}
{% for action in redfish_actions %}
    {% set _ = user_commands.update({'rf_' + action: {'do': rf_script + ' ' + action}}) %}
{% endfor %}

This reduces the pain (just add one word to a list), but still requires device configuration edits.

My Questions

  1. Is there any mechanism I've missed that allows passing runtime parameters from job files to user_commands?
  2. Is this a known limitation that others have encountered?
  3. Would it be feasible to add support for parameter substitution in user_commands (similar to how deploy actions work with {IMAGE}), while maintaining security constraints?
  4. Are there alternative approaches within LAVA's architecture that I should consider?

Any guidance or suggestions would be greatly appreciated. If this is a feature that doesn't exist but would be useful, I'd be happy to discuss potential implementation approaches or contribute to a feature request.

Thank you for your time and for maintaining LAVA!

Best regards, Mor