)
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
):
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: