From 88cf6fc4f01b1f60242972f2d40e2d2bcb5463ba Mon Sep 17 00:00:00 2001 From: Sai Sindhur Malleni Date: Mon, 2 Mar 2020 15:35:41 -0500 Subject: [PATCH] Add dynamically captured version data to metadata Currently the user had to manually change version.json to reflect the environment in which the user is running browbeat. This commit adds functionality for browbeat to consume OSP version data captured from stockpile and ship it ES along with result data, as metadata. Change-Id: Ic8036914046aa19680abf491683bb9cd141875ff --- browbeat/prescribe.py | 16 ++++++++++++++++ metadata/version.json | 4 ---- 2 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 metadata/version.json diff --git a/browbeat/prescribe.py b/browbeat/prescribe.py index 78e8c1a43..74ee67377 100644 --- a/browbeat/prescribe.py +++ b/browbeat/prescribe.py @@ -80,6 +80,19 @@ class Metadata(object): env_dict['environment_setup'][nodes] = number return env_dict + def get_version_metadata(self, sys_data): + version = {} + for item, dictionary in six.iteritems(sys_data): + if 'undercloud' in sys_data[item]['group_names']: + if 'stockpile_rhosp_version' in dictionary: + version['rhosp_version'] = dictionary['stockpile_rhosp_version'] + if 'stockpile_rhosp_major' in dictionary: + version['rhosp_major'] = dictionary['stockpile_rhosp_major'] + if 'stockpile_rhosp_puddle' in dictionary: + version['rhosp_puddle'] = dictionary['stockpile_rhosp_puddle'] + break + return version + def get_software_metadata(self, sys_data): soft_all_dict = [] bad_output_list = [{},[],""] @@ -182,6 +195,9 @@ def main(): hardware_data = metadata.get_hardware_metadata(sysdata) metadata.write_metadata_file( hardware_data, os.path.join(args.path, 'hardware-metadata.json')) + version_data = metadata.get_version_metadata(sysdata) + metadata.write_metadata_file( + version_data, os.path.join(args.path, 'version.json')) software_data = metadata.get_software_metadata(sysdata) # Just a simple check to ensure that stockpile was able to collect osp data check = False diff --git a/metadata/version.json b/metadata/version.json deleted file mode 100644 index 8d9ad4bec..000000000 --- a/metadata/version.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "osp_series": "rocky", - "build": "2018-XX-XX.X" -}