1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(logs): a resolved migration and an unapplied console setting log what happened

From the Codex and agy review of the VM audit log before v3.2.0:

- Resolving an uncertain migration wrote its row without the VM's UUID,
  because the migrate job writes no entries of its own; the resolution now
  takes the UUID from the job's intent, so the VM's Logs tab shows it.
- A console keymap or listen address the VM could not take (no graphics
  device, or a console on a socket) was logged as done although nothing
  changed; it now writes no row, as an edit that changes nothing.
This commit is contained in:
catborise 2026-10-24 14:28:09 +03:00
parent 273052d7c6
commit a4c62cb9d6
3 changed files with 34 additions and 6 deletions

View file

@ -262,9 +262,10 @@ def resolve(op_id, user, outcome_state, note):
Operation.objects.filter(pk=op.pk).update(state=outcome_state, resolution=outcome_state,
resolution_note=note, resolved_by=user, resolved_at=timezone.now())
Claim.objects.filter(operation=op).delete()
# the host, VM and UUID columns of the kind's own entries, so the VM's log shows it
# the host, VM and UUID columns of the kind's own entries, so the VM's log shows it;
# a kind without entries (a migration) still names its VM by the UUID in its intent
entry = _entry(op, outcome_state)
host, instance, uuid = entry[:3] if entry is not None else ("-", op.resource_label, "")
host, instance, uuid = entry[:3] if entry is not None else ("-", op.resource_label, op.intent.get("uuid", ""))
_log(user.username, host, instance, uuid, f"Job {op.pk} resolved as {outcome_state}: {note}",
outcome_state == Operation.SUCCEEDED)
op.refresh_from_db()