diff --git a/framework/python/src/api/api.py b/framework/python/src/api/api.py index 0fc7b7dad..29a1f26fb 100644 --- a/framework/python/src/api/api.py +++ b/framework/python/src/api/api.py @@ -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): diff --git a/framework/python/src/common/device.py b/framework/python/src/common/device.py index c6a289d2c..55f0c5b66 100644 --- a/framework/python/src/common/device.py +++ b/framework/python/src/common/device.py @@ -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 @@ -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 @@ -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 diff --git a/framework/python/src/core/testrun.py b/framework/python/src/core/testrun.py index a88f2f527..eb8b2479f 100644 --- a/framework/python/src/core/testrun.py +++ b/framework/python/src/core/testrun.py @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/make/DEBIAN/control b/make/DEBIAN/control index 3361b7ff1..707bcab41 100644 --- a/make/DEBIAN/control +++ b/make/DEBIAN/control @@ -1,5 +1,5 @@ Package: Testrun -Version: 1.4.1-a +Version: 2.0-a Architecture: amd64 Maintainer: Google Homepage: https://github.com/google/testrun