Skip to content
Snippets Groups Projects
Commit be890708 authored by garciadeblas's avatar garciadeblas
Browse files

Add update_state_operation_history function to update states with arbitrary text in an operation


Change-Id: I47b87d4a02163ca0fb5c6b979d7766b97fb1ce4e
Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 8bde3f4c
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,33 @@ class GitOpsLcm(LcmBase):
)
return operation.get("operationType", {})
def update_state_operation_history(
self, content, op_id, workflow_state=None, resource_state=None
):
self.logger.info(
f"Update state of operation {op_id} in Operation History in DB"
)
self.logger.info(
f"Workflow state: {workflow_state}. Resource state: {resource_state}"
)
self.logger.debug(f"Content: {content}")
op_num = 0
for operation in content["operationHistory"]:
self.logger.debug("Operations: {}".format(operation))
if operation["op_id"] == op_id:
self.logger.debug("Found operation number: {}".format(op_num))
if workflow_state is not None:
operation["workflowState"] = workflow_state
if resource_state is not None:
operation["resourceState"] = resource_state
break
op_num += 1
self.logger.debug("content: {}".format(content))
return content
def update_operation_history(
self, content, op_id, workflow_status=None, resource_status=None, op_end=True
):
......@@ -198,8 +225,8 @@ class GitOpsLcm(LcmBase):
return status, message
else:
db_item["resourceState"] = checking["resourceState"]
db_item = self.update_operation_history(
db_item, op_id, "COMPLETED", checking["resourceState"]
db_item = self.update_state_operation_history(
db_item, op_id, None, checking["resourceState"]
)
self.db.set_one(db_collection, {"_id": db_item["_id"]}, db_item)
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment