mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
feat(vmbackups): delete a backup; the Backups page
Backups in the menu now opens a page of every backup, newest first, filtered by VM name, target and state; a removed VM's backups are marked. Each backup, there and on the VM's Backups tab, has a Delete button (also DELETE /api/v1/backups/<uuid>/, 202 with the job). The backup.delete job holds the backup and its target. Through the first of the target's computes that reaches its pool, it marks the backup deleting, removes the manifest first, so the target no longer holds a complete backup, then every other file named from the backup's UUID (also those a failed backup left), then the row. Recovery runs the same steps again. A backup being made is refused: its job is cancelled instead. States and consistency are shown in the reader's language.
This commit is contained in:
parent
f4559acbc7
commit
7227867d78
17 changed files with 607 additions and 117 deletions
Binary file not shown.
|
|
@ -11,7 +11,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-17 06:13+0000\n"
|
||||
"POT-Creation-Date: 2026-11-17 06:14+0000\n"
|
||||
"PO-Revision-Date: 2020-11-04 12:00+0000\n"
|
||||
"Last-Translator: catborise <muhammetalisag@gmail.com>, 2020\n"
|
||||
"Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n"
|
||||
|
|
@ -472,6 +472,7 @@ msgstr "%(name)s API anahtarı için işlemler"
|
|||
#: templates/common/confirm_delete.html:5
|
||||
#: templates/common/confirm_delete.html:9
|
||||
#: templates/common/confirm_delete.html:26
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:2
|
||||
msgid "Delete"
|
||||
msgstr "Sil"
|
||||
|
||||
|
|
@ -982,7 +983,8 @@ msgstr "Tamamlandı"
|
|||
|
||||
#: admin/templates/admin/logs.html:56 admin/views.py:395 logs/views.py:18
|
||||
#: operations/templates/operations/job.html:107
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:49
|
||||
#: vmbackups/templates/vmbackups/index.html:31
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Failed"
|
||||
msgstr "Başarısız"
|
||||
|
||||
|
|
@ -3264,7 +3266,7 @@ msgstr ""
|
|||
msgid "The name of the virtual machine must not contain any special characters"
|
||||
msgstr "Sanal makine adı özel karakterler içeremez"
|
||||
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:73
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:74
|
||||
msgid "The VM moved to another compute after the job was queued"
|
||||
msgstr "İş kuyruğa alındıktan sonra sanal makine başka bir sunucuya taşındı"
|
||||
|
||||
|
|
@ -3452,11 +3454,11 @@ msgid "Clone VM"
|
|||
msgstr "Sanal makineyi klonla"
|
||||
|
||||
#: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005
|
||||
#: vmbackups/jobs.py:210
|
||||
#: vmbackups/jobs.py:211
|
||||
msgid "Copying disks"
|
||||
msgstr "Diskler kopyalanıyor"
|
||||
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:286
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:287
|
||||
msgid "libvirt has no result of the copy"
|
||||
msgstr "libvirt'te kopyanın sonucu yok"
|
||||
|
||||
|
|
@ -3469,7 +3471,7 @@ msgstr ""
|
|||
"Kopyalama başarısız oldu: %(error)s. Konuğun dosya sistemleri çözülemedi "
|
||||
"(%(thaw)s); şununla çözün: virsh domfsthaw %(vm)s"
|
||||
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:292
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:293
|
||||
msgid "The copy failed"
|
||||
msgstr "Kopyalama başarısız oldu"
|
||||
|
||||
|
|
@ -3491,11 +3493,11 @@ msgstr ""
|
|||
"Klonun bir birimi oluşturuluyordu; şu birimleri kontrol edin, sonra bu işi "
|
||||
"çözün: %(volumes)s"
|
||||
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:329
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:330
|
||||
msgid "The job stopped before the copy started"
|
||||
msgstr "İş, kopyalama başlamadan durdu"
|
||||
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:377
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:378
|
||||
msgid "libvirt is still copying the disks"
|
||||
msgstr "libvirt diskleri hâlâ kopyalıyor"
|
||||
|
||||
|
|
@ -3959,6 +3961,7 @@ msgstr "Harf, rakam, nokta, tire ve alt çizgi."
|
|||
|
||||
#: instances/templates/add_instance_volume.html:44
|
||||
#: instances/templates/instances/settings_tab.html:851
|
||||
#: vmbackups/templates/vmbackups/index.html:45
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Size"
|
||||
msgstr "Boyut"
|
||||
|
|
@ -4118,6 +4121,8 @@ msgstr "Adres"
|
|||
|
||||
#: instances/templates/allinstances.html:105 instances/views.py:240
|
||||
#: interfaces/templates/interface.html:153 networks/templates/network.html:202
|
||||
#: vmbackups/templates/vmbackups/index.html:15
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
msgid "VM"
|
||||
msgstr "VM"
|
||||
|
||||
|
|
@ -4549,6 +4554,8 @@ msgid "Stats"
|
|||
msgstr "İstatistikler"
|
||||
|
||||
#: instances/templates/instance.html:112 templates/navbar.html:21
|
||||
#: vmbackups/templates/vmbackups/index.html:6
|
||||
#: vmbackups/templates/vmbackups/index.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Backups"
|
||||
msgstr "Yedekler"
|
||||
|
|
@ -6612,6 +6619,8 @@ msgstr "Çok fazla arama hâlâ çalışıyor; birazdan yeniden deneyin."
|
|||
#: operations/templates/operations/jobs.html:38
|
||||
#: operations/templates/operations/jobs.html:62
|
||||
#: storages/templates/storage.html:91
|
||||
#: vmbackups/templates/vmbackups/index.html:26
|
||||
#: vmbackups/templates/vmbackups/index.html:45
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "State"
|
||||
msgstr "Durum"
|
||||
|
|
@ -8276,6 +8285,8 @@ msgstr "Filtre oluştur"
|
|||
|
||||
#: nwfilters/templates/nwfilter.html:15 nwfilters/templates/nwfilter.html:54
|
||||
#: operations/templates/operations/jobs.html:46
|
||||
#: vmbackups/templates/vmbackups/index.html:13
|
||||
#: vmbackups/templates/vmbackups/index.html:36
|
||||
msgid "Filter"
|
||||
msgstr "Filtre"
|
||||
|
||||
|
|
@ -8618,6 +8629,7 @@ msgid "All kinds"
|
|||
msgstr "Tüm türler"
|
||||
|
||||
#: operations/templates/operations/jobs.html:39
|
||||
#: vmbackups/templates/vmbackups/index.html:28
|
||||
msgid "All states"
|
||||
msgstr "Tüm durumlar"
|
||||
|
||||
|
|
@ -8630,7 +8642,7 @@ msgid "No jobs"
|
|||
msgstr "İş yok"
|
||||
|
||||
#: operations/templates/operations/jobs.html:59
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:50
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Job"
|
||||
msgstr "İş"
|
||||
|
||||
|
|
@ -9719,17 +9731,17 @@ msgstr "Sunucu"
|
|||
msgid "A backup target with this name exists"
|
||||
msgstr "Bu adla bir yedek hedefi zaten var"
|
||||
|
||||
#: vmbackups/jobs.py:46
|
||||
#: vmbackups/jobs.py:47
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has no storage pool on %(compute)s"
|
||||
msgstr "%(target)s yedek hedefinin %(compute)s üzerinde depolama havuzu yok"
|
||||
|
||||
#: vmbackups/jobs.py:56
|
||||
#: vmbackups/jobs.py:57
|
||||
msgid "The VM must be running, paused or shut off to be backed up"
|
||||
msgstr ""
|
||||
"Yedeklenmek için sanal makine çalışıyor, duraklatılmış ya da kapalı olmalı"
|
||||
|
||||
#: vmbackups/jobs.py:60
|
||||
#: vmbackups/jobs.py:61
|
||||
msgid ""
|
||||
"A running VM's backup needs libvirt 11.10 or later; shut the VM down to back "
|
||||
"it up"
|
||||
|
|
@ -9737,35 +9749,35 @@ msgstr ""
|
|||
"Çalışan bir sanal makinenin yedeği libvirt 11.10 veya sonrasını gerektirir; "
|
||||
"yedeklemek için sanal makineyi kapatın"
|
||||
|
||||
#: vmbackups/jobs.py:62
|
||||
#: vmbackups/jobs.py:63
|
||||
msgid "A paused VM's file systems cannot be frozen"
|
||||
msgstr "Duraklatılmış bir sanal makinenin dosya sistemleri dondurulamaz"
|
||||
|
||||
#: vmbackups/jobs.py:64
|
||||
#: vmbackups/jobs.py:65
|
||||
msgid "The guest agent does not answer: the file systems cannot be frozen"
|
||||
msgstr "Konuk ajanı yanıt vermiyor: dosya sistemleri dondurulamaz"
|
||||
|
||||
#: vmbackups/jobs.py:114
|
||||
#: vmbackups/jobs.py:115
|
||||
msgid ""
|
||||
"The VM's NVRAM file changed while it was backed up; back the VM up again"
|
||||
msgstr ""
|
||||
"Sanal makinenin NVRAM dosyası yedeklenirken değişti; sanal makineyi yeniden "
|
||||
"yedekleyin"
|
||||
|
||||
#: vmbackups/jobs.py:175
|
||||
#: vmbackups/jobs.py:176
|
||||
msgid "Back up VM"
|
||||
msgstr "Sanal makineyi yedekle"
|
||||
|
||||
#: vmbackups/jobs.py:226 vmbackups/jobs.py:293
|
||||
#: vmbackups/jobs.py:227 vmbackups/jobs.py:294
|
||||
msgid "Writing the backup's files"
|
||||
msgstr "Yedeğin dosyaları yazılıyor"
|
||||
|
||||
#: vmbackups/jobs.py:305
|
||||
#: vmbackups/jobs.py:306
|
||||
msgid "The guest's file systems could not be thawed; trying again"
|
||||
msgstr ""
|
||||
"Konuğun dosya sistemlerinin dondurulması kaldırılamadı; yeniden deneniyor"
|
||||
|
||||
#: vmbackups/jobs.py:354
|
||||
#: vmbackups/jobs.py:355
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The VM is no longer on the compute the job ran on; check these volumes of the"
|
||||
|
|
@ -9774,7 +9786,7 @@ msgstr ""
|
|||
"Sanal makine artık işin çalıştığı sunucuda değil; yedek hedefindeki şu "
|
||||
"birimleri kontrol edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:371
|
||||
#: vmbackups/jobs.py:372
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check these volumes of the "
|
||||
|
|
@ -9783,7 +9795,7 @@ msgstr ""
|
|||
"İş durduğunda bir disk kopyalanıyordu; yedek hedefindeki şu birimleri kontrol"
|
||||
" edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:381
|
||||
#: vmbackups/jobs.py:382
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Another backup runs on the VM; check these volumes of the backup target, then"
|
||||
|
|
@ -9792,7 +9804,7 @@ msgstr ""
|
|||
"Sanal makinede başka bir yedekleme çalışıyor; yedek hedefindeki şu birimleri "
|
||||
"kontrol edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:387
|
||||
#: vmbackups/jobs.py:388
|
||||
#, python-format
|
||||
msgid ""
|
||||
"libvirt has no result of the copy; check these volumes of the backup target, "
|
||||
|
|
@ -9801,15 +9813,51 @@ msgstr ""
|
|||
"libvirt'te kopyanın sonucu yok; yedek hedefindeki şu birimleri kontrol edin, "
|
||||
"sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:395
|
||||
#: vmbackups/jobs.py:396
|
||||
msgid "The job stopped before the copy ended"
|
||||
msgstr "İş, kopyalama bitmeden durdu"
|
||||
|
||||
#: vmbackups/jobs.py:402
|
||||
#: vmbackups/jobs.py:403
|
||||
#, python-format
|
||||
msgid "The backup's files could not be written: %(error)s"
|
||||
msgstr "Yedeğin dosyaları yazılamadı: %(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:421
|
||||
#, python-format
|
||||
msgid "No compute of backup target %(target)s reaches its storage pool"
|
||||
msgstr ""
|
||||
"%(target)s yedek hedefinin hiçbir sunucusu depolama havuzuna erişemiyor"
|
||||
|
||||
#: vmbackups/jobs.py:434
|
||||
msgid "Delete backup"
|
||||
msgstr "Yedeği sil"
|
||||
|
||||
#: vmbackups/jobs.py:443
|
||||
msgid "This backup is being made; cancel its job to stop it"
|
||||
msgstr "Bu yedek alınıyor; durdurmak için işini iptal edin"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Shut off"
|
||||
msgstr "Kapalı"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Frozen"
|
||||
msgstr "Dondurulmuş"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Crash-consistent"
|
||||
msgstr "Çökme tutarlı"
|
||||
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:3
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Delete the backup of %(vm)s taken %(time)s? Its files are removed from the "
|
||||
"target."
|
||||
msgstr ""
|
||||
"%(vm)s sanal makinesinin %(time)s tarihli yedeği silinsin mi? Dosyaları "
|
||||
"hedeften kaldırılır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:10
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
|
|
@ -9817,6 +9865,57 @@ msgstr "Yedeğin dosyaları yazılamadı: %(error)s"
|
|||
msgid "Backup targets"
|
||||
msgstr "Yedek hedefleri"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:16
|
||||
msgid "VM name"
|
||||
msgstr "Sanal makine adı"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:19
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Target"
|
||||
msgstr "Hedef"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:21
|
||||
msgid "All targets"
|
||||
msgstr "Tüm hedefler"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:29
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Ready"
|
||||
msgstr "Hazır"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:30
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Creating"
|
||||
msgstr "Oluşturuluyor"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:32
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Deleting"
|
||||
msgstr "Siliniyor"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Time"
|
||||
msgstr "Zaman"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Consistency"
|
||||
msgstr "Tutarlılık"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:53
|
||||
msgid "removed"
|
||||
msgstr "kaldırıldı"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:67
|
||||
msgid "No backup matches the filter."
|
||||
msgstr "Süzgece uyan yedek yok."
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:69
|
||||
msgid "No backup yet. Back a VM up from its Backups tab."
|
||||
msgstr "Henüz yedek yok. Bir sanal makineyi Yedekler sekmesinden yedekleyin."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
|
|
@ -9905,31 +10004,7 @@ msgstr ""
|
|||
" konuk ajanı yanıt verirse dosya sistemleri o an için dondurulur, vermezse "
|
||||
"yedek çökme tutarlıdır. Bellek saklanmaz."
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Time"
|
||||
msgstr "Zaman"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Target"
|
||||
msgstr "Hedef"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Consistency"
|
||||
msgstr "Tutarlılık"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:46
|
||||
msgid "Ready"
|
||||
msgstr "Hazır"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:47
|
||||
msgid "Creating"
|
||||
msgstr "Oluşturuluyor"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:48
|
||||
msgid "Deleting"
|
||||
msgstr "Siliniyor"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:58
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:53
|
||||
msgid "No backup of this VM yet."
|
||||
msgstr "Bu sanal makinenin henüz yedeği yok."
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-17 06:13+0000\n"
|
||||
"POT-Creation-Date: 2026-11-17 06:14+0000\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
|
@ -465,6 +465,7 @@ msgstr "API 令牌 %(name)s 的操作"
|
|||
#: templates/common/confirm_delete.html:5
|
||||
#: templates/common/confirm_delete.html:9
|
||||
#: templates/common/confirm_delete.html:26
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:2
|
||||
msgid "Delete"
|
||||
msgstr "删除"
|
||||
|
||||
|
|
@ -957,7 +958,8 @@ msgstr "完成"
|
|||
|
||||
#: admin/templates/admin/logs.html:56 admin/views.py:395 logs/views.py:18
|
||||
#: operations/templates/operations/job.html:107
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:49
|
||||
#: vmbackups/templates/vmbackups/index.html:31
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Failed"
|
||||
msgstr "失败"
|
||||
|
||||
|
|
@ -3109,7 +3111,7 @@ msgstr "控制台监听的不只是 localhost;只有管理员可以移除其
|
|||
msgid "The name of the virtual machine must not contain any special characters"
|
||||
msgstr "虚拟机名称不能包含任何特殊字符"
|
||||
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:73
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:74
|
||||
msgid "The VM moved to another compute after the job was queued"
|
||||
msgstr "任务排队后,虚拟机已移到另一个计算节点"
|
||||
|
||||
|
|
@ -3282,11 +3284,11 @@ msgid "Clone VM"
|
|||
msgstr "克隆虚拟机"
|
||||
|
||||
#: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005
|
||||
#: vmbackups/jobs.py:210
|
||||
#: vmbackups/jobs.py:211
|
||||
msgid "Copying disks"
|
||||
msgstr "正在复制磁盘"
|
||||
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:286
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:287
|
||||
msgid "libvirt has no result of the copy"
|
||||
msgstr "libvirt 没有复制的结果"
|
||||
|
||||
|
|
@ -3297,7 +3299,7 @@ msgid ""
|
|||
"(%(thaw)s); thaw them with: virsh domfsthaw %(vm)s"
|
||||
msgstr "复制失败:%(error)s。无法解冻客户机的文件系统(%(thaw)s);请用以下命令解冻:virsh domfsthaw %(vm)s"
|
||||
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:292
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:293
|
||||
msgid "The copy failed"
|
||||
msgstr "复制失败"
|
||||
|
||||
|
|
@ -3315,11 +3317,11 @@ msgid ""
|
|||
"this job: %(volumes)s"
|
||||
msgstr "克隆的一个卷正在创建中;请检查这些卷,然后处理此任务:%(volumes)s"
|
||||
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:329
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:330
|
||||
msgid "The job stopped before the copy started"
|
||||
msgstr "任务在复制开始前停止"
|
||||
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:377
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:378
|
||||
msgid "libvirt is still copying the disks"
|
||||
msgstr "libvirt 仍在复制磁盘"
|
||||
|
||||
|
|
@ -3760,6 +3762,7 @@ msgstr "字母、数字、点、短横线和下划线。"
|
|||
|
||||
#: instances/templates/add_instance_volume.html:44
|
||||
#: instances/templates/instances/settings_tab.html:851
|
||||
#: vmbackups/templates/vmbackups/index.html:45
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Size"
|
||||
msgstr "大小"
|
||||
|
|
@ -3914,6 +3917,8 @@ msgstr "地址"
|
|||
|
||||
#: instances/templates/allinstances.html:105 instances/views.py:240
|
||||
#: interfaces/templates/interface.html:153 networks/templates/network.html:202
|
||||
#: vmbackups/templates/vmbackups/index.html:15
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
msgid "VM"
|
||||
msgstr "虚拟机"
|
||||
|
||||
|
|
@ -4334,6 +4339,8 @@ msgid "Stats"
|
|||
msgstr "统计"
|
||||
|
||||
#: instances/templates/instance.html:112 templates/navbar.html:21
|
||||
#: vmbackups/templates/vmbackups/index.html:6
|
||||
#: vmbackups/templates/vmbackups/index.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Backups"
|
||||
msgstr "备份"
|
||||
|
|
@ -6231,6 +6238,8 @@ msgstr "仍在运行的搜索过多;请稍后再试。"
|
|||
#: operations/templates/operations/jobs.html:38
|
||||
#: operations/templates/operations/jobs.html:62
|
||||
#: storages/templates/storage.html:91
|
||||
#: vmbackups/templates/vmbackups/index.html:26
|
||||
#: vmbackups/templates/vmbackups/index.html:45
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "State"
|
||||
msgstr "状态"
|
||||
|
|
@ -7790,6 +7799,8 @@ msgstr "创建过滤器"
|
|||
|
||||
#: nwfilters/templates/nwfilter.html:15 nwfilters/templates/nwfilter.html:54
|
||||
#: operations/templates/operations/jobs.html:46
|
||||
#: vmbackups/templates/vmbackups/index.html:13
|
||||
#: vmbackups/templates/vmbackups/index.html:36
|
||||
msgid "Filter"
|
||||
msgstr "过滤器"
|
||||
|
||||
|
|
@ -8120,6 +8131,7 @@ msgid "All kinds"
|
|||
msgstr "所有类型"
|
||||
|
||||
#: operations/templates/operations/jobs.html:39
|
||||
#: vmbackups/templates/vmbackups/index.html:28
|
||||
msgid "All states"
|
||||
msgstr "所有状态"
|
||||
|
||||
|
|
@ -8132,7 +8144,7 @@ msgid "No jobs"
|
|||
msgstr "没有任务"
|
||||
|
||||
#: operations/templates/operations/jobs.html:59
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:50
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Job"
|
||||
msgstr "任务"
|
||||
|
||||
|
|
@ -9164,83 +9176,116 @@ msgstr "计算节点"
|
|||
msgid "A backup target with this name exists"
|
||||
msgstr "已存在同名的备份目标"
|
||||
|
||||
#: vmbackups/jobs.py:46
|
||||
#: vmbackups/jobs.py:47
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has no storage pool on %(compute)s"
|
||||
msgstr "备份目标 %(target)s 在 %(compute)s 上没有存储池"
|
||||
|
||||
#: vmbackups/jobs.py:56
|
||||
#: vmbackups/jobs.py:57
|
||||
msgid "The VM must be running, paused or shut off to be backed up"
|
||||
msgstr "虚拟机必须处于运行、暂停或关闭状态才能备份"
|
||||
|
||||
#: vmbackups/jobs.py:60
|
||||
#: vmbackups/jobs.py:61
|
||||
msgid ""
|
||||
"A running VM's backup needs libvirt 11.10 or later; shut the VM down to back "
|
||||
"it up"
|
||||
msgstr "运行中虚拟机的备份需要 libvirt 11.10 或更高版本;请关闭虚拟机后再备份"
|
||||
|
||||
#: vmbackups/jobs.py:62
|
||||
#: vmbackups/jobs.py:63
|
||||
msgid "A paused VM's file systems cannot be frozen"
|
||||
msgstr "无法冻结已暂停虚拟机的文件系统"
|
||||
|
||||
#: vmbackups/jobs.py:64
|
||||
#: vmbackups/jobs.py:65
|
||||
msgid "The guest agent does not answer: the file systems cannot be frozen"
|
||||
msgstr "客户机代理没有响应:无法冻结文件系统"
|
||||
|
||||
#: vmbackups/jobs.py:114
|
||||
#: vmbackups/jobs.py:115
|
||||
msgid ""
|
||||
"The VM's NVRAM file changed while it was backed up; back the VM up again"
|
||||
msgstr "虚拟机的 NVRAM 文件在备份期间发生了变化;请重新备份该虚拟机"
|
||||
|
||||
#: vmbackups/jobs.py:175
|
||||
#: vmbackups/jobs.py:176
|
||||
msgid "Back up VM"
|
||||
msgstr "备份虚拟机"
|
||||
|
||||
#: vmbackups/jobs.py:226 vmbackups/jobs.py:293
|
||||
#: vmbackups/jobs.py:227 vmbackups/jobs.py:294
|
||||
msgid "Writing the backup's files"
|
||||
msgstr "正在写入备份文件"
|
||||
|
||||
#: vmbackups/jobs.py:305
|
||||
#: vmbackups/jobs.py:306
|
||||
msgid "The guest's file systems could not be thawed; trying again"
|
||||
msgstr "无法解冻客户机的文件系统;正在重试"
|
||||
|
||||
#: vmbackups/jobs.py:354
|
||||
#: vmbackups/jobs.py:355
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The VM is no longer on the compute the job ran on; check these volumes of the"
|
||||
" backup target, then resolve this job: %(volumes)s"
|
||||
msgstr "虚拟机已不在作业运行的计算节点上;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:371
|
||||
#: vmbackups/jobs.py:372
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check these volumes of the "
|
||||
"backup target, then resolve this job: %(volumes)s"
|
||||
msgstr "作业停止时正在复制磁盘;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:381
|
||||
#: vmbackups/jobs.py:382
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Another backup runs on the VM; check these volumes of the backup target, then"
|
||||
" resolve this job: %(volumes)s"
|
||||
msgstr "虚拟机上正在运行另一个备份;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:387
|
||||
#: vmbackups/jobs.py:388
|
||||
#, python-format
|
||||
msgid ""
|
||||
"libvirt has no result of the copy; check these volumes of the backup target, "
|
||||
"then resolve this job: %(volumes)s"
|
||||
msgstr "libvirt 没有复制的结果;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:395
|
||||
#: vmbackups/jobs.py:396
|
||||
msgid "The job stopped before the copy ended"
|
||||
msgstr "作业在复制结束前停止"
|
||||
|
||||
#: vmbackups/jobs.py:402
|
||||
#: vmbackups/jobs.py:403
|
||||
#, python-format
|
||||
msgid "The backup's files could not be written: %(error)s"
|
||||
msgstr "无法写入备份文件:%(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:421
|
||||
#, python-format
|
||||
msgid "No compute of backup target %(target)s reaches its storage pool"
|
||||
msgstr "备份目标 %(target)s 的计算节点都无法访问其存储池"
|
||||
|
||||
#: vmbackups/jobs.py:434
|
||||
msgid "Delete backup"
|
||||
msgstr "删除备份"
|
||||
|
||||
#: vmbackups/jobs.py:443
|
||||
msgid "This backup is being made; cancel its job to stop it"
|
||||
msgstr "此备份正在创建;要停止它,请取消其作业"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Shut off"
|
||||
msgstr "已关闭"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Frozen"
|
||||
msgstr "已冻结"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Crash-consistent"
|
||||
msgstr "崩溃一致"
|
||||
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:3
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Delete the backup of %(vm)s taken %(time)s? Its files are removed from the "
|
||||
"target."
|
||||
msgstr "要删除 %(vm)s 在 %(time)s 的备份吗?其文件将从目标中移除。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:10
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
|
|
@ -9248,6 +9293,57 @@ msgstr "无法写入备份文件:%(error)s"
|
|||
msgid "Backup targets"
|
||||
msgstr "备份目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:16
|
||||
msgid "VM name"
|
||||
msgstr "虚拟机名称"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:19
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Target"
|
||||
msgstr "目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:21
|
||||
msgid "All targets"
|
||||
msgstr "所有目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:29
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Ready"
|
||||
msgstr "就绪"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:30
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Creating"
|
||||
msgstr "正在创建"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:32
|
||||
#: vmbackups/templates/vmbackups/state.html:1
|
||||
msgid "Deleting"
|
||||
msgstr "正在删除"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Time"
|
||||
msgstr "时间"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:44
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Consistency"
|
||||
msgstr "一致性"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:53
|
||||
msgid "removed"
|
||||
msgstr "已移除"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:67
|
||||
msgid "No backup matches the filter."
|
||||
msgstr "没有符合筛选条件的备份。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:69
|
||||
msgid "No backup yet. Back a VM up from its Backups tab."
|
||||
msgstr "还没有备份。请在虚拟机的备份选项卡中备份虚拟机。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
|
|
@ -9324,31 +9420,7 @@ msgid ""
|
|||
"backup is crash-consistent. Memory is not kept."
|
||||
msgstr "运行中的虚拟机会继续运行:其磁盘从同一时刻复制;客户机代理响应时,文件系统在该时刻被冻结,否则备份为崩溃一致。不保存内存。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Time"
|
||||
msgstr "时间"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Target"
|
||||
msgstr "目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:36
|
||||
msgid "Consistency"
|
||||
msgstr "一致性"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:46
|
||||
msgid "Ready"
|
||||
msgstr "就绪"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:47
|
||||
msgid "Creating"
|
||||
msgstr "正在创建"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:48
|
||||
msgid "Deleting"
|
||||
msgstr "正在删除"
|
||||
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:58
|
||||
#: vmbackups/templates/vmbackups/vm_tab.html:53
|
||||
msgid "No backup of this VM yet."
|
||||
msgstr "此虚拟机还没有备份。"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<a class="nav-link" href="{% url 'computes' %}">{% bs_icon 'pc-display' %} {% trans "Computes" %}</a>
|
||||
</li>
|
||||
<li class="nav-item {% class_active request '^/backups' %}">
|
||||
<a class="nav-link" href="{% url 'vmbackups:targets' %}">{% bs_icon 'archive' %} {% trans "Backups" %}</a>
|
||||
<a class="nav-link" href="{% url 'vmbackups:index' %}">{% bs_icon 'archive' %} {% trans "Backups" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -9,11 +9,17 @@ from operations.api.serializers import OperationSerializer
|
|||
from webvirtcloud.serializers import ErrorSerializer
|
||||
|
||||
from .models import Backup
|
||||
from .serializers import BackupSerializer, CreateBackupSerializer
|
||||
from .serializers import BackupSerializer, CreateBackupSerializer, SubmissionSerializer
|
||||
|
||||
|
||||
def _accepted(request, op):
|
||||
return Response(OperationSerializer(op, context={"request": request}).data, status=status.HTTP_202_ACCEPTED,
|
||||
headers={"Location": reverse("operation-detail", args=[op.pk])})
|
||||
|
||||
|
||||
class BackupViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
|
||||
"""VM backups: list, read, and back a VM up (a job, answered 202)."""
|
||||
"""VM backups: list, read, back a VM up and delete a backup (jobs,
|
||||
answered 202)."""
|
||||
|
||||
permission_classes = [IsSuperUser]
|
||||
serializer_class = BackupSerializer
|
||||
|
|
@ -27,6 +33,12 @@ class BackupViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.G
|
|||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
data = serializer.validated_data
|
||||
raw = {"instance": data["instance"].pk, "target": data["target"].pk, "frozen": data["frozen"]}
|
||||
op = jobs.submit("backup.create", request.user, raw, data["submission_key"])
|
||||
return Response(OperationSerializer(op, context={"request": request}).data, status=status.HTTP_202_ACCEPTED,
|
||||
headers={"Location": reverse("operation-detail", args=[op.pk])})
|
||||
return _accepted(request, jobs.submit("backup.create", request.user, raw, data["submission_key"]))
|
||||
|
||||
@extend_schema(request=SubmissionSerializer, responses={202: OperationSerializer, 409: ErrorSerializer})
|
||||
def destroy(self, request, uuid=None):
|
||||
backup = self.get_object()
|
||||
serializer = SubmissionSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
key = serializer.validated_data["submission_key"]
|
||||
return _accepted(request, jobs.submit("backup.delete", request.user, {"backup": str(backup.uuid)}, key))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import hashlib
|
||||
import json
|
||||
import time
|
||||
from uuid import uuid4
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import transaction
|
||||
|
|
@ -20,6 +20,7 @@ from operations.models import Claim, Operation
|
|||
from operations.utils import safe_text, say
|
||||
from vrtManager import util
|
||||
from vrtManager.backup import backup_file_names, check_target_space, put_file, remove_files, target_pool, wvmBackup
|
||||
from vrtManager.connection import wvmConnect
|
||||
from vrtManager.instance import LIVE_CLONE_MIN_LIBVIRT
|
||||
|
||||
from .models import Backup, BackupFile, BackupTarget
|
||||
|
|
@ -407,3 +408,73 @@ class CreateBackup(Kind):
|
|||
else:
|
||||
action = f"back up to {op.intent['target']}"
|
||||
return _log(op, state, action)
|
||||
|
||||
|
||||
def _target_pool(target):
|
||||
"""The target's pool through the first of its computes that reaches it."""
|
||||
for row in target.pools.select_related("compute").order_by("compute__name"):
|
||||
c = row.compute
|
||||
try:
|
||||
return target_pool(wvmConnect(c.hostname, c.login, c.password, c.type), row.pool, row.pool_uuid)
|
||||
except libvirtError:
|
||||
continue
|
||||
raise util.OperationError(_("No compute of backup target %(target)s reaches its storage pool"), target=target.name)
|
||||
|
||||
|
||||
def _backup(params):
|
||||
return Backup.objects.select_related("target").get(uuid=params["backup"])
|
||||
|
||||
|
||||
@register
|
||||
class DeleteBackup(Kind):
|
||||
"""The manifest goes first, so the target no longer holds a complete
|
||||
backup; then the other files of the backup, then its row."""
|
||||
|
||||
name = "backup.delete"
|
||||
label = _("Delete backup")
|
||||
|
||||
def normalize(self, raw):
|
||||
return {"backup": str(UUID(str(raw["backup"])))}
|
||||
|
||||
def plan(self, user, params):
|
||||
_superuser(user)
|
||||
backup = _backup(params)
|
||||
if backup.state == Backup.CREATING:
|
||||
raise util.OperationError(_("This backup is being made; cancel its job to stop it"))
|
||||
return Plan(
|
||||
claims={claims.backup_key(backup.uuid): Claim.EXCLUSIVE,
|
||||
claims.backup_target_key(backup.target_id): Claim.EXCLUSIVE},
|
||||
resource=claims.backup_key(backup.uuid),
|
||||
label=f"{backup.target.name}/{backup.vm_name}",
|
||||
intent={"compute": backup.compute_name, "vm": backup.vm_name, "uuid": backup.vm_uuid,
|
||||
"time": timezone.localtime(backup.created_at).strftime("%Y-%m-%d %H:%M")},
|
||||
)
|
||||
|
||||
def run(self, op, ctx):
|
||||
_superuser(op.user)
|
||||
backup = _backup(op.params)
|
||||
pool = _target_pool(backup.target)
|
||||
ctx.record_intent(deleting=True)
|
||||
return self._delete(backup, pool)
|
||||
|
||||
@staticmethod
|
||||
def _delete(backup, pool):
|
||||
Backup.objects.filter(pk=backup.pk).update(state=Backup.DELETING)
|
||||
# another compute may have written the files: this one's pool lists them after a refresh
|
||||
pool.refresh(0)
|
||||
manifest = f"{backup.prefix}-manifest.json"
|
||||
remove_files(pool, [manifest])
|
||||
remove_files(pool, [n for n in pool.listVolumes() if n.startswith(backup.prefix + "-") and n != manifest])
|
||||
backup.delete()
|
||||
return {}
|
||||
|
||||
def reconcile(self, op):
|
||||
backup = Backup.objects.select_related("target").filter(uuid=op.params["backup"]).first()
|
||||
if backup is None:
|
||||
return Outcome(Operation.SUCCEEDED)
|
||||
return Outcome(Operation.SUCCEEDED, result=self._delete(backup, _target_pool(backup.target)))
|
||||
|
||||
def log_entry(self, op, state):
|
||||
backup = f"Backup {op.intent['time']} of {op.intent['vm']}"
|
||||
message = f"{backup} deleted" if state == Operation.SUCCEEDED else f"{backup}: delete ({state})"
|
||||
return op.intent["compute"], op.intent["vm"], op.intent["uuid"], message
|
||||
|
|
|
|||
|
|
@ -27,3 +27,7 @@ class CreateBackupSerializer(serializers.Serializer):
|
|||
target = serializers.PrimaryKeyRelatedField(queryset=BackupTarget.objects.all())
|
||||
frozen = serializers.BooleanField(default=False)
|
||||
submission_key = serializers.CharField(write_only=True)
|
||||
|
||||
|
||||
class SubmissionSerializer(serializers.Serializer):
|
||||
submission_key = serializers.CharField(write_only=True)
|
||||
|
|
|
|||
1
vmbackups/templates/vmbackups/consistency.html
Normal file
1
vmbackups/templates/vmbackups/consistency.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
{% load i18n %}{% if backup.consistency == "offline" %}{% trans "Shut off" %}{% elif backup.consistency == "frozen" %}{% trans "Frozen" %}{% elif backup.consistency == "crash" %}{% trans "Crash-consistent" %}{% else %}–{% endif %}
|
||||
3
vmbackups/templates/vmbackups/delete_form.html
Normal file
3
vmbackups/templates/vmbackups/delete_form.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{% load i18n %}{% load operations %}{% load bootstrap_icons %}{% if backup.state != "creating" %}<form method="post" action="{% url 'vmbackups:delete' backup.uuid %}" class="d-inline">{% csrf_token %}{% submission_key %}
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" aria-label="{% trans "Delete" %}" title="{% trans "Delete" %}"
|
||||
data-confirm="{% blocktrans with time=backup.created_at|date:"Y-m-d H:i" vm=backup.vm_name %}Delete the backup of {{ vm }} taken {{ time }}? Its files are removed from the target.{% endblocktrans %}">{% bs_icon 'trash' %}</button></form>{% endif %}
|
||||
71
vmbackups/templates/vmbackups/index.html
Normal file
71
vmbackups/templates/vmbackups/index.html
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load operations %}
|
||||
|
||||
{% block title %}{% trans "Backups" %}{% endblock %}
|
||||
|
||||
{% block page_heading %}{% trans "Backups" %}{% endblock page_heading %}
|
||||
|
||||
{% block page_heading_extra %}<a class="btn btn-outline-primary btn-sm" href="{% url 'vmbackups:targets' %}">{% bs_icon 'hdd-network' %} {% trans "Backup targets" %}</a>{% endblock page_heading_extra %}
|
||||
|
||||
{% block content %}
|
||||
<form method="get" class="row g-2 mb-3" aria-label="{% trans "Filter" %}">
|
||||
<div class="col-12 col-md">
|
||||
<label class="visually-hidden" for="filter-vm">{% trans "VM" %}</label>
|
||||
<input type="search" class="form-control" id="filter-vm" name="vm" value="{{ vm }}" placeholder="{% trans "VM name" %}">
|
||||
</div>
|
||||
<div class="col-6 col-md-auto">
|
||||
<label class="visually-hidden" for="filter-target">{% trans "Target" %}</label>
|
||||
<select class="form-select" id="filter-target" name="target">
|
||||
<option value="">{% trans "All targets" %}</option>
|
||||
{% for t in targets %}<option value="{{ t.id }}"{% if target == t.id|stringformat:"d" %} selected{% endif %}>{{ t.name }}</option>{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-md-auto">
|
||||
<label class="visually-hidden" for="filter-state">{% trans "State" %}</label>
|
||||
<select class="form-select" id="filter-state" name="state">
|
||||
<option value="">{% trans "All states" %}</option>
|
||||
<option value="ready"{% if state == "ready" %} selected{% endif %}>{% trans "Ready" %}</option>
|
||||
<option value="creating"{% if state == "creating" %} selected{% endif %}>{% trans "Creating" %}</option>
|
||||
<option value="failed"{% if state == "failed" %} selected{% endif %}>{% trans "Failed" %}</option>
|
||||
<option value="deleting"{% if state == "deleting" %} selected{% endif %}>{% trans "Deleting" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-md-auto d-grid">
|
||||
<button type="submit" class="btn btn-outline-secondary">{% bs_icon 'filter' %} {% trans "Filter" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if rows %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle" id="backups">
|
||||
<thead>
|
||||
<tr><th>{% trans "Time" %}</th><th>{% trans "VM" %}</th><th>{% trans "Target" %}</th><th>{% trans "Consistency" %}</th>
|
||||
<th class="text-end">{% trans "Size" %}</th><th>{% trans "State" %}</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for backup in rows %}
|
||||
<tr>
|
||||
<td class="text-nowrap">{{ backup.created_at|date:"Y-m-d H:i" }}</td>
|
||||
<td>
|
||||
{% if backup.instance %}<a href="{% url 'instances:instance' backup.instance.id %}">{{ backup.vm_name }}</a>
|
||||
{% else %}{{ backup.vm_name }} <span class="badge text-bg-secondary">{% trans "removed" %}</span>{% endif %}
|
||||
<div class="small text-body-secondary">{{ backup.compute_name }}</div>
|
||||
</td>
|
||||
<td>{{ backup.target.name }}</td>
|
||||
<td>{% include "vmbackups/consistency.html" %}</td>
|
||||
<td class="text-end text-nowrap">{% if backup.size %}{{ backup.size|filesizeformat }}{% else %}–{% endif %}</td>
|
||||
<td>{% include "vmbackups/state.html" %}</td>
|
||||
<td class="text-end">{% include "vmbackups/delete_form.html" %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% elif vm or target or state %}
|
||||
<div class="alert alert-info">{% trans "No backup matches the filter." %}</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info">{% trans "No backup yet. Back a VM up from its Backups tab." %}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
1
vmbackups/templates/vmbackups/state.html
Normal file
1
vmbackups/templates/vmbackups/state.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
{% load i18n %}{% if backup.state == "ready" %}<span class="badge text-bg-success">{% trans "Ready" %}</span>{% elif backup.state == "creating" %}<span class="badge text-bg-info">{% trans "Creating" %}</span>{% elif backup.state == "deleting" %}<span class="badge text-bg-warning">{% trans "Deleting" %}</span>{% else %}<span class="badge text-bg-danger">{% trans "Failed" %}</span>{% endif %}{% if backup.operation_id %} <a class="small" href="{% url 'operations:job' backup.operation_id %}">{% trans "Job" %}</a>{% endif %}
|
||||
|
|
@ -33,22 +33,17 @@
|
|||
<div class="table-responsive mt-3">
|
||||
<table class="table table-sm align-middle mb-0">
|
||||
<thead>
|
||||
<tr><th>{% trans "Time" %}</th><th>{% trans "Target" %}</th><th>{% trans "Consistency" %}</th><th class="text-end">{% trans "Size" %}</th><th>{% trans "State" %}</th></tr>
|
||||
<tr><th>{% trans "Time" %}</th><th>{% trans "Target" %}</th><th>{% trans "Consistency" %}</th><th class="text-end">{% trans "Size" %}</th><th>{% trans "State" %}</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for backup in backups.rows %}
|
||||
<tr>
|
||||
<td class="text-nowrap">{{ backup.created_at|date:"Y-m-d H:i" }}</td>
|
||||
<td>{{ backup.target.name }}</td>
|
||||
<td>{{ backup.get_consistency_display }}</td>
|
||||
<td>{% include "vmbackups/consistency.html" %}</td>
|
||||
<td class="text-end text-nowrap">{% if backup.size %}{{ backup.size|filesizeformat }}{% else %}–{% endif %}</td>
|
||||
<td>
|
||||
{% if backup.state == "ready" %}<span class="badge text-bg-success">{% trans "Ready" %}</span>
|
||||
{% elif backup.state == "creating" %}<span class="badge text-bg-info">{% trans "Creating" %}</span>
|
||||
{% elif backup.state == "deleting" %}<span class="badge text-bg-warning">{% trans "Deleting" %}</span>
|
||||
{% else %}<span class="badge text-bg-danger">{% trans "Failed" %}</span>{% endif %}
|
||||
{% if backup.operation_id %}<a class="small ms-1" href="{% url 'operations:job' backup.operation_id %}">{% trans "Job" %}</a>{% endif %}
|
||||
</td>
|
||||
<td>{% include "vmbackups/state.html" %}</td>
|
||||
<td class="text-end">{% include "vmbackups/delete_form.html" %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ class BackupTabTests(PageControls, TransactionTestCase):
|
|||
self.controls(admin)
|
||||
page = lxml_html.fromstring(self.last_page)
|
||||
self.assertIn("ctl-vm has TPM state", page.xpath("string(//div[@id='backups'])"))
|
||||
self.assertFalse(page.xpath("//div[@id='backups']//form"))
|
||||
self.assertFalse(page.xpath("//div[@id='backups']//form[contains(@action, '/create/')]"))
|
||||
|
||||
def test_owners_have_no_backups_tab(self):
|
||||
self.controls(self.user("tab-owner", owner={"is_change": True}))
|
||||
|
|
|
|||
149
vmbackups/tests/test_delete.py
Normal file
149
vmbackups/tests/test_delete.py
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
"""backup.delete: the manifest first, then the other files, then the row;
|
||||
the Backups page lists every backup."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
from uuid import uuid4
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TransactionTestCase
|
||||
from django.urls import reverse
|
||||
from lxml import html as lxml_html
|
||||
|
||||
from appsettings.settings import get_settings
|
||||
from computes.models import Compute
|
||||
from instances.models import Instance
|
||||
from operations import jobs
|
||||
from operations.jobs import Context
|
||||
from operations.models import Operation, acquire
|
||||
from vmbackups.jobs import DeleteBackup
|
||||
from vmbackups.models import Backup, BackupTarget, BackupTargetPool
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
WORKER = "wvc-test:1:a"
|
||||
|
||||
|
||||
class DeleteBackupTests(TransactionTestCase):
|
||||
def setUp(self):
|
||||
get_settings()
|
||||
self.admin = get_user_model().objects.create_superuser("del_admin", "a@example.com", "pw")
|
||||
self.compute = Compute.objects.create(name="h1", hostname="192.0.2.31", login="u", password="p", type=1)
|
||||
self.vm = Instance.objects.create(compute=self.compute, name="vm1", uuid="31313131-0000-4000-8000-000000000001")
|
||||
self.target = BackupTarget.objects.create(name="nfs1")
|
||||
BackupTargetPool.objects.create(target=self.target, compute=self.compute, pool="b1", pool_uuid="u")
|
||||
self.backup = Backup.objects.create(target=self.target, instance=self.vm, vm_uuid=self.vm.uuid, vm_name="vm1",
|
||||
compute_name="h1", state=Backup.READY)
|
||||
prefix = self.backup.prefix
|
||||
self.pool = MagicMock()
|
||||
self.pool.listVolumes.return_value = [f"{prefix}-vda.qcow2", f"{prefix}-domain.xml", f"{prefix}-manifest.json",
|
||||
"wvc-00000000-0000-4000-8000-000000000009-vda.qcow2", "other.img"]
|
||||
self.removed = []
|
||||
for name, value in (
|
||||
("vmbackups.jobs.wvmConnect", MagicMock()),
|
||||
("vmbackups.jobs.target_pool", MagicMock(return_value=self.pool)),
|
||||
("vmbackups.jobs.remove_files", MagicMock(side_effect=lambda pool, names: self.removed.append(list(names)))),
|
||||
):
|
||||
patcher = patch(name, value)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def submit(self):
|
||||
op = jobs.submit("backup.delete", self.admin, {"backup": str(self.backup.uuid)}, f"key-{uuid4().hex[:12]}")
|
||||
acquire(WORKER, "wvc-test")
|
||||
Operation.objects.filter(pk=op.pk).update(state=Operation.RUNNING, worker=WORKER)
|
||||
op.refresh_from_db()
|
||||
return op
|
||||
|
||||
def run_job(self, op):
|
||||
return DeleteBackup().run(op, Context(op, SimpleNamespace(identity=WORKER)))
|
||||
|
||||
def test_the_manifest_goes_first(self):
|
||||
self.run_job(self.submit())
|
||||
prefix = self.backup.prefix
|
||||
self.assertEqual(self.removed, [[f"{prefix}-manifest.json"], [f"{prefix}-vda.qcow2", f"{prefix}-domain.xml"]])
|
||||
self.assertFalse(Backup.objects.exists())
|
||||
|
||||
def test_the_pool_is_refreshed_before_the_manifest_is_looked_up(self):
|
||||
# another compute made the backup: this one's pool lists its files only after a refresh
|
||||
self.pool.refresh.side_effect = lambda flags: self.removed.append("refresh")
|
||||
self.run_job(self.submit())
|
||||
self.assertEqual(self.removed[0], "refresh")
|
||||
|
||||
def test_an_interrupted_delete_is_finished_by_recovery(self):
|
||||
op = self.submit()
|
||||
with patch("vmbackups.jobs.remove_files", side_effect=[None, RuntimeError("worker gone")]):
|
||||
with self.assertRaises(RuntimeError):
|
||||
self.run_job(op)
|
||||
self.backup.refresh_from_db()
|
||||
self.assertEqual(self.backup.state, Backup.DELETING)
|
||||
op.refresh_from_db()
|
||||
self.assertEqual(DeleteBackup().reconcile(op).state, Operation.SUCCEEDED)
|
||||
self.assertFalse(Backup.objects.exists())
|
||||
|
||||
def test_a_creating_backup_is_not_deleted(self):
|
||||
Backup.objects.filter(pk=self.backup.pk).update(state=Backup.CREATING)
|
||||
with self.assertRaisesMessage(OperationError, "being made"):
|
||||
self.submit()
|
||||
|
||||
def test_a_target_no_compute_reaches_is_refused(self):
|
||||
op = self.submit()
|
||||
with patch("vmbackups.jobs.target_pool", side_effect=OperationError("Storage pool %(pool)s is gone", pool="b1")):
|
||||
with self.assertRaisesMessage(OperationError, "nfs1"):
|
||||
self.run_job(op)
|
||||
self.assertTrue(Backup.objects.filter(state=Backup.READY).exists())
|
||||
|
||||
def test_the_log_row(self):
|
||||
op = self.submit()
|
||||
self.run_job(op)
|
||||
entry = DeleteBackup().log_entry(op, Operation.SUCCEEDED)
|
||||
self.assertEqual(entry[:3], ("h1", "vm1", self.vm.uuid))
|
||||
self.assertRegex(entry[3], r"^Backup \d{4}-\d\d-\d\d \d\d:\d\d of vm1 deleted$")
|
||||
|
||||
def test_api_delete(self):
|
||||
self.client.force_login(self.admin)
|
||||
response = self.client.delete(f"/api/v1/backups/{self.backup.uuid}/", {"submission_key": "key-api-del1"},
|
||||
content_type="application/json")
|
||||
self.assertEqual(response.status_code, 202, response.content)
|
||||
self.assertEqual(response.json()["kind"], "backup.delete")
|
||||
|
||||
def test_the_page_deletes_and_goes_back(self):
|
||||
self.client.force_login(self.admin)
|
||||
url = reverse("vmbackups:delete", args=[self.backup.uuid])
|
||||
response = self.client.post(url, {"submission_key": "key-page-del1"}, HTTP_REFERER="http://testserver/backups/")
|
||||
op = Operation.objects.get()
|
||||
self.assertEqual(op.kind, "backup.delete")
|
||||
# the job's own page: neither the Backups page nor the VM page shows a backup's job
|
||||
self.assertRedirects(response, reverse("operations:job", args=[op.pk]), fetch_redirect_response=False)
|
||||
|
||||
|
||||
class IndexTests(TransactionTestCase):
|
||||
def setUp(self):
|
||||
self.admin = get_user_model().objects.create_superuser("idx_admin", "a@example.com", "pw")
|
||||
compute = Compute.objects.create(name="h1", hostname="192.0.2.32", login="u", password="p", type=1)
|
||||
vm = Instance.objects.create(compute=compute, name="web1", uuid="32323232-0000-4000-8000-000000000001")
|
||||
self.t1 = BackupTarget.objects.create(name="nfs1")
|
||||
self.t2 = BackupTarget.objects.create(name="nfs2")
|
||||
Backup.objects.create(target=self.t1, instance=vm, vm_uuid=vm.uuid, vm_name="web1", compute_name="h1",
|
||||
state=Backup.READY)
|
||||
Backup.objects.create(target=self.t2, instance=None, vm_uuid="u2", vm_name="db1", compute_name="h1",
|
||||
state=Backup.FAILED)
|
||||
|
||||
def rows(self, query=""):
|
||||
self.client.force_login(self.admin)
|
||||
page = lxml_html.fromstring(self.client.get(reverse("vmbackups:index") + query).content)
|
||||
return [" ".join(row.text_content().split()) for row in page.xpath("//table[@id='backups']/tbody/tr")]
|
||||
|
||||
def test_the_index_filters_and_marks_removed_vms(self):
|
||||
rows = self.rows()
|
||||
self.assertEqual(len(rows), 2)
|
||||
self.assertIn("removed", next(r for r in rows if "db1" in r))
|
||||
self.assertNotIn("removed", next(r for r in rows if "web1" in r))
|
||||
self.assertEqual(len(self.rows("?vm=WEB")), 1)
|
||||
self.assertIn("db1", self.rows(f"?target={self.t2.pk}")[0])
|
||||
self.assertIn("db1", self.rows("?state=failed")[0])
|
||||
self.assertEqual(self.rows("?state=ready&vm=db"), [])
|
||||
|
||||
def test_only_superusers(self):
|
||||
user = get_user_model().objects.create_user("idx_user", password="pw")
|
||||
self.client.force_login(user)
|
||||
self.assertEqual(self.client.get(reverse("vmbackups:index")).status_code, 403)
|
||||
|
|
@ -5,6 +5,8 @@ from . import views
|
|||
app_name = "vmbackups"
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.index, name="index"),
|
||||
path("<uuid:uuid>/delete/", views.delete, name="delete"),
|
||||
path("targets/", views.targets, name="targets"),
|
||||
path("targets/<int:target_id>/", views.target, name="target"),
|
||||
path("vm/<int:instance_id>/create/", views.create, name="create"),
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ from instances.models import Instance
|
|||
from logs.audit import audit
|
||||
from operations import claims, jobs
|
||||
from operations.utils import busy_message
|
||||
from webvirtcloud.middleware import error_text
|
||||
from webvirtcloud.middleware import error_text, same_origin_referer
|
||||
from vrtManager.backup import pool_space, target_pool
|
||||
from vrtManager.connection import wvmConnect
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
from .forms import TargetForm, TargetPoolForm
|
||||
from .models import BackupTarget
|
||||
from .models import Backup, BackupTarget
|
||||
from .utils import inside_vm_pool
|
||||
|
||||
|
||||
|
|
@ -125,3 +125,37 @@ def create(request, instance_id):
|
|||
else:
|
||||
jobs.remember_job(request, op)
|
||||
return redirect(page)
|
||||
|
||||
|
||||
@superuser_only
|
||||
def index(request):
|
||||
"""Every backup, newest first; filtered by VM name, target and state."""
|
||||
rows = Backup.objects.select_related("target", "instance")
|
||||
vm, target, state = request.GET.get("vm", "").strip(), request.GET.get("target", ""), request.GET.get("state", "")
|
||||
if vm:
|
||||
rows = rows.filter(vm_name__icontains=vm)
|
||||
if target.isdigit():
|
||||
rows = rows.filter(target_id=int(target))
|
||||
if state in dict(Backup.STATES):
|
||||
rows = rows.filter(state=state)
|
||||
return render(request, "vmbackups/index.html", {
|
||||
"rows": rows, "targets": BackupTarget.objects.order_by("name"),
|
||||
"vm": vm, "target": target, "state": state,
|
||||
})
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
def delete(request, uuid):
|
||||
backup = get_object_or_404(Backup, uuid=uuid)
|
||||
try:
|
||||
op = jobs.submit("backup.delete", request.user, {"backup": str(backup.uuid)},
|
||||
request.POST.get("submission_key", ""))
|
||||
except claims.Busy as busy:
|
||||
messages.error(request, busy_message(busy, request.user))
|
||||
except (jobs.SubmissionConflict, libvirtError) as err:
|
||||
messages.error(request, error_text(request, err))
|
||||
else:
|
||||
# the job's page follows it: the pages listing backups show no backup's job
|
||||
return redirect("operations:job", op.pk)
|
||||
return redirect(same_origin_referer(request, reverse("vmbackups:index")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue