From 1280071ea43e592111c31c0bb41c5ef1e99495e0 Mon Sep 17 00:00:00 2001 From: sshathee Date: Thu, 4 Apr 2024 09:06:27 -0400 Subject: [PATCH] Add ostree commit id to software show api The commit id changes after apt-ostree command is run in software deploy start. We are updating that commit id to metadata dictionary, which is accessed by software show rest api. Updating the new commit id for remove case also to metadata dictionary. Test Plan: PASS: Check ostree commit id after apply case of software deploy start in software show PASS: Check ostree commit id after remove case of software deploy start in software show PASS: Check commit id for a prepatched iso Story: 2010676 Task: 49818 Change-Id: I247c35f2e95bf013e0af0c684e17c4c38d0c2802 Signed-off-by: sshathee --- software/software/software_controller.py | 4 ++++ software/software/software_functions.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/software/software/software_controller.py b/software/software/software_controller.py index d1d62020..c8e6586e 100644 --- a/software/software/software_controller.py +++ b/software/software/software_controller.py @@ -2511,6 +2511,8 @@ class PatchController(PatchService): LOG.exception(msg) raise MetadataFail(msg) + self.release_data.metadata[release]["commit"] = self.latest_feed_commit + if not os.path.isfile(INITIAL_CONTROLLER_CONFIG_COMPLETE): self.release_data.metadata[release]["state"] = constants.DEPLOYING_START elif len(self.hosts) > 0: @@ -2640,6 +2642,8 @@ class PatchController(PatchService): self.interim_state[release] = list(self.hosts) if removed: + self.latest_feed_commit = ostree_utils.get_feed_latest_commit(SW_VERSION) + self.release_data.metadata[release]["commit"] = self.latest_feed_commit try: metadata_dir = DEPLOY_STATE_METADATA_DIR_DICT[deploystate] shutil.move("%s/%s-metadata.xml" % (metadata_dir, deployment), diff --git a/software/software/software_functions.py b/software/software/software_functions.py index 9aeda761..013c3993 100644 --- a/software/software/software_functions.py +++ b/software/software/software_functions.py @@ -335,6 +335,8 @@ class ReleaseData(object): self.metadata[release_id]["sw_version"] = "unknown" + # commit is derived from apt-ostree command run in software deploy start + for key in ["status", "unremovable", "sw_version", @@ -343,7 +345,8 @@ class ReleaseData(object): "install_instructions", "restart_script", "warnings", - "apply_active_release_only"]: + "apply_active_release_only", + "commit"]: value = root.findtext(key) if value is not None: self.metadata[release_id][key] = value