From fd13f28d42c858402ef3a027583b10f251820d5e Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Sat, 1 Oct 2016 20:24:11 -0500 Subject: [PATCH] bft: add support for dynamic devices enumerated in the config You can add devices dynamically with the following syntax in the boardconfig: "devices": [ { "type": "debian", "name": "wan", "ipaddr": "port2", "color": "cyan" }, { "type": "debian", "name": "lan", "ipaddr": "port3", "color": "blue" } Signed-off-by: Matthew McClintock --- bft | 18 ++++++++++++++++++ docs/BOARD_FARM.md | 17 ++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/bft b/bft index 314c47cc..1fd8f53c 100755 --- a/bft +++ b/bft @@ -61,6 +61,21 @@ def setup_legacy_devices(config): port=config.board.get('2g_port', "22")) +def setup_dynamic_devices(config): + '''Sets up dynamic devices from devices node in JSON config file''' + for device in config.board['devices']: + if device['type'] == 'debian': + #TODO: support conn_cmd and ipaddr (for ssh) + d = debian.DebianBox(name=device['ipaddr'], + color=device.get('color', 'black'), + reboot=config.reboot_vms, + username=device.get('username', "root"), + password=device.get('password', "bigfoot1"), + port=config.board.get('port', "22")) + setattr(config, device['name'], d) + else: + print("Unknown device type for %d", device) + def main(): '''Connect to devices, run tests, record results.''' @@ -102,6 +117,9 @@ def main(): setup_legacy_devices(config) + if 'devices' in config.board: + setup_dynamic_devices(config) + except Exception as e: print(e) connected_to_board = False diff --git a/docs/BOARD_FARM.md b/docs/BOARD_FARM.md index 9f74b14a..88788cc0 100644 --- a/docs/BOARD_FARM.md +++ b/docs/BOARD_FARM.md @@ -209,8 +209,19 @@ All routers in a board farm need an entry in the boardfarm_config.json file like "": { "board_type": "", "conn_cmd": "telnet ", - "lan_device": "10.0.0.107", - "wan_device": "bf-vm-YY.something.com", + "devices": [ + { + "type": "debian", + "name": "wan", + "ipaddr": "port2", + "color": "cyan" + }, + { + "type": "debian", + "name": "lan", + "ipaddr": "port3", + "color": "blue" + } "powerip": "", "powerport": "" } @@ -221,7 +232,7 @@ Where: * `name` is any unique name at all * `model` is a descriptive model name * `conn_cmd` is the command to run to connect to the board -* `lan_device` and `wan_device` are the devices connected to the board (must have ssh server) +* `devices' is an array of devices that will be added, must have a WAN device at minimum * `powerip` and `powerport` are the network-control power unit and outlet to reset the board Using a local serial port (i.e. no console server)