Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.93 KB

File metadata and controls

59 lines (45 loc) · 1.93 KB

Sharing Target Files Across Multiple Devices

When a lab has multiple physical devices of the same model (e.g., three Belkin RT3200 routers), creating separate target configuration files for each device leads to unnecessary duplication and maintenance overhead.

If this is your situation, you can use the device_instances field in labnet.yaml to define multiple physical instances sharing a single target file:

devices:
  linksys_e8450:
    name: Linksys E8450 / Belkin RT3200
    target: mediatek-mt7622
    firmware: initramfs-kernel.bin

labs:
  labgrid-example:
    proxy: labgrid-example
    maintainers: "@maintainer"
    devices:
      - linksys_e8450
    device_instances:
      linksys_e8450:
        - router_1
        - router_2
        - router_3

This will create three different labgrid places from the same configuration file.

  • labgrid-example-router_1targets/linksys_e8450.yaml
  • labgrid-example-router_2targets/linksys_e8450.yaml
  • labgrid-example-router_3targets/linksys_e8450.yaml

Configuration Separation

  • Generic configuration (drivers, prompts, strategies) → targets/linksys_e8450.yaml (shared)
  • Device-specific details (serial ports, IPs, power) → ansible/files/exporter/<lab>/exporter.yaml (per device)

Automatic Target Resolution

When running tests with pytest, simply set LG_PLACE - the target file is resolved automatically:

export LG_PLACE=labgrid-example-router_1
export LG_PROXY=labgrid-example

# LG_ENV is automatically set to targets/linksys_e8450.yaml
pytest tests/ --lg-log

When to Use

✅ Use device_instances when:

  • You have multiple devices of the same model
  • Devices require identical driver configurations
  • Only device-specific details (serial, IP, power) differ

❌ Don't use when:

  • Devices need different driver configurations
  • Firmware boot process differs between instances
  • You only have one device of that specific model