Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion framework/python/src/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ async def get_sys_config(self):
return self._session.get_config()

async def get_devices(self):
return self._session.get_device_repository()
devices = []
for device in self._session.get_device_repository():
devices.append(device.to_dict())
return devices

async def start_test_run(self, request: Request, response: Response):

Expand Down
12 changes: 12 additions & 0 deletions framework/python/src/common/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
class Device():
"""Represents a physical device and it's configuration."""

status: str = 'Valid'
folder_url: str = None
mac_addr: str = None
manufacturer: str = None
model: str = None
type: str = None
technology: str = None
test_pack: str = 'Device Qualification'
test_modules: Dict = field(default_factory=dict)
ip_addr: str = None
firmware: str = None
Expand Down Expand Up @@ -54,9 +58,13 @@ def to_dict(self):
"""Returns the device as a python dictionary. This is used for the
system status API endpoint and in the report."""
device_json = {}
device_json['status'] = self.status
device_json['mac_addr'] = self.mac_addr
device_json['manufacturer'] = self.manufacturer
device_json['model'] = self.model
device_json['type'] = self.type
device_json['technology'] = self.technology
device_json['test_pack'] = self.test_pack
if self.firmware is not None:
device_json['firmware'] = self.firmware
device_json['test_modules'] = self.test_modules
Expand All @@ -66,8 +74,12 @@ def to_config_json(self):
"""Returns the device as a python dictionary. Fields relevant to the device
config json file are exported."""
device_json = {}
device_json['status'] = self.status
device_json['mac_addr'] = self.mac_addr
device_json['manufacturer'] = self.manufacturer
device_json['model'] = self.model
device_json['type'] = self.type
device_json['technology'] = self.technology
device_json['test_pack'] = self.test_pack
device_json['test_modules'] = self.test_modules
return device_json
23 changes: 22 additions & 1 deletion framework/python/src/core/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
DEVICE_MODEL = 'model'
DEVICE_MAC_ADDR = 'mac_addr'
DEVICE_TEST_MODULES = 'test_modules'
DEVICE_TYPE_KEY = 'type'
DEVICE_TECHNOLOGY_KEY = 'technology'
DEVICE_TEST_PACK_KEY = 'test_pack'

MAX_DEVICE_REPORTS_KEY = 'max_device_reports'

class Testrun: # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -166,7 +170,7 @@ def _load_devices(self, device_dir):
# Check if device config file exists before loading
if not os.path.exists(device_config_file_path):
LOGGER.error('Device configuration file missing ' +
f'from device {device_folder}')
f'for device {device_folder}')
continue

# Open device config file
Expand All @@ -178,6 +182,8 @@ def _load_devices(self, device_dir):
device_model = device_config_json.get(DEVICE_MODEL)
mac_addr = device_config_json.get(DEVICE_MAC_ADDR)
test_modules = device_config_json.get(DEVICE_TEST_MODULES)

# Load max device reports
max_device_reports = None
if 'max_device_reports' in device_config_json:
max_device_reports = device_config_json.get(MAX_DEVICE_REPORTS_KEY)
Expand All @@ -192,6 +198,21 @@ def _load_devices(self, device_dir):
max_device_reports=max_device_reports,
device_folder=device_folder)

# Load in the additional fields
if DEVICE_TYPE_KEY in device_config_json:
device.type = device_config_json.get(DEVICE_TYPE_KEY)

if DEVICE_TECHNOLOGY_KEY in device_config_json:
device.technology = device_config_json.get(DEVICE_TECHNOLOGY_KEY)

if DEVICE_TEST_PACK_KEY in device_config_json:
device.test_pack = device_config_json.get(DEVICE_TEST_PACK_KEY)

if None in [device.type, device.technology, device.test_pack]:
LOGGER.warning(
'Device is outdated and requires further configuration')
device.status = 'Invalid'

self._load_test_reports(device)

# Add device to device repository
Expand Down
2 changes: 1 addition & 1 deletion make/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Testrun
Version: 1.4.1-a
Version: 2.0-a
Architecture: amd64
Maintainer: Google <boddey@google.com>
Homepage: https://github.com/google/testrun
Expand Down