=== modified file 'lava/dispatcher/commands.py'
@@ -1,4 +1,3 @@
-import argparse
import logging
import os
import sys
@@ -7,7 +6,7 @@
from lava.tool.command import Command
from lava.tool.errors import CommandError
-from lava_dispatcher.config import get_config, get_device_config
+from lava_dispatcher.config import get_config, get_device_config, get_devices
from lava_dispatcher.job import LavaTestJob, validate_job_data
@@ -30,6 +29,15 @@
help="Configuration directory override (currently %(default)s")
+class devices(DispatcherCommand):
+ """
+ Lists all the configured devices in this LAVA instance.
+ """
+ def invoke(self):
+ for d in get_devices(self.args.config_dir):
+ print d.hostname
+
+
class dispatch(DispatcherCommand):
"""
Run test scenarios on virtual and physical hardware
@@ -68,8 +76,8 @@
del logging.root.handlers[:]
del logging.root.filters[:]
FORMAT = '<LAVA_DISPATCHER>%(asctime)s %(levelname)s: %(message)s'
- DATEFMT= '%Y-%m-%d %I:%M:%S %p'
- logging.basicConfig(format=FORMAT,datefmt=DATEFMT)
+ DATEFMT = '%Y-%m-%d %I:%M:%S %p'
+ logging.basicConfig(format=FORMAT, datefmt=DATEFMT)
config = get_config(self.args.config_dir)
logging.root.setLevel(config.logging_level)
@@ -100,7 +108,6 @@
job.run()
-
class DeviceCommand(DispatcherCommand):
@classmethod
@@ -115,12 +122,14 @@
except Exception:
raise CommandError("no such device: %s" % self.args.device)
+
class connect(DeviceCommand):
def invoke(self):
os.execlp(
'sh', 'sh', '-c', self.device_config.connection_command)
+
class power_cycle(DeviceCommand):
def invoke(self):
=== modified file 'lava_dispatcher/config.py'
@@ -191,3 +191,12 @@
logging.warning("Device config for %s is not valid:\n %s", name, '\n '.join(report))
return DeviceConfig(real_device_config)
+
+
+def get_devices(config_dir):
+ devices = []
+ devices_dir = os.path.join(config_dir, 'devices')
+ for d in os.listdir(devices_dir):
+ d = os.path.splitext(d)[0]
+ devices.append(get_device_config(d, config_dir))
+ return devices
=== modified file 'setup.py'
@@ -15,6 +15,7 @@
[lava.commands]
dispatch = lava.dispatcher.commands:dispatch
connect = lava.dispatcher.commands:connect
+ devices = lava.dispatcher.commands:devices
power-cycle = lava.dispatcher.commands:power_cycle
[lava.signal_handlers]
add-duration = lava_dispatcher.signals.duration:AddDuration