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 <shunmugam.shatheesh@windriver.com>
This commit is contained in:
sshathee 2024-04-04 09:06:27 -04:00
parent 3c3a3ecb62
commit 1280071ea4
2 changed files with 8 additions and 1 deletions

View File

@ -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),

View File

@ -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