From e08aff1559872a920e7af6639fedb7c991602a85 Mon Sep 17 00:00:00 2001 From: yshah Date: Thu, 7 Nov 2024 09:32:22 +0000 Subject: [PATCH] Update operationHistory and response for create operation Change-Id: I89aec4ce42e8f4ccc5471aa63acb202435a2acc8 Signed-off-by: yshah --- osm_nbi/base_topic.py | 3 ++- osm_nbi/k8s_topics.py | 4 +++- osm_nbi/nbi.py | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osm_nbi/base_topic.py b/osm_nbi/base_topic.py index a327260..dc656d5 100644 --- a/osm_nbi/base_topic.py +++ b/osm_nbi/base_topic.py @@ -432,7 +432,8 @@ class BaseTopic: if launch_workflow: operation["workflowState"] = "PROCESSING" operation["resourceState"] = "NOT_READY" - operation["git_operation_info"] = None + operation["operationState"] = "IN_PROGRESS" + operation["gitOperationInfo"] = None operation["operationParams"] = operation_params content["operationHistory"].append(operation) diff --git a/osm_nbi/k8s_topics.py b/osm_nbi/k8s_topics.py index 22eceba..f353724 100644 --- a/osm_nbi/k8s_topics.py +++ b/osm_nbi/k8s_topics.py @@ -527,7 +527,10 @@ class K8sTopic(BaseTopic): filter_db = self._get_project_filter(session) # To allow project&user addressing by name AS WELL AS _id filter_db[BaseTopic.id_field(self.topic, _id)] = _id + op_id = str(uuid4()) + operation_params = {} data = self.db.get_one(self.topic, filter_db) + data["current_operation"] = op_id data["operatingState"] = "PROCESSING" data["resourceState"] = "IN_PROGRESS" operation_params = indata @@ -537,7 +540,6 @@ class K8sTopic(BaseTopic): operation_params, ) self.db.set_one(self.topic, {"_id": _id}, data) - op_id = data["current_operation"] data = {"cluster_id": _id, "operation_id": op_id} self._send_msg(item, data) return op_id diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index e11f4ba..368074a 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -1872,7 +1872,7 @@ class Server(object): self._set_location_header(main_topic, version, topic, _id) else: cherrypy.response.headers["Transaction-Id"] = _id - outdata = {"_id": _id} + outdata = {"_id": _id, "id": _id} elif topic == "ns_instances_content": # creates NSR _id, _ = self.engine.new_item( @@ -1994,7 +1994,7 @@ class Server(object): rollback, engine_session, engine_topic, indata, kwargs ) self._set_location_header(main_topic, version, topic, _id) - outdata = {"id": _id} + outdata = {"_id": _id, "id": _id} elif ( topic in ( @@ -2011,7 +2011,7 @@ class Server(object): rollback, engine_session, engine_topic, indata, kwargs ) self._set_location_header(main_topic, version, topic, _id) - outdata = {"_id": _id} + outdata = {"_id": _id, "id": _id} elif topic == "ksus" and item: if item == "clone": _id = self.engine.clone( @@ -2024,7 +2024,7 @@ class Server(object): cherrypy.request.headers, ) self._set_location_header(main_topic, version, topic, _id) - outdata = {"id": _id} + outdata = {"_id": _id, "id": _id} if item == "move": op_id = self.engine.move_ksu( engine_session, engine_topic, _id, indata, kwargs @@ -2055,7 +2055,7 @@ class Server(object): cherrypy.request.headers, ) self._set_location_header(main_topic, version, topic, _id) - outdata = {"id": _id} + outdata = {"_id": _id, "id": _id} if op_id: outdata["op_id"] = op_id cherrypy.response.status = HTTPStatus.ACCEPTED.value -- 2.25.1