mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
Operations on a VM now write their rows the way the admin audit does: one
row per operation, done or failed with a safe reason, with the user, IP and
host. Each row names the VM ("VM web-1: delete snapshot snap1") and carries
its UUID in the new Logs.instance_uuid column.
- audit_vm and failed_vm wrap audit() and failed() for a VM. A failure the
view turns into a message is caught outside the block, so its failed row
is written; busy claims, permission and quota refusals and invalid input
write nothing. No password, key or XML goes into a row.
- All VM page operations move from addlogmsg to audit_vm, and addlogmsg
goes. QoS changes and defining a VM from XML are logged now; a gstfsd
error reply (root password, SSH key) is a failed row, not a done one.
- Partial results are rows of their own: the VM delete, then each disk
delete; the disk detach, then the volume delete; the migration, then a
failed autostart restore, NVRAM removal or record on the target.
- Migration rows use the compute name as the host column, as every other
row does.
- VM job rows (create, clone, snapshots) and their resolutions carry the
VM's UUID; snapshot job intents now record it. The owner rows of the VM
page and the accounts pages, and the ownership system rows, carry it too.
- The Logs tab loads vm_logs/<pk>/ and shows the rows with the VM's UUID,
so a rename keeps the history, two VMs with one name are told apart and
a VM on two computes is one VM. It gains a Result column. Rows from
before this change have no UUID and stay on the Logs page only.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
15 lines
725 B
Python
15 lines
725 B
Python
from django.db.models import BooleanField, CharField, DateTimeField, GenericIPAddressField, Model, TextField
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class Logs(Model):
|
|
user = CharField(_("user"), max_length=150)
|
|
host = CharField(_("host"), max_length=255, default="-")
|
|
instance = CharField(_("instance"), max_length=120)
|
|
instance_uuid = CharField(_("instance UUID"), max_length=36, blank=True, default="", db_index=True)
|
|
message = TextField(_("message"))
|
|
date = DateTimeField(_("date"), auto_now_add=True, db_index=True)
|
|
success = BooleanField(_("success"), null=True)
|
|
ip = GenericIPAddressField(_("IP address"), null=True)
|
|
|
|
def __str__(self):
|
|
return self.instance
|