in backend/bms_app/webhook/services/pubsub.py [0:0]
def process_host_related_data(msg, completed_at):
"""Update host related data: source_db, mapping, operation details."""
for hostname in msg['hostnames']:
op_detail = (
db.session.query(OperationDetails)
.join(Mapping)
.join(BMSServer, Mapping.bms_id == BMSServer.id)
.filter(OperationDetails.operation_id == msg['operation_id'],
BMSServer.name == hostname)
.first()
)
cls_handler = operation_details_handler_mapper.get(
op_detail.operation_type.value
)
status_handler = cls_handler(op_detail, completed_at)
if 'step' in msg:
status_handler.set_step(msg['step'], msg['timestamp'])
if 'host_status' in msg:
if msg['host_status'] == 'FAILED':
status_handler.fail()
elif msg['host_status'] == 'COMPLETE':
status_handler.complete()
else:
status_handler.set_status(msg['host_status'])
db.session.flush()