mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
feat(vmbackups): backup targets: a storage pool per host, checked to be one directory
A backup target is a dir or NFS storage pool the administrator makes on the hosts and registers on the new Backup targets page (Backups in the menu, superusers only). Each compute's pool is kept with its UUID, so a pool replaced by another of the same name is refused. A second compute's pool is accepted only when it is the same directory as the target's first (the exclusive-create check migrations use). The target page shows each pool's space and warns when the target is inside another pool's directory, as its backups would share that storage's failures. The storage pages refuse to delete a target's pool, and a volume of a backup (page and API): backups are deleted from the Backups pages.
This commit is contained in:
parent
c7d6f90823
commit
022737f143
17 changed files with 821 additions and 54 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-16 19:52+0000\n"
|
||||
"POT-Creation-Date: 2026-11-17 04:36+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"
|
||||
|
|
@ -75,7 +75,8 @@ msgstr "Geçersiz anahtar"
|
|||
#: interfaces/templates/interface.html:119 networks/templates/network.html:145
|
||||
#: networks/templates/network.html:373 nwfilters/templates/nwfilters.html:29
|
||||
#: storages/templates/storage.html:123 virtsecrets/forms.py:34
|
||||
#: virtsecrets/forms.py:36
|
||||
#: virtsecrets/forms.py:36 vmbackups/forms.py:22
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Name"
|
||||
msgstr "Ad"
|
||||
|
||||
|
|
@ -508,7 +509,7 @@ msgid "Signing in..."
|
|||
msgstr "Oturum açılıyor..."
|
||||
|
||||
#: accounts/templates/profile.html:6 accounts/templates/profile.html:8
|
||||
#: templates/navbar.html:50
|
||||
#: templates/navbar.html:53
|
||||
msgid "Profile"
|
||||
msgstr "Profil"
|
||||
|
||||
|
|
@ -540,6 +541,8 @@ msgstr "Kullanıcıya anahtar ekleme formu"
|
|||
#: instances/templates/create_flavors.html:20
|
||||
#: instances/templates/instances/boot_device.html:17
|
||||
#: networks/templates/network.html:134 nwfilters/templates/nwfilter.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:49
|
||||
#: vmbackups/templates/vmbackups/targets.html:40
|
||||
msgid "Add"
|
||||
msgstr "Ekle"
|
||||
|
||||
|
|
@ -743,7 +746,7 @@ msgstr "İzinler"
|
|||
#: admin/forms.py:103 admin/templates/admin/group_list.html:6
|
||||
#: admin/templates/admin/group_list.html:8
|
||||
#: admin/templates/admin/group_list.html:24
|
||||
#: admin/templates/admin/user_form.html:124 templates/navbar.html:33
|
||||
#: admin/templates/admin/user_form.html:124 templates/navbar.html:36
|
||||
msgid "Groups"
|
||||
msgstr "Gruplar"
|
||||
|
||||
|
|
@ -916,7 +919,7 @@ msgstr "Aramayla eşleşen grup yok."
|
|||
|
||||
#: admin/templates/admin/logs.html:6 admin/templates/admin/logs.html:8
|
||||
#: admin/templates/admin/logs.html:19
|
||||
#: instances/templates/instances/stats_tab.html:20 templates/navbar.html:34
|
||||
#: instances/templates/instances/stats_tab.html:20 templates/navbar.html:37
|
||||
msgid "Logs"
|
||||
msgstr "Loglar"
|
||||
|
||||
|
|
@ -984,7 +987,7 @@ msgstr "Başarısız"
|
|||
|
||||
#: admin/templates/admin/tombstone_list.html:6
|
||||
#: admin/templates/admin/tombstone_list.html:8
|
||||
#: admin/templates/admin/tombstone_list.html:19 templates/navbar.html:35
|
||||
#: admin/templates/admin/tombstone_list.html:19 templates/navbar.html:38
|
||||
msgid "Removed VMs"
|
||||
msgstr "Kaldırılan Sanal Makineler"
|
||||
|
||||
|
|
@ -1115,7 +1118,7 @@ msgid "New user"
|
|||
msgstr "Yeni kullanıcı"
|
||||
|
||||
#: admin/templates/admin/user_list.html:19 admin/views.py:179
|
||||
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:32
|
||||
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:35
|
||||
msgid "Users"
|
||||
msgstr "Kullanıcılar"
|
||||
|
||||
|
|
@ -1776,7 +1779,7 @@ msgstr "Ayar grupları"
|
|||
msgid "Appearance"
|
||||
msgstr "Görünüm"
|
||||
|
||||
#: appsettings/templates/appsettings.html:35 templates/navbar.html:48
|
||||
#: appsettings/templates/appsettings.html:35 templates/navbar.html:51
|
||||
msgid "Language"
|
||||
msgstr "Dil"
|
||||
|
||||
|
|
@ -3942,7 +3945,7 @@ msgstr "Sunucunun bir havuzunda zaten bulunan bir birim."
|
|||
#: instances/templates/create_instance_w2.html:137
|
||||
#: instances/templates/create_instance_w2.html:165
|
||||
#: instances/templates/instances/move_disk.html:16
|
||||
#: instances/templates/instances/settings_tab.html:223
|
||||
#: instances/templates/instances/settings_tab.html:223 vmbackups/forms.py:13
|
||||
msgid "Storage pool"
|
||||
msgstr "Depolama havuzu"
|
||||
|
||||
|
|
@ -4176,7 +4179,6 @@ msgid "Choose the host the VM runs on."
|
|||
msgstr "Sanal makinenin çalışacağı sunucuyu seçin."
|
||||
|
||||
#: instances/templates/create_inst_block.html:22
|
||||
#| msgid "In maintenance"
|
||||
msgid "Maintenance"
|
||||
msgstr "Bakım"
|
||||
|
||||
|
|
@ -4349,6 +4351,7 @@ msgstr "Aygıt"
|
|||
#: instances/templates/instances/boot_device.html:14
|
||||
#: instances/templates/instances/settings_tab.html:685
|
||||
#: networks/templates/network.html:304
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
msgid "Remove"
|
||||
msgstr "Kaldır"
|
||||
|
||||
|
|
@ -4534,7 +4537,7 @@ msgstr "Boyutlandır"
|
|||
msgid "Snapshot"
|
||||
msgstr "Anlık Görüntü"
|
||||
|
||||
#: instances/templates/instance.html:102 templates/navbar.html:37
|
||||
#: instances/templates/instance.html:102 templates/navbar.html:40
|
||||
msgid "Settings"
|
||||
msgstr "Ayarlar"
|
||||
|
||||
|
|
@ -8518,7 +8521,7 @@ msgstr "Yalnızca belirsiz bir iş çözülebilir"
|
|||
#: operations/templates/operations/job.html:11
|
||||
#: operations/templates/operations/jobs.html:7
|
||||
#: operations/templates/operations/jobs.html:9
|
||||
#: operations/templates/operations/jobs.html:20 templates/navbar.html:24
|
||||
#: operations/templates/operations/jobs.html:20 templates/navbar.html:27
|
||||
msgid "Jobs"
|
||||
msgstr "İşler"
|
||||
|
||||
|
|
@ -8782,8 +8785,8 @@ msgstr ""
|
|||
msgid "The worker stopped before the job changed anything"
|
||||
msgstr "Worker, iş herhangi bir şeyi değiştirmeden önce durdu"
|
||||
|
||||
#: storages/api/viewsets.py:144 storages/api/viewsets.py:160
|
||||
#: storages/api/viewsets.py:196 storages/api/viewsets.py:218
|
||||
#: storages/api/viewsets.py:145 storages/api/viewsets.py:161
|
||||
#: storages/api/viewsets.py:197 storages/api/viewsets.py:220
|
||||
msgid "Pool is not active"
|
||||
msgstr "Havuz etkin değil"
|
||||
|
||||
|
|
@ -9345,36 +9348,36 @@ msgstr "Son parça bildirilen dosya boyutuyla eşleşmiyor"
|
|||
msgid "The partial upload is missing"
|
||||
msgstr "Kısmi yükleme bulunamadı"
|
||||
|
||||
#: storages/views.py:32
|
||||
#: storages/views.py:33
|
||||
msgid "No file chunk was submitted."
|
||||
msgstr "Dosya parçası gönderilmedi."
|
||||
|
||||
#: storages/views.py:38
|
||||
#: storages/views.py:39
|
||||
msgid "Invalid chunk parameters."
|
||||
msgstr "Geçersiz parça parametreleri."
|
||||
|
||||
#: storages/views.py:40
|
||||
#: storages/views.py:41
|
||||
msgid "Invalid chunk index or total chunks."
|
||||
msgstr "Geçersiz parça dizini veya toplam parça sayısı."
|
||||
|
||||
#: storages/views.py:45
|
||||
#: storages/views.py:46
|
||||
msgid "Invalid file size."
|
||||
msgstr "Geçersiz dosya boyutu."
|
||||
|
||||
#: storages/views.py:54
|
||||
#: storages/views.py:55
|
||||
msgid "Upload session is busy. Please retry."
|
||||
msgstr "Yükleme oturumu meşgul. Lütfen yeniden deneyin."
|
||||
|
||||
#: storages/views.py:56
|
||||
#: storages/views.py:57
|
||||
msgid "ISO image already exists"
|
||||
msgstr "ISO imajı zaten mevcut"
|
||||
|
||||
#: storages/views.py:184
|
||||
#: storages/views.py:187
|
||||
#, python-format
|
||||
msgid "Volume: %(vol)s is deleted."
|
||||
msgstr "Birim: %(vol)s silindi."
|
||||
|
||||
#: storages/views.py:201
|
||||
#: storages/views.py:204
|
||||
#, python-format
|
||||
msgid "Image file %(name)s is created successfully"
|
||||
msgstr "İmaj dosyası %(name)s başarıyla oluşturuldu"
|
||||
|
|
@ -9507,15 +9510,19 @@ msgstr "Geri"
|
|||
msgid "Home"
|
||||
msgstr "Ana sayfa"
|
||||
|
||||
#: templates/navbar.html:28
|
||||
#: templates/navbar.html:21 vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Backups"
|
||||
msgstr "Yedekler"
|
||||
|
||||
#: templates/navbar.html:31
|
||||
msgid "Administration"
|
||||
msgstr "Yönetim"
|
||||
|
||||
#: templates/navbar.html:36
|
||||
#: templates/navbar.html:39
|
||||
msgid "VM report (.xlsx)"
|
||||
msgstr "Sanal makine raporu (.xlsx)"
|
||||
|
||||
#: templates/navbar.html:54
|
||||
#: templates/navbar.html:57
|
||||
msgid "Log Out"
|
||||
msgstr "Oturumu Kapat"
|
||||
|
||||
|
|
@ -9698,6 +9705,125 @@ msgstr ""
|
|||
"Eski değerin yerini hemen alır; bir parolanın şifrelediği veriler yeniden "
|
||||
"şifrelenmez."
|
||||
|
||||
#: vmbackups/forms.py:12
|
||||
msgid "Compute"
|
||||
msgstr "Sunucu"
|
||||
|
||||
#: vmbackups/forms.py:28
|
||||
msgid "A backup target with this name exists"
|
||||
msgstr "Bu adla bir yedek hedefi zaten var"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
#: vmbackups/templates/vmbackups/targets.html:8
|
||||
msgid "Backup targets"
|
||||
msgstr "Yedek hedefleri"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
msgid_plural "%(counter)s backups."
|
||||
msgstr[0] "%(counter)s yedek."
|
||||
msgstr[1] "%(counter)s yedek."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
msgid ""
|
||||
"Remove this storage pool from the target? The pool and its files stay on the "
|
||||
"host."
|
||||
msgstr ""
|
||||
"Bu depolama havuzu hedeften çıkarılsın mı? Havuz ve dosyaları sunucuda kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The target is inside storage pool %(pool)s: its backups are lost with that "
|
||||
"storage."
|
||||
msgstr ""
|
||||
"Hedef %(pool)s depolama havuzunun içinde: o depolama kaybolursa yedekler de "
|
||||
"kaybolur."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
msgid "Add a compute's storage pool"
|
||||
msgstr "Bir sunucunun depolama havuzunu ekle"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:45
|
||||
msgid ""
|
||||
"The pool must be the same directory as the target's other pools, as an NFS "
|
||||
"share mounted on each host."
|
||||
msgstr ""
|
||||
"Havuz, hedefin diğer havuzlarıyla aynı dizin olmalıdır; örneğin her sunucuya "
|
||||
"bağlanmış bir NFS paylaşımı."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
msgid "Delete this backup target? Its storage pools stay on the hosts."
|
||||
msgstr "Bu yedek hedefi silinsin mi? Depolama havuzları sunucularda kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
msgid "Delete target"
|
||||
msgstr "Hedefi sil"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:11
|
||||
msgid ""
|
||||
"A backup target is a directory or NFS storage pool made on the hosts. Use "
|
||||
"storage apart from the VMs' disks: a target on the same storage is lost with "
|
||||
"it."
|
||||
msgstr ""
|
||||
"Yedek hedefi, sunucularda oluşturulmuş bir dizin veya NFS depolama havuzudur."
|
||||
" Sanal makine disklerinden ayrı bir depolama kullanın: aynı depolamadaki bir "
|
||||
"hedef onunla birlikte kaybolur."
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Storage pools"
|
||||
msgstr "Depolama havuzları"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:31
|
||||
msgid "No backup target yet."
|
||||
msgstr "Henüz yedek hedefi yok."
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:35
|
||||
msgid "Add a backup target"
|
||||
msgstr "Yedek hedefi ekle"
|
||||
|
||||
#: vmbackups/utils.py:25
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the "
|
||||
"Backups page"
|
||||
msgstr ""
|
||||
"%(volume)s birimi %(vm)s yedeğine ait; yedeği Yedekler sayfasından silin"
|
||||
|
||||
#: vmbackups/utils.py:35
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is backup target %(target)s; remove it from the target "
|
||||
"first"
|
||||
msgstr ""
|
||||
"%(pool)s depolama havuzu %(target)s yedek hedefidir; önce hedeften çıkarın"
|
||||
|
||||
#: vmbackups/views.py:61 vmbackups/views.py:69
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has backups; delete them first"
|
||||
msgstr "%(target)s yedek hedefinde yedekler var; önce onları silin"
|
||||
|
||||
#: vmbackups/views.py:86
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s of %(compute)s is not the same directory as storage "
|
||||
"pool %(other)s of %(other_compute)s"
|
||||
msgstr ""
|
||||
"%(compute)s sunucusunun %(pool)s depolama havuzu, %(other_compute)s "
|
||||
"sunucusunun %(other)s depolama havuzuyla aynı dizin değil"
|
||||
|
||||
#: vrtManager/backup.py:30
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is not an active directory or NFS pool of this host, or"
|
||||
" not the one the backup target registered"
|
||||
msgstr ""
|
||||
"%(pool)s depolama havuzu bu sunucuda etkin bir dizin veya NFS havuzu değil ya"
|
||||
" da yedek hedefinin kaydettiği havuz değil"
|
||||
|
||||
#: vrtManager/connection.py:45
|
||||
msgid "Connection closed (error)"
|
||||
msgstr "Bağlantı kapandı (hata)"
|
||||
|
|
@ -10957,10 +11083,10 @@ msgid "Secret %(uuid)s is used by %(named)s; remove it from them first"
|
|||
msgstr ""
|
||||
"%(uuid)s parolası %(named)s tarafından kullanılıyor; önce onlardan kaldırın"
|
||||
|
||||
#: webvirtcloud/settings.py:319
|
||||
#: webvirtcloud/settings.py:320
|
||||
msgid "Localhost"
|
||||
msgstr "Yerel sunucu"
|
||||
|
||||
#: webvirtcloud/settings.py:320
|
||||
#: webvirtcloud/settings.py:321
|
||||
msgid "All interfaces"
|
||||
msgstr "Tüm arabirimler"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-16 19:52+0000\n"
|
||||
"POT-Creation-Date: 2026-11-17 04:36+0000\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
|
@ -72,7 +72,8 @@ msgstr "无效的密钥"
|
|||
#: interfaces/templates/interface.html:119 networks/templates/network.html:145
|
||||
#: networks/templates/network.html:373 nwfilters/templates/nwfilters.html:29
|
||||
#: storages/templates/storage.html:123 virtsecrets/forms.py:34
|
||||
#: virtsecrets/forms.py:36
|
||||
#: virtsecrets/forms.py:36 vmbackups/forms.py:22
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Name"
|
||||
msgstr "名称"
|
||||
|
||||
|
|
@ -501,7 +502,7 @@ msgid "Signing in..."
|
|||
msgstr "正在登录…"
|
||||
|
||||
#: accounts/templates/profile.html:6 accounts/templates/profile.html:8
|
||||
#: templates/navbar.html:50
|
||||
#: templates/navbar.html:53
|
||||
msgid "Profile"
|
||||
msgstr "个人资料"
|
||||
|
||||
|
|
@ -532,6 +533,8 @@ msgstr "为用户添加密钥表单"
|
|||
#: instances/templates/create_flavors.html:20
|
||||
#: instances/templates/instances/boot_device.html:17
|
||||
#: networks/templates/network.html:134 nwfilters/templates/nwfilter.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:49
|
||||
#: vmbackups/templates/vmbackups/targets.html:40
|
||||
msgid "Add"
|
||||
msgstr "添加"
|
||||
|
||||
|
|
@ -723,7 +726,7 @@ msgstr "权限"
|
|||
#: admin/forms.py:103 admin/templates/admin/group_list.html:6
|
||||
#: admin/templates/admin/group_list.html:8
|
||||
#: admin/templates/admin/group_list.html:24
|
||||
#: admin/templates/admin/user_form.html:124 templates/navbar.html:33
|
||||
#: admin/templates/admin/user_form.html:124 templates/navbar.html:36
|
||||
msgid "Groups"
|
||||
msgstr "用户组"
|
||||
|
||||
|
|
@ -891,7 +894,7 @@ msgstr "没有与搜索匹配的用户组。"
|
|||
|
||||
#: admin/templates/admin/logs.html:6 admin/templates/admin/logs.html:8
|
||||
#: admin/templates/admin/logs.html:19
|
||||
#: instances/templates/instances/stats_tab.html:20 templates/navbar.html:34
|
||||
#: instances/templates/instances/stats_tab.html:20 templates/navbar.html:37
|
||||
msgid "Logs"
|
||||
msgstr "日志"
|
||||
|
||||
|
|
@ -959,7 +962,7 @@ msgstr "失败"
|
|||
|
||||
#: admin/templates/admin/tombstone_list.html:6
|
||||
#: admin/templates/admin/tombstone_list.html:8
|
||||
#: admin/templates/admin/tombstone_list.html:19 templates/navbar.html:35
|
||||
#: admin/templates/admin/tombstone_list.html:19 templates/navbar.html:38
|
||||
msgid "Removed VMs"
|
||||
msgstr "已移除的虚拟机"
|
||||
|
||||
|
|
@ -1084,7 +1087,7 @@ msgid "New user"
|
|||
msgstr "新建用户"
|
||||
|
||||
#: admin/templates/admin/user_list.html:19 admin/views.py:179
|
||||
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:32
|
||||
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:35
|
||||
msgid "Users"
|
||||
msgstr "用户"
|
||||
|
||||
|
|
@ -1714,7 +1717,7 @@ msgstr "设置分组"
|
|||
msgid "Appearance"
|
||||
msgstr "外观"
|
||||
|
||||
#: appsettings/templates/appsettings.html:35 templates/navbar.html:48
|
||||
#: appsettings/templates/appsettings.html:35 templates/navbar.html:51
|
||||
msgid "Language"
|
||||
msgstr "语言"
|
||||
|
||||
|
|
@ -3743,7 +3746,7 @@ msgstr "主机存储池中已有的卷。"
|
|||
#: instances/templates/create_instance_w2.html:137
|
||||
#: instances/templates/create_instance_w2.html:165
|
||||
#: instances/templates/instances/move_disk.html:16
|
||||
#: instances/templates/instances/settings_tab.html:223
|
||||
#: instances/templates/instances/settings_tab.html:223 vmbackups/forms.py:13
|
||||
msgid "Storage pool"
|
||||
msgstr "存储池"
|
||||
|
||||
|
|
@ -3969,7 +3972,6 @@ msgid "Choose the host the VM runs on."
|
|||
msgstr "选择运行虚拟机的主机。"
|
||||
|
||||
#: instances/templates/create_inst_block.html:22
|
||||
#| msgid "In maintenance"
|
||||
msgid "Maintenance"
|
||||
msgstr "维护"
|
||||
|
||||
|
|
@ -4138,6 +4140,7 @@ msgstr "设备"
|
|||
#: instances/templates/instances/boot_device.html:14
|
||||
#: instances/templates/instances/settings_tab.html:685
|
||||
#: networks/templates/network.html:304
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
msgid "Remove"
|
||||
msgstr "移除"
|
||||
|
||||
|
|
@ -4319,7 +4322,7 @@ msgstr "调整大小"
|
|||
msgid "Snapshot"
|
||||
msgstr "快照"
|
||||
|
||||
#: instances/templates/instance.html:102 templates/navbar.html:37
|
||||
#: instances/templates/instance.html:102 templates/navbar.html:40
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
|
|
@ -8022,7 +8025,7 @@ msgstr "只能处理状态不确定的任务"
|
|||
#: operations/templates/operations/job.html:11
|
||||
#: operations/templates/operations/jobs.html:7
|
||||
#: operations/templates/operations/jobs.html:9
|
||||
#: operations/templates/operations/jobs.html:20 templates/navbar.html:24
|
||||
#: operations/templates/operations/jobs.html:20 templates/navbar.html:27
|
||||
msgid "Jobs"
|
||||
msgstr "任务"
|
||||
|
||||
|
|
@ -8269,8 +8272,8 @@ msgstr "恢复在一小时内无法读取任务状态;请检查虚拟机,然
|
|||
msgid "The worker stopped before the job changed anything"
|
||||
msgstr "工作进程在任务做出任何更改之前停止"
|
||||
|
||||
#: storages/api/viewsets.py:144 storages/api/viewsets.py:160
|
||||
#: storages/api/viewsets.py:196 storages/api/viewsets.py:218
|
||||
#: storages/api/viewsets.py:145 storages/api/viewsets.py:161
|
||||
#: storages/api/viewsets.py:197 storages/api/viewsets.py:220
|
||||
msgid "Pool is not active"
|
||||
msgstr "存储池未激活"
|
||||
|
||||
|
|
@ -8814,36 +8817,36 @@ msgstr "最后一个分块与声明的文件大小不符"
|
|||
msgid "The partial upload is missing"
|
||||
msgstr "部分上传的文件不存在"
|
||||
|
||||
#: storages/views.py:32
|
||||
#: storages/views.py:33
|
||||
msgid "No file chunk was submitted."
|
||||
msgstr "未提交文件分块。"
|
||||
|
||||
#: storages/views.py:38
|
||||
#: storages/views.py:39
|
||||
msgid "Invalid chunk parameters."
|
||||
msgstr "分块参数无效。"
|
||||
|
||||
#: storages/views.py:40
|
||||
#: storages/views.py:41
|
||||
msgid "Invalid chunk index or total chunks."
|
||||
msgstr "分块索引或分块总数无效。"
|
||||
|
||||
#: storages/views.py:45
|
||||
#: storages/views.py:46
|
||||
msgid "Invalid file size."
|
||||
msgstr "文件大小无效。"
|
||||
|
||||
#: storages/views.py:54
|
||||
#: storages/views.py:55
|
||||
msgid "Upload session is busy. Please retry."
|
||||
msgstr "上传会话繁忙,请重试。"
|
||||
|
||||
#: storages/views.py:56
|
||||
#: storages/views.py:57
|
||||
msgid "ISO image already exists"
|
||||
msgstr "ISO 镜像已存在"
|
||||
|
||||
#: storages/views.py:184
|
||||
#: storages/views.py:187
|
||||
#, python-format
|
||||
msgid "Volume: %(vol)s is deleted."
|
||||
msgstr "卷 %(vol)s 已删除。"
|
||||
|
||||
#: storages/views.py:201
|
||||
#: storages/views.py:204
|
||||
#, python-format
|
||||
msgid "Image file %(name)s is created successfully"
|
||||
msgstr "镜像文件 %(name)s 创建成功"
|
||||
|
|
@ -8957,15 +8960,19 @@ msgstr "返回"
|
|||
msgid "Home"
|
||||
msgstr "首页"
|
||||
|
||||
#: templates/navbar.html:28
|
||||
#: templates/navbar.html:21 vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Backups"
|
||||
msgstr "备份"
|
||||
|
||||
#: templates/navbar.html:31
|
||||
msgid "Administration"
|
||||
msgstr "管理"
|
||||
|
||||
#: templates/navbar.html:36
|
||||
#: templates/navbar.html:39
|
||||
msgid "VM report (.xlsx)"
|
||||
msgstr "虚拟机报告 (.xlsx)"
|
||||
|
||||
#: templates/navbar.html:54
|
||||
#: templates/navbar.html:57
|
||||
msgid "Log Out"
|
||||
msgstr "退出登录"
|
||||
|
||||
|
|
@ -9143,6 +9150,110 @@ msgid ""
|
|||
"encrypted anew."
|
||||
msgstr "新值会立即替换旧值;之前用口令加密的内容不会重新加密。"
|
||||
|
||||
#: vmbackups/forms.py:12
|
||||
msgid "Compute"
|
||||
msgstr "计算节点"
|
||||
|
||||
#: vmbackups/forms.py:28
|
||||
msgid "A backup target with this name exists"
|
||||
msgstr "已存在同名的备份目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
#: vmbackups/templates/vmbackups/targets.html:8
|
||||
msgid "Backup targets"
|
||||
msgstr "备份目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
msgid_plural "%(counter)s backups."
|
||||
msgstr[0] "%(counter)s 个备份。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
msgid ""
|
||||
"Remove this storage pool from the target? The pool and its files stay on the "
|
||||
"host."
|
||||
msgstr "要从目标中移除此存储池吗?存储池及其文件仍保留在主机上。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The target is inside storage pool %(pool)s: its backups are lost with that "
|
||||
"storage."
|
||||
msgstr "目标位于存储池 %(pool)s 内:该存储丢失时其备份也会丢失。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
msgid "Add a compute's storage pool"
|
||||
msgstr "添加计算节点的存储池"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:45
|
||||
msgid ""
|
||||
"The pool must be the same directory as the target's other pools, as an NFS "
|
||||
"share mounted on each host."
|
||||
msgstr "该存储池必须与目标的其他存储池是同一目录,例如挂载在每台主机上的 NFS 共享。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
msgid "Delete this backup target? Its storage pools stay on the hosts."
|
||||
msgstr "要删除此备份目标吗?其存储池仍保留在主机上。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
msgid "Delete target"
|
||||
msgstr "删除目标"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:11
|
||||
msgid ""
|
||||
"A backup target is a directory or NFS storage pool made on the hosts. Use "
|
||||
"storage apart from the VMs' disks: a target on the same storage is lost with "
|
||||
"it."
|
||||
msgstr "备份目标是在主机上创建的目录或 NFS 存储池。请使用与虚拟机磁盘分开的存储:位于同一存储上的目标会随之一起丢失。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:17
|
||||
msgid "Storage pools"
|
||||
msgstr "存储池"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:31
|
||||
msgid "No backup target yet."
|
||||
msgstr "还没有备份目标。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/targets.html:35
|
||||
msgid "Add a backup target"
|
||||
msgstr "添加备份目标"
|
||||
|
||||
#: vmbackups/utils.py:25
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the "
|
||||
"Backups page"
|
||||
msgstr "卷 %(volume)s 属于 %(vm)s 的备份;请在备份页面删除该备份"
|
||||
|
||||
#: vmbackups/utils.py:35
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is backup target %(target)s; remove it from the target "
|
||||
"first"
|
||||
msgstr "存储池 %(pool)s 是备份目标 %(target)s;请先将其从目标中移除"
|
||||
|
||||
#: vmbackups/views.py:61 vmbackups/views.py:69
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has backups; delete them first"
|
||||
msgstr "备份目标 %(target)s 中有备份;请先删除它们"
|
||||
|
||||
#: vmbackups/views.py:86
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s of %(compute)s is not the same directory as storage "
|
||||
"pool %(other)s of %(other_compute)s"
|
||||
msgstr "%(compute)s 的存储池 %(pool)s 与 %(other_compute)s 的存储池 %(other)s 不是同一目录"
|
||||
|
||||
#: vrtManager/backup.py:30
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is not an active directory or NFS pool of this host, or"
|
||||
" not the one the backup target registered"
|
||||
msgstr "存储池 %(pool)s 不是此主机上活动的目录或 NFS 存储池,或不是备份目标登记的那个存储池"
|
||||
|
||||
#: vrtManager/connection.py:45
|
||||
msgid "Connection closed (error)"
|
||||
msgstr "连接已关闭(错误)"
|
||||
|
|
@ -10286,10 +10397,10 @@ msgstr "存储池 %(names)s"
|
|||
msgid "Secret %(uuid)s is used by %(named)s; remove it from them first"
|
||||
msgstr "机密 %(uuid)s 正被 %(named)s 使用;请先从中移除它"
|
||||
|
||||
#: webvirtcloud/settings.py:319
|
||||
#: webvirtcloud/settings.py:320
|
||||
msgid "Localhost"
|
||||
msgstr "本机"
|
||||
|
||||
#: webvirtcloud/settings.py:320
|
||||
#: webvirtcloud/settings.py:321
|
||||
msgid "All interfaces"
|
||||
msgstr "所有接口"
|
||||
|
|
|
|||
4
static/icon_cache/archive_None_None_None.svg
Normal file
4
static/icon_cache/archive_None_None_None.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-archive" viewBox="0 0 16 16">
|
||||
<path d="M0 2a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1v7.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V5a1 1 0 0 1-1-1zm2 3v7.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V5zm13-3H1v2h14zM5 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 417 B |
|
|
@ -13,6 +13,7 @@ from logs.audit import audit, failed
|
|||
from rest_framework import serializers, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from vmbackups.utils import refuse_backup_volume
|
||||
from vrtManager.storage import wvmStorage, wvmStorages
|
||||
from webvirtcloud.serializers import ErrorSerializer, StatusSerializer
|
||||
|
||||
|
|
@ -208,6 +209,7 @@ class VolumeViewSet(viewsets.ViewSet):
|
|||
subject, action = f"Storage pool {storage_pk}", f"delete volume {pk}"
|
||||
if conn.is_active():
|
||||
with audit(request, compute, subject, action):
|
||||
refuse_backup_volume(compute, storage_pk, pk)
|
||||
conn.check_unused_elsewhere(pk, lambda paths: paths_used_on_other_computes(compute, paths))
|
||||
# no VM operation attaches it between the check and the delete
|
||||
with libvirt_compute_lock(compute):
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from vrtManager.storage import wvmStorage, wvmStorages
|
|||
from storages.forms import AddStgPool, CloneImage, CreateVolumeForm
|
||||
from storages.jobs import is_iso
|
||||
from storages.upload import write_chunk
|
||||
from vmbackups.utils import refuse_backup_volume, refuse_target_pool
|
||||
from webvirtcloud.gunicorn_worker import request_progressed
|
||||
|
||||
|
||||
|
|
@ -154,6 +155,7 @@ def storage(request, compute_id, pool):
|
|||
if "delete" in request.POST:
|
||||
try:
|
||||
with audit(request, compute, subject, "delete"):
|
||||
refuse_target_pool(compute, pool)
|
||||
conn.delete()
|
||||
except OperationError as err: # a VM names it for a disk
|
||||
messages.error(request, str(err))
|
||||
|
|
@ -171,6 +173,7 @@ def storage(request, compute_id, pool):
|
|||
volname = request.POST.get("volname", "")
|
||||
try:
|
||||
with audit(request, compute, subject, f"delete volume {volname}"):
|
||||
refuse_backup_volume(compute, pool, volname)
|
||||
conn.check_unused_elsewhere(volname, lambda paths: paths_used_on_other_computes(compute, paths))
|
||||
# no VM operation attaches it between the check and the delete
|
||||
with libvirt_compute_lock(compute):
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
<li class="nav-item {% class_active request '^/computes' %}">
|
||||
<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>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<ul class="navbar-nav ms-auto">
|
||||
|
|
|
|||
29
vmbackups/forms.py
Normal file
29
vmbackups/forms.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from computes.models import Compute
|
||||
|
||||
from .models import BackupTarget
|
||||
|
||||
|
||||
class TargetPoolForm(forms.Form):
|
||||
"""A compute's storage pool for a target; computes that have one already are not offered."""
|
||||
|
||||
compute = forms.ModelChoiceField(Compute.objects.all(), label=_("Compute"))
|
||||
pool = forms.CharField(label=_("Storage pool"), max_length=128)
|
||||
|
||||
def __init__(self, *args, target=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if target is not None:
|
||||
self.fields["compute"].queryset = Compute.objects.exclude(backuptargetpool__target=target)
|
||||
|
||||
|
||||
class TargetForm(TargetPoolForm):
|
||||
name = forms.CharField(label=_("Name"), max_length=64)
|
||||
field_order = ["name", "compute", "pool"]
|
||||
|
||||
def clean_name(self):
|
||||
name = self.cleaned_data["name"]
|
||||
if BackupTarget.objects.filter(name=name).exists():
|
||||
raise forms.ValidationError(_("A backup target with this name exists"))
|
||||
return name
|
||||
61
vmbackups/templates/vmbackups/target.html
Normal file
61
vmbackups/templates/vmbackups/target.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load django_bootstrap5 %}
|
||||
|
||||
{% block title %}{{ target.name }} - {% trans "Backup targets" %}{% endblock %}
|
||||
|
||||
{% block page_heading %}<a href="{% url 'vmbackups:targets' %}">{% trans "Backup targets" %}</a> / {{ target.name }}{% endblock page_heading %}
|
||||
|
||||
{% block content %}
|
||||
<p class="text-body-secondary">{% blocktrans count counter=backup_count %}{{ counter }} backup.{% plural %}{{ counter }} backups.{% endblocktrans %}</p>
|
||||
|
||||
<div class="row row-cols-1 row-cols-md-2 g-3 mb-4">
|
||||
{% for item in pools %}
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex flex-wrap align-items-center gap-2">
|
||||
<span class="fw-semibold me-auto text-break">{{ item.row.compute.name }}: {{ item.row.pool }}</span>
|
||||
{% if not backup_count %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="remove_pool" value="{{ item.row.id }}" class="btn btn-sm btn-outline-danger"
|
||||
data-confirm="{% trans "Remove this storage pool from the target? The pool and its files stay on the host." %}">{% trans "Remove" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if item.error %}
|
||||
<div class="text-danger small">{% bs_icon 'exclamation-triangle' %} {{ item.error }}</div>
|
||||
{% else %}
|
||||
{% include "computes/pool_bar.html" with pool=item.space hide_name=True %}
|
||||
{% if item.inside %}
|
||||
<div class="alert alert-warning small mt-2 mb-0">{% blocktrans with pool=item.inside %}The target is inside storage pool {{ pool }}: its backups are lost with that storage.{% endblocktrans %}</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="card mb-4" style="max-width: 40rem;">
|
||||
<div class="card-header fw-semibold">{% trans "Add a compute's storage pool" %}</div>
|
||||
<div class="card-body">
|
||||
<p class="small text-body-secondary">{% trans "The pool must be the same directory as the target's other pools, as an NFS share mounted on each host." %}</p>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
<button type="submit" name="add_pool" value="1" class="btn btn-primary">{% bs_icon 'plus' %} {% trans "Add" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not backup_count %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="delete" value="1" class="btn btn-outline-danger"
|
||||
data-confirm="{% trans "Delete this backup target? Its storage pools stay on the hosts." %}">{% bs_icon 'trash' %} {% trans "Delete target" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
44
vmbackups/templates/vmbackups/targets.html
Normal file
44
vmbackups/templates/vmbackups/targets.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load django_bootstrap5 %}
|
||||
|
||||
{% block title %}{% trans "Backup targets" %}{% endblock %}
|
||||
|
||||
{% block page_heading %}{% trans "Backup targets" %}{% endblock page_heading %}
|
||||
|
||||
{% block content %}
|
||||
<p class="text-body-secondary">{% blocktrans %}A backup target is a directory or NFS storage pool made on the hosts. Use storage apart from the VMs' disks: a target on the same storage is lost with it.{% endblocktrans %}</p>
|
||||
|
||||
{% if targets %}
|
||||
<div class="table-responsive mb-4">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead>
|
||||
<tr><th>{% trans "Name" %}</th><th>{% trans "Storage pools" %}</th><th class="text-end">{% trans "Backups" %}</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for target in targets %}
|
||||
<tr>
|
||||
<td><a href="{% url 'vmbackups:target' target.id %}">{{ target.name }}</a></td>
|
||||
<td>{% for row in target.pools.all %}<span class="badge text-bg-light border me-1">{{ row.compute.name }}: {{ row.pool }}</span>{% empty %}–{% endfor %}</td>
|
||||
<td class="text-end">{{ target.backup_count }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info">{% trans "No backup target yet." %}</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card" style="max-width: 40rem;">
|
||||
<div class="card-header fw-semibold">{% trans "Add a backup target" %}</div>
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
<button type="submit" class="btn btn-primary">{% bs_icon 'plus' %} {% trans "Add" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
191
vmbackups/tests/test_targets.py
Normal file
191
vmbackups/tests/test_targets.py
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.messages import get_messages
|
||||
from django.test import RequestFactory, TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from computes.models import Compute
|
||||
from vmbackups.models import Backup, BackupTarget, BackupTargetPool
|
||||
from vmbackups.utils import inside_vm_pool
|
||||
from vrtManager.backup import pool_space, target_pool
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def pool_mock(name="b1", uuid="aaaaaaaa-0000-4000-8000-000000000001", kind="dir", active=True, path="/srv/b1"):
|
||||
pool = MagicMock()
|
||||
pool.name.return_value = name
|
||||
pool.UUIDString.return_value = uuid
|
||||
pool.isActive.return_value = active
|
||||
pool.XMLDesc.return_value = f"<pool type='{kind}'><name>{name}</name><target><path>{path}</path></target></pool>"
|
||||
pool.info.return_value = [2, 100, 40, 60]
|
||||
return pool
|
||||
|
||||
|
||||
class TargetPoolTests(TestCase):
|
||||
"""vrtManager: which pool a target may use."""
|
||||
|
||||
def conn(self, pool):
|
||||
conn = MagicMock()
|
||||
conn.get_storage.return_value = pool
|
||||
return conn
|
||||
|
||||
def test_an_active_directory_pool_is_taken(self):
|
||||
pool = pool_mock()
|
||||
self.assertIs(target_pool(self.conn(pool), "b1"), pool)
|
||||
|
||||
def test_a_pool_of_another_type_is_refused(self):
|
||||
with self.assertRaisesMessage(OperationError, "b1"):
|
||||
target_pool(self.conn(pool_mock(kind="logical")), "b1")
|
||||
|
||||
def test_a_stopped_pool_is_refused(self):
|
||||
with self.assertRaises(OperationError):
|
||||
target_pool(self.conn(pool_mock(active=False)), "b1")
|
||||
|
||||
def test_a_replaced_pool_is_refused(self):
|
||||
with self.assertRaises(OperationError):
|
||||
target_pool(self.conn(pool_mock(uuid="bbbbbbbb-0000-4000-8000-000000000002")), "b1", "aaaaaaaa-0000-4000-8000-000000000001")
|
||||
|
||||
def test_a_missing_pool_is_refused(self):
|
||||
from libvirt import VIR_ERR_NO_STORAGE_POOL, libvirtError
|
||||
|
||||
error = libvirtError("no pool")
|
||||
error.get_error_code = lambda: VIR_ERR_NO_STORAGE_POOL
|
||||
conn = MagicMock()
|
||||
conn.get_storage.side_effect = error
|
||||
with self.assertRaisesMessage(OperationError, "b1"):
|
||||
target_pool(conn, "b1")
|
||||
|
||||
def test_pool_space_is_read_after_a_refresh(self):
|
||||
pool = pool_mock()
|
||||
self.assertEqual(pool_space(pool), {"name": "b1", "size": 100, "free": 60, "used_percent": 40})
|
||||
self.assertEqual([call[0] for call in pool.method_calls][:2], ["refresh", "info"])
|
||||
|
||||
def test_inside_a_vm_pool(self):
|
||||
conn = MagicMock()
|
||||
conn.file_pools.return_value = {"default": (None, "/var/lib/libvirt/images"), "b1": (None, "/var/lib/libvirt/images/b1")}
|
||||
self.assertEqual(inside_vm_pool(conn, pool_mock(path="/var/lib/libvirt/images/b1")), "default")
|
||||
conn.file_pools.return_value = {"default": (None, "/var/lib/libvirt/images"), "b1": (None, "/srv/b1")}
|
||||
self.assertIsNone(inside_vm_pool(conn, pool_mock(path="/srv/b1")))
|
||||
|
||||
|
||||
@patch("vmbackups.views.wvmConnect")
|
||||
@patch("vmbackups.views.target_pool")
|
||||
class TargetPageTests(TestCase):
|
||||
def setUp(self):
|
||||
User.objects.create_superuser(username="bk_admin", password="password", email="bk_admin@example.com")
|
||||
self.client.login(request=RequestFactory().get("/"), username="bk_admin", password="password")
|
||||
self.c1 = Compute.objects.create(name="h1", hostname="192.0.2.11", login="u", password="p", type=1)
|
||||
self.c2 = Compute.objects.create(name="h2", hostname="192.0.2.12", login="u", password="p", type=1)
|
||||
|
||||
def add_target(self):
|
||||
target = BackupTarget.objects.create(name="nfs1")
|
||||
BackupTargetPool.objects.create(target=target, compute=self.c1, pool="b1", pool_uuid="aaaaaaaa-0000-4000-8000-000000000001")
|
||||
return target
|
||||
|
||||
def test_a_target_is_added_with_its_pool_uuid(self, mock_pool, mock_conn):
|
||||
mock_pool.return_value = pool_mock()
|
||||
response = self.client.post(reverse("vmbackups:targets"), {"name": "nfs1", "compute": self.c1.id, "pool": "b1"})
|
||||
target = BackupTarget.objects.get(name="nfs1")
|
||||
self.assertRedirects(response, reverse("vmbackups:target", args=[target.id]), fetch_redirect_response=False)
|
||||
row = target.pools.get()
|
||||
self.assertEqual((row.compute, row.pool, row.pool_uuid), (self.c1, "b1", "aaaaaaaa-0000-4000-8000-000000000001"))
|
||||
|
||||
def test_a_refused_pool_adds_no_target(self, mock_pool, mock_conn):
|
||||
mock_pool.side_effect = OperationError("Storage pool %(pool)s is not usable", pool="b1")
|
||||
response = self.client.post(reverse("vmbackups:targets"), {"name": "nfs1", "compute": self.c1.id, "pool": "b1"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "Storage pool b1 is not usable")
|
||||
self.assertFalse(BackupTarget.objects.exists())
|
||||
|
||||
def test_a_second_compute_pool_must_be_the_same_directory(self, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
mock_pool.return_value = pool_mock()
|
||||
mock_conn.same_directory.return_value = False
|
||||
response = self.client.post(reverse("vmbackups:target", args=[target.id]), {"add_pool": "1", "compute": self.c2.id, "pool": "b1"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "not the same directory")
|
||||
self.assertEqual(target.pools.count(), 1)
|
||||
|
||||
def test_a_second_compute_pool_of_the_same_directory_is_added(self, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
mock_pool.return_value = pool_mock()
|
||||
mock_conn.same_directory.return_value = True
|
||||
self.client.post(reverse("vmbackups:target", args=[target.id]), {"add_pool": "1", "compute": self.c2.id, "pool": "b1"})
|
||||
self.assertEqual(target.pools.count(), 2)
|
||||
|
||||
@patch("vmbackups.views.inside_vm_pool", return_value="default")
|
||||
def test_the_page_warns_when_the_target_is_inside_a_vm_pool(self, mock_inside, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
mock_pool.return_value = pool_mock()
|
||||
response = self.client.get(reverse("vmbackups:target", args=[target.id]))
|
||||
self.assertContains(response, "inside storage pool default")
|
||||
|
||||
def test_a_pool_with_backups_cannot_be_removed(self, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
Backup.objects.create(target=target, vm_uuid="u", vm_name="vm1", compute_name="h1")
|
||||
url = reverse("vmbackups:target", args=[target.id])
|
||||
response = self.client.post(url, {"remove_pool": target.pools.get().id})
|
||||
self.assertRedirects(response, url, fetch_redirect_response=False)
|
||||
self.assertEqual(target.pools.count(), 1)
|
||||
response = self.client.post(url, {"delete": "1"})
|
||||
self.assertTrue(BackupTarget.objects.filter(pk=target.pk).exists())
|
||||
|
||||
def test_an_empty_target_is_deleted(self, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
response = self.client.post(reverse("vmbackups:target", args=[target.id]), {"delete": "1"})
|
||||
self.assertRedirects(response, reverse("vmbackups:targets"), fetch_redirect_response=False)
|
||||
self.assertFalse(BackupTarget.objects.exists())
|
||||
|
||||
def test_only_superusers(self, mock_pool, mock_conn):
|
||||
target = self.add_target()
|
||||
User.objects.create_user(username="owner", password="password")
|
||||
self.client.logout()
|
||||
self.client.login(request=RequestFactory().get("/"), username="owner", password="password")
|
||||
self.assertEqual(self.client.get(reverse("vmbackups:targets")).status_code, 403)
|
||||
self.assertEqual(self.client.get(reverse("vmbackups:target", args=[target.id])).status_code, 403)
|
||||
|
||||
|
||||
class StorageRefusalTests(TestCase):
|
||||
def setUp(self):
|
||||
User.objects.create_superuser(username="st_admin", password="password", email="st_admin@example.com")
|
||||
self.client.login(request=RequestFactory().get("/"), username="st_admin", password="password")
|
||||
self.compute = Compute.objects.create(name="h1", hostname="192.0.2.11", login="u", password="p", type=1)
|
||||
self.target = BackupTarget.objects.create(name="nfs1")
|
||||
BackupTargetPool.objects.create(target=self.target, compute=self.compute, pool="b1", pool_uuid="u1")
|
||||
self.backup = Backup.objects.create(target=self.target, vm_uuid="u", vm_name="vm1", compute_name="h1")
|
||||
self.url = reverse("storage", args=[self.compute.id, "b1"])
|
||||
|
||||
@patch("storages.views.wvmStorage")
|
||||
def test_a_backup_volume_is_not_deleted_from_the_storage_page(self, mock_wvm):
|
||||
conn = mock_wvm.return_value
|
||||
response = self.client.post(self.url, {"del_volume": "1", "volname": f"{self.backup.prefix}-vda.qcow2"})
|
||||
self.assertRedirects(response, self.url, fetch_redirect_response=False)
|
||||
conn.del_volume.assert_not_called()
|
||||
messages = [str(m) for m in get_messages(response.wsgi_request)]
|
||||
self.assertTrue(any("belongs to a backup of vm1" in m for m in messages), messages)
|
||||
|
||||
@patch("storages.views.wvmStorage")
|
||||
def test_another_volume_of_the_target_pool_is_deleted(self, mock_wvm):
|
||||
conn = mock_wvm.return_value
|
||||
conn.check_unused_elsewhere.return_value = None
|
||||
self.client.post(self.url, {"del_volume": "1", "volname": "wvc-00000000-0000-4000-8000-000000000009-vda.qcow2"})
|
||||
conn.del_volume.assert_called_once()
|
||||
|
||||
@patch("storages.views.wvmStorage")
|
||||
def test_a_target_pool_is_not_deleted_from_the_storage_page(self, mock_wvm):
|
||||
conn = mock_wvm.return_value
|
||||
response = self.client.post(self.url, {"delete": "1"})
|
||||
self.assertRedirects(response, self.url, fetch_redirect_response=False)
|
||||
conn.delete.assert_not_called()
|
||||
messages = [str(m) for m in get_messages(response.wsgi_request)]
|
||||
self.assertTrue(any("is backup target nfs1" in m for m in messages), messages)
|
||||
|
||||
@patch("storages.api.viewsets.wvmStorage")
|
||||
def test_the_api_does_not_delete_a_backup_volume(self, mock_wvm):
|
||||
mock_wvm.return_value.is_active.return_value = True
|
||||
response = self.client.delete(f"/api/v1/computes/{self.compute.id}/storages/b1/volumes/{self.backup.prefix}-vda.qcow2/")
|
||||
self.assertEqual(response.status_code, 409)
|
||||
mock_wvm.return_value.del_volume.assert_not_called()
|
||||
10
vmbackups/urls.py
Normal file
10
vmbackups/urls.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = "vmbackups"
|
||||
|
||||
urlpatterns = [
|
||||
path("targets/", views.targets, name="targets"),
|
||||
path("targets/<int:target_id>/", views.target, name="target"),
|
||||
]
|
||||
38
vmbackups/utils.py
Normal file
38
vmbackups/utils.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from django.utils.translation import gettext_noop
|
||||
from lxml import etree
|
||||
|
||||
from storages.forms import inside
|
||||
from vrtManager.util import InUse
|
||||
|
||||
from .models import Backup, BackupTargetPool
|
||||
|
||||
|
||||
def inside_vm_pool(conn, pool):
|
||||
"""The name of another pool of the host whose directory holds the target
|
||||
pool's: its backups would share that storage's failures."""
|
||||
path = etree.fromstring(pool.XMLDesc(0)).findtext("target/path").rstrip("/")
|
||||
for name, (_pool, directory) in conn.file_pools().items():
|
||||
if name != pool.name() and inside(path, directory):
|
||||
return name
|
||||
return None
|
||||
|
||||
|
||||
def refuse_backup_volume(compute, pool, volume):
|
||||
"""A volume of a backup is deleted with its backup, on the Backups pages."""
|
||||
for backup in Backup.objects.filter(target__pools__compute=compute, target__pools__pool=pool):
|
||||
if volume.startswith(backup.prefix + "-"):
|
||||
raise InUse(
|
||||
gettext_noop("Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the Backups page"),
|
||||
volume=volume,
|
||||
vm=backup.vm_name,
|
||||
)
|
||||
|
||||
|
||||
def refuse_target_pool(compute, pool):
|
||||
row = BackupTargetPool.objects.filter(compute=compute, pool=pool).select_related("target").first()
|
||||
if row:
|
||||
raise InUse(
|
||||
gettext_noop("Storage pool %(pool)s is backup target %(target)s; remove it from the target first"),
|
||||
pool=pool,
|
||||
target=row.target.name,
|
||||
)
|
||||
101
vmbackups/views.py
Normal file
101
vmbackups/views.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
from django.contrib import messages
|
||||
from django.db import transaction
|
||||
from django.db.models import Count
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext_noop
|
||||
from libvirt import libvirtError
|
||||
|
||||
from admin.decorators import superuser_only
|
||||
from logs.audit import audit
|
||||
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 .utils import inside_vm_pool
|
||||
|
||||
|
||||
def connect(compute):
|
||||
return wvmConnect(compute.hostname, compute.login, compute.password, compute.type)
|
||||
|
||||
|
||||
@superuser_only
|
||||
def targets(request):
|
||||
form = TargetForm(request.POST or None)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
try:
|
||||
with audit(request, data["compute"], f"Backup target {data['name']}", f"add with storage pool {data['pool']}"):
|
||||
pool = target_pool(connect(data["compute"]), data["pool"])
|
||||
with transaction.atomic():
|
||||
target = BackupTarget.objects.create(name=data["name"])
|
||||
target.pools.create(compute=data["compute"], pool=data["pool"], pool_uuid=pool.UUIDString())
|
||||
except libvirtError as err:
|
||||
form.add_error("pool", str(err))
|
||||
else:
|
||||
return redirect("vmbackups:target", target.id)
|
||||
rows = BackupTarget.objects.annotate(backup_count=Count("backups")).prefetch_related("pools__compute").order_by("name")
|
||||
return render(request, "vmbackups/targets.html", {"targets": rows, "form": form})
|
||||
|
||||
|
||||
def pool_state(row):
|
||||
"""A target's pool on its compute as the page shows it: its space and
|
||||
whether another pool holds it, or why it cannot be read."""
|
||||
try:
|
||||
conn = connect(row.compute)
|
||||
pool = target_pool(conn, row.pool, row.pool_uuid)
|
||||
return {"row": row, "space": pool_space(pool), "inside": inside_vm_pool(conn, pool)}
|
||||
except libvirtError as err:
|
||||
return {"row": row, "error": str(err)}
|
||||
|
||||
|
||||
@superuser_only
|
||||
def target(request, target_id):
|
||||
target = get_object_or_404(BackupTarget, pk=target_id)
|
||||
subject = f"Backup target {target.name}"
|
||||
form = TargetPoolForm(request.POST if "add_pool" in request.POST else None, target=target)
|
||||
if request.method == "POST" and "delete" in request.POST:
|
||||
if target.backups.exists():
|
||||
messages.error(request, _("Backup target %(target)s has backups; delete them first") % {"target": target.name})
|
||||
return redirect("vmbackups:target", target.id)
|
||||
with audit(request, None, subject, "delete"):
|
||||
target.delete()
|
||||
return redirect("vmbackups:targets")
|
||||
if request.method == "POST" and "remove_pool" in request.POST:
|
||||
row = get_object_or_404(target.pools.select_related("compute"), pk=request.POST["remove_pool"])
|
||||
if target.backups.exists():
|
||||
messages.error(request, _("Backup target %(target)s has backups; delete them first") % {"target": target.name})
|
||||
else:
|
||||
with audit(request, row.compute, subject, f"remove storage pool {row.pool}"):
|
||||
row.delete()
|
||||
return redirect("vmbackups:target", target.id)
|
||||
if form.is_valid():
|
||||
compute, name = form.cleaned_data["compute"], form.cleaned_data["pool"]
|
||||
try:
|
||||
with audit(request, compute, subject, f"add storage pool {name}"):
|
||||
pool = target_pool(connect(compute), name)
|
||||
# a target is one directory: the new pool must be the one the others are
|
||||
other = target.pools.select_related("compute").first()
|
||||
if other and not wvmConnect.same_directory(
|
||||
target_pool(connect(other.compute), other.pool, other.pool_uuid), pool
|
||||
):
|
||||
raise OperationError(
|
||||
gettext_noop(
|
||||
"Storage pool %(pool)s of %(compute)s is not the same directory as "
|
||||
"storage pool %(other)s of %(other_compute)s"
|
||||
),
|
||||
pool=name,
|
||||
compute=compute.name,
|
||||
other=other.pool,
|
||||
other_compute=other.compute.name,
|
||||
)
|
||||
target.pools.create(compute=compute, pool=name, pool_uuid=pool.UUIDString())
|
||||
except libvirtError as err:
|
||||
form.add_error("pool", str(err))
|
||||
else:
|
||||
return redirect("vmbackups:target", target.id)
|
||||
pools = [pool_state(row) for row in target.pools.select_related("compute").order_by("compute__name")]
|
||||
return render(request, "vmbackups/target.html", {"target": target, "pools": pools, "form": form,
|
||||
"backup_count": target.backups.count()})
|
||||
43
vrtManager/backup.py
Normal file
43
vrtManager/backup.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""VM backups: the target pools and what a VM's backup holds (app vmbackups)."""
|
||||
|
||||
import libvirt
|
||||
from django.utils.translation import gettext_noop
|
||||
from lxml import etree
|
||||
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
# pools that keep their volumes as files in one directory
|
||||
TARGET_TYPES = ("dir", "netfs")
|
||||
|
||||
|
||||
def target_pool(conn, name, uuid=None):
|
||||
"""The active dir or netfs pool name of conn's host; with uuid, only the
|
||||
pool a target registered, not another made since under its name."""
|
||||
try:
|
||||
pool = conn.get_storage(name)
|
||||
usable = (
|
||||
pool.isActive()
|
||||
and etree.fromstring(pool.XMLDesc(0)).get("type") in TARGET_TYPES
|
||||
and uuid in (None, pool.UUIDString())
|
||||
)
|
||||
except libvirt.libvirtError as err:
|
||||
if err.get_error_code() != libvirt.VIR_ERR_NO_STORAGE_POOL:
|
||||
raise
|
||||
usable = False
|
||||
if not usable:
|
||||
raise OperationError(
|
||||
gettext_noop(
|
||||
"Storage pool %(pool)s is not an active directory or NFS pool of this host, "
|
||||
"or not the one the backup target registered"
|
||||
),
|
||||
pool=name,
|
||||
)
|
||||
return pool
|
||||
|
||||
|
||||
def pool_space(pool):
|
||||
"""{name, size, free, used_percent} of a pool, as the storage pages show
|
||||
it; refreshed first, as files may have changed outside libvirt."""
|
||||
pool.refresh(0)
|
||||
_state, size, used, free = pool.info()
|
||||
return {"name": pool.name(), "size": size, "free": free, "used_percent": used * 100 / size if size else 0}
|
||||
|
|
@ -35,6 +35,7 @@ urlpatterns = [
|
|||
path("i18n/", include("django.conf.urls.i18n")),
|
||||
path("logs/", include("logs.urls")),
|
||||
path("jobs/", include("operations.urls")),
|
||||
path("backups/", include("vmbackups.urls")),
|
||||
path('api/v1/', include("webvirtcloud.urls-api")),
|
||||
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
|
||||
re_path(r"^swagger\.(?P<format>json|yaml)$", SpectacularAPIView.as_view(), name="schema-json"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue