return operation.get("operationType", {})
def update_operation_history(
- self, content, op_id, workflow_status=None, resource_status=None
+ self, content, op_id, workflow_status=None, resource_status=None, op_end=True
):
self.logger.info(
f"Update Operation History in DB. Workflow status: {workflow_status}. Resource status: {resource_status}"
self.logger.debug("Operations: {}".format(operation))
if operation["op_id"] == op_id:
self.logger.debug("Found operation number: {}".format(op_num))
- now = time()
if workflow_status:
- content["operationHistory"][op_num]["workflowState"] = "COMPLETED"
- content["operationHistory"][op_num]["result"] = True
+ operation["workflowState"] = "COMPLETED"
+ operation["result"] = True
else:
- content["operationHistory"][op_num]["workflowState"] = "ERROR"
- content["operationHistory"][op_num]["operationState"] = "FAILED"
- content["operationHistory"][op_num]["result"] = False
+ operation["workflowState"] = "ERROR"
+ operation["operationState"] = "FAILED"
+ operation["result"] = False
if resource_status:
- content["operationHistory"][op_num]["resourceState"] = "READY"
- content["operationHistory"][op_num]["operationState"] = "COMPLETED"
- content["operationHistory"][op_num]["result"] = True
+ operation["resourceState"] = "READY"
+ operation["operationState"] = "COMPLETED"
+ operation["result"] = True
else:
- content["operationHistory"][op_num]["resourceState"] = "NOT_READY"
- content["operationHistory"][op_num]["operationState"] = "FAILED"
- content["operationHistory"][op_num]["result"] = False
+ operation["resourceState"] = "NOT_READY"
+ operation["operationState"] = "FAILED"
+ operation["result"] = False
- content["operationHistory"][op_num]["endDate"] = now
+ if op_end:
+ now = time()
+ operation["endDate"] = now
break
op_num += 1
self.logger.debug("content: {}".format(content))