diff --git a/src/lava_callback.py b/src/lava_callback.py index 792925022..e373e0ae9 100755 --- a/src/lava_callback.py +++ b/src/lava_callback.py @@ -29,7 +29,6 @@ from base import validate_url - SETTINGS = toml.load(os.getenv('KCI_SETTINGS', 'config/kernelci.toml')) CONFIGS = kernelci.config.load( SETTINGS.get('DEFAULT', {}).get('yaml_config', 'config') @@ -211,6 +210,23 @@ def async_job_submit(api_helper, node_id, job_callback): job_result = job_callback.get_job_status() device_id = job_callback.get_device_id() storage_config_name = job_callback.get_meta('storage_config_name') + input_file_types = [ + 'nfsrootfs', + 'rootfs', + 'ramdisk', + 'initrd', + 'ndbroot', + 'persistent_nfs' + ] + job_actions = job_callback.get_job_definition('actions') + if job_actions and len(job_actions) > 0: + deploy = job_actions[0].get('deploy') + if deploy: + for input_file in input_file_types: + if deploy.get('images') and deploy['images'].get(input_file): + url = deploy['images'][input_file].get('url') + if url: + job_node['artifacts']["input_"+input_file] = url storage = _get_storage(storage_config_name) log_txt_url = _upload_log(log_parser, job_node, storage) if log_txt_url: diff --git a/src/send_kcidb.py b/src/send_kcidb.py index 7662c4ef9..aef894cec 100755 --- a/src/send_kcidb.py +++ b/src/send_kcidb.py @@ -190,11 +190,33 @@ def _parse_checkout_node(self, origin, checkout_node): } }] + def _get_input_files(self, artifacts: dict, exclude_properties=None): + input_files = [] + for name, url in artifacts.items(): + if exclude_properties and name in exclude_properties: + continue + if "input_" not in name: + # Skip output files + continue + # Replace "/" with "_" to match with the allowed pattern + # for "name" property of "input_files" i.e. '^[^/]+$' + name = name.replace("/", "_") + input_files.append( + { + 'name': name, + 'url': url + } + ) + return input_files + def _get_output_files(self, artifacts: dict, exclude_properties=None): output_files = [] for name, url in artifacts.items(): if exclude_properties and name in exclude_properties: continue + if "input_" in name: + # Skip input files + continue # Replace "/" with "_" to match with the allowed pattern # for "name" property of "output_files" i.e. '^[^/]+$' name = name.replace("/", "_") @@ -312,7 +334,6 @@ def _parse_build_node(self, origin, node): artifacts=artifacts, exclude_properties=('build_log', '_config') ) - parsed_build_node['input_files'] = None parsed_build_node['config_url'] = artifacts.get('_config') parsed_build_node['log_url'] = artifacts.get('build_log') log_url = parsed_build_node['log_url'] @@ -537,11 +558,14 @@ def _parse_test_node(self, origin, test_node): artifacts = self._get_artifacts(test_node) if artifacts: + parsed_test_node['input_files'] = self._get_input_files( + artifacts=artifacts, + exclude_properties=None + ) parsed_test_node['output_files'] = self._get_output_files( artifacts=artifacts, exclude_properties=('lava_log', 'test_log') ) - parsed_test_node['input_files'] = None if artifacts.get('lava_log'): parsed_test_node['log_url'] = artifacts.get('lava_log') else: