From 00cfe8bc82b68748121ce41df0341848dd8f3bfb Mon Sep 17 00:00:00 2001 From: yshah Date: Fri, 17 Jan 2025 04:05:45 +0000 Subject: [PATCH] OKA update check conflict on name and description Change-Id: I44eaa83a15ae8386dfe470f0c06a3264538b87e0 Signed-off-by: yshah --- osm_nbi/k8s_topics.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/osm_nbi/k8s_topics.py b/osm_nbi/k8s_topics.py index 9519f2d..d4ff80b 100644 --- a/osm_nbi/k8s_topics.py +++ b/osm_nbi/k8s_topics.py @@ -1038,16 +1038,24 @@ class OkaTopic(DescriptorTopic, ACMOperationTopic): ) def check_conflict_on_edit(self, session, final_content, edit_content, _id): - if ( - final_content["name"] == edit_content["name"] + if "name" in edit_content: + if final_content["name"] == edit_content["name"]: + name = edit_content["name"] + raise EngineException( + f"No update, new name for the OKA is the same: {name}", + http_code=HTTPStatus.CONFLICT, + ) + else: + self.check_unique_name(session, edit_content["name"]) + elif ( + "description" in edit_content and final_content["description"] == edit_content["description"] ): + description = edit_content["description"] raise EngineException( - "No update", + f"No update, new description for the OKA is the same: {description}", http_code=HTTPStatus.CONFLICT, ) - if final_content["name"] != edit_content["name"]: - self.check_unique_name(session, edit_content["name"]) return final_content def edit(self, session, _id, indata=None, kwargs=None, content=None): -- 2.25.1