Fix on patch removal order

Change-Id: I9d0921f9abd071c4c7b9aaac5b548d8179f7a698
Signed-off-by: Lindley Werner <Lindley.Vieira@windriver.com>
This commit is contained in:
Lindley Werner 2024-05-01 15:39:09 -03:00
parent ee78efb5f7
commit e65d9ce60b
1 changed files with 12 additions and 6 deletions

View File

@ -1329,13 +1329,19 @@ class PatchController(PatchService):
if not id_verification:
return dict(info=msg_info, warning=msg_warning, error=msg_error)
patch_list = self.patch_apply_remove_order(patch_ids)
# Protect against duplications
patch_list = sorted(list(set(patch_ids)))
if patch_list is None:
msg = "Patch list provided belongs to different software versions."
LOG.error(msg)
msg_error += msg + "\n"
return dict(info=msg_info, warning=msg_warning, error=msg_error)
# checks if the patch versions in the list match
ver = None
for patch_id in patch_list:
if ver is None:
ver = self.patch_data.metadata[patch_id]["sw_version"]
elif self.patch_data.metadata[patch_id]["sw_version"] != ver:
msg = "Patch list provided belongs to different software versions."
LOG.error(msg)
msg_error += msg + "\n"
return dict(info=msg_info, warning=msg_warning, error=msg_error)
msg = "Removing patches: %s" % ",".join(patch_list)
LOG.info(msg)