mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix: a test alert button; damage shown and warned of on restore
Audit of the alerts and backup verification: an operator could learn that the alert mail or webhook works only from a real failure. Settings > Alerts gets "Send a test alert", sent at once to the channels saved, each channel's result shown. A damaged backup's reasons were only in a tooltip, so not on a touch screen: they show under the badge. A restore of a backup that a verification found damaged, or of an incremental on a damaged base (shown as Ready), said nothing: the restore pages warn.
This commit is contained in:
parent
dcd7e32df7
commit
2c8493ba8c
15 changed files with 254 additions and 70 deletions
|
|
@ -94,8 +94,12 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="border-top mt-3 pt-3 text-end">
|
||||
<div class="border-top mt-3 pt-3 d-flex flex-wrap justify-content-end gap-2">
|
||||
{# Save first: Enter in a field saves #}
|
||||
<button type="submit" class="btn btn-primary">{% blocktrans %}Save {{ group_title }}{% endblocktrans %}</button>
|
||||
{% if title == "Alerts" %}{# to the addresses and webhook saved #}
|
||||
<button type="submit" name="test_alert" value="1" class="btn btn-outline-secondary order-first" formnovalidate>{% trans "Send a test alert" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from django.shortcuts import render
|
|||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_noop
|
||||
from logs.audit import audit
|
||||
from operations import alerts
|
||||
from operations.utils import BOUNDS
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
|
|
@ -110,6 +111,17 @@ def appsettings(request):
|
|||
settings_by_key = {s.key: s for s in AppSettings.objects.exclude(key="BOOTSTRAP_THEME")}
|
||||
|
||||
if request.method == "POST":
|
||||
if "test_alert" in request.POST: # with the settings saved
|
||||
results = alerts.test()
|
||||
if not results:
|
||||
messages.error(request, _("Set an alert e-mail address or webhook and save it first"))
|
||||
for channel, error in results.items():
|
||||
name = _("E-mail") if channel == "mail" else _("Webhook")
|
||||
if error is None:
|
||||
messages.success(request, _("%(channel)s: the test alert was sent") % {"channel": name})
|
||||
else:
|
||||
messages.error(request, _("%(channel)s: the test alert failed: %(error)s") % {"channel": name, "error": error})
|
||||
return HttpResponseRedirect(request.get_full_path()) # the results are at the top
|
||||
if "BOOTSTRAP_THEME" in request.POST:
|
||||
theme = request.POST.get("BOOTSTRAP_THEME", "")
|
||||
if theme not in themes_list:
|
||||
|
|
|
|||
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-19 13:10+0000\n"
|
||||
"POT-Creation-Date: 2026-11-19 14:12+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"
|
||||
|
|
@ -819,7 +819,7 @@ msgstr "Bellek"
|
|||
#: instances/templates/create_instance_w2.html:118
|
||||
#: instances/templates/instances/settings_tab.html:25
|
||||
#: instances/templates/instances/stats_tab.html:53 vmbackups/forms.py:57
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "Disk"
|
||||
msgstr "Disk"
|
||||
|
||||
|
|
@ -1961,103 +1961,129 @@ msgstr "Tüm kullanıcılar için"
|
|||
msgid "Change theme"
|
||||
msgstr "Temayı değiştir"
|
||||
|
||||
#: appsettings/templates/appsettings.html:98
|
||||
#: appsettings/templates/appsettings.html:99
|
||||
msgid "Send a test alert"
|
||||
msgstr "Deneme uyarısı gönder"
|
||||
|
||||
#: appsettings/templates/appsettings.html:101
|
||||
#, python-format
|
||||
msgid "Save %(group_title)s"
|
||||
msgstr "%(group_title)s kaydet"
|
||||
|
||||
#: appsettings/views.py:45
|
||||
#: appsettings/views.py:46
|
||||
msgid "New VM defaults"
|
||||
msgstr "Yeni sanal makine varsayılanları"
|
||||
|
||||
#: appsettings/views.py:48 instances/templates/instance.html:71
|
||||
#: appsettings/views.py:49 instances/templates/instance.html:71
|
||||
#: instances/templates/instances/destroy_instance_form.html:33
|
||||
#: instances/templates/instances/resize_tab.html:21
|
||||
#: instances/templates/instances/settings_tab.html:197
|
||||
msgid "Disks"
|
||||
msgstr "Diskler"
|
||||
|
||||
#: appsettings/views.py:52
|
||||
#: appsettings/views.py:53
|
||||
msgid "Clones"
|
||||
msgstr "Klonlar"
|
||||
|
||||
#: appsettings/views.py:53 console/templates/console-base.html:10
|
||||
#: appsettings/views.py:54 console/templates/console-base.html:10
|
||||
#: console/templates/console-base.html:23
|
||||
#: instances/templates/instance_actions.html:11
|
||||
#: instances/templates/instances/settings_tab.html:32
|
||||
msgid "Console"
|
||||
msgstr "Konsol"
|
||||
|
||||
#: appsettings/views.py:54
|
||||
#: appsettings/views.py:55
|
||||
msgid "VM access and owners"
|
||||
msgstr "Sanal makine erişimi ve sahipleri"
|
||||
|
||||
#: appsettings/views.py:56
|
||||
#: appsettings/views.py:57
|
||||
msgid "Snapshots and jobs"
|
||||
msgstr "Anlık görüntüler ve işler"
|
||||
|
||||
#: appsettings/views.py:58
|
||||
#: appsettings/views.py:59
|
||||
msgid "Login"
|
||||
msgstr "Oturum açma"
|
||||
|
||||
#: appsettings/views.py:59
|
||||
#: appsettings/views.py:60
|
||||
msgid "Alerts"
|
||||
msgstr "Uyarılar"
|
||||
|
||||
#: appsettings/views.py:60
|
||||
#: appsettings/views.py:61
|
||||
msgid "Lists and pages"
|
||||
msgstr "Listeler ve sayfalar"
|
||||
|
||||
#: appsettings/views.py:68
|
||||
#: appsettings/views.py:69
|
||||
#, python-format
|
||||
msgid "%(setting)s takes at most %(length)s characters"
|
||||
msgstr "%(setting)s en fazla %(length)s karakter alır"
|
||||
|
||||
#: appsettings/views.py:73
|
||||
#: appsettings/views.py:74
|
||||
#, python-format
|
||||
msgid "%(setting)s must be a whole number between %(low)s and %(high)s"
|
||||
msgstr "%(setting)s, %(low)s ile %(high)s arasında bir tam sayı olmalıdır"
|
||||
|
||||
#: appsettings/views.py:76
|
||||
#: appsettings/views.py:77
|
||||
#, python-format
|
||||
msgid "%(setting)s must be one of %(choices)s"
|
||||
msgstr "%(setting)s şunlardan biri olmalıdır: %(choices)s"
|
||||
|
||||
#: appsettings/views.py:80
|
||||
#: appsettings/views.py:81
|
||||
#, python-format
|
||||
msgid "%(setting)s takes letters, digits and '-' only"
|
||||
msgstr "%(setting)s yalnızca harf, rakam ve '-' alır"
|
||||
|
||||
#: appsettings/views.py:90
|
||||
#: appsettings/views.py:91
|
||||
#, python-format
|
||||
msgid "%(setting)s: %(value)s is not an e-mail address or an http(s) URL"
|
||||
msgstr "%(setting)s: %(value)s bir e-posta adresi ya da http(s) adresi değil"
|
||||
|
||||
#: appsettings/views.py:99
|
||||
#: appsettings/views.py:100
|
||||
msgid "Disk I/O native needs disk cache none or directsync"
|
||||
msgstr ""
|
||||
"Disk G/Ç native, disk önbelleği none veya directsync olmasını gerektirir"
|
||||
|
||||
#: appsettings/views.py:116
|
||||
#: appsettings/views.py:117
|
||||
msgid "Set an alert e-mail address or webhook and save it first"
|
||||
msgstr "Önce bir uyarı e-posta adresi ya da webhook girip kaydedin"
|
||||
|
||||
#: appsettings/views.py:119
|
||||
msgid "E-mail"
|
||||
msgstr "E-posta"
|
||||
|
||||
#: appsettings/views.py:119
|
||||
msgid "Webhook"
|
||||
msgstr "Webhook"
|
||||
|
||||
#: appsettings/views.py:121
|
||||
#, python-format
|
||||
msgid "%(channel)s: the test alert was sent"
|
||||
msgstr "%(channel)s: deneme uyarısı gönderildi"
|
||||
|
||||
#: appsettings/views.py:123
|
||||
#, python-format
|
||||
msgid "%(channel)s: the test alert failed: %(error)s"
|
||||
msgstr "%(channel)s: deneme uyarısı gönderilemedi: %(error)s"
|
||||
|
||||
#: appsettings/views.py:128
|
||||
#, python-format
|
||||
msgid "Unknown theme: %(theme)s"
|
||||
msgstr "Bilinmeyen tema: %(theme)s"
|
||||
|
||||
#: appsettings/views.py:122
|
||||
#: appsettings/views.py:134
|
||||
#, python-format
|
||||
msgid "Theme is changed. Now: %(theme)s"
|
||||
msgstr "Tema değiştirildi. Şimdi: %(theme)s"
|
||||
|
||||
#: appsettings/views.py:159
|
||||
#: appsettings/views.py:171
|
||||
#, python-format
|
||||
msgid "Saved: %(settings)s"
|
||||
msgstr "Kaydedildi: %(settings)s"
|
||||
|
||||
#: appsettings/views.py:161
|
||||
#: appsettings/views.py:173
|
||||
msgid "Nothing changed"
|
||||
msgstr "Hiçbir şey değişmedi"
|
||||
|
||||
#: appsettings/views.py:168 vrtManager/nodedevs.py:294
|
||||
#: appsettings/views.py:180 vrtManager/nodedevs.py:294
|
||||
#: vrtManager/nodedevs.py:333
|
||||
msgid "Other"
|
||||
msgstr "Diğer"
|
||||
|
|
@ -2336,7 +2362,7 @@ msgstr "Bu sunucular bakımda ve hesaba katılmadı:"
|
|||
|
||||
#: computes/templates/computes/balance.html:32
|
||||
#: instances/templates/instances/snapshots_tab.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "Now"
|
||||
msgstr "Şimdi"
|
||||
|
||||
|
|
@ -8722,6 +8748,14 @@ msgstr ""
|
|||
"Harfler, rakamlar, nokta, tire ve alt çizgi. Kopya, filtrenin kurallarını ve "
|
||||
"başvurularını içerir."
|
||||
|
||||
#: operations/alerts.py:49
|
||||
msgid "Test alert"
|
||||
msgstr "Deneme uyarısı"
|
||||
|
||||
#: operations/alerts.py:49
|
||||
msgid "WebVirtCloud sends its alerts here."
|
||||
msgstr "WebVirtCloud uyarılarını buraya gönderir."
|
||||
|
||||
#: operations/api/serializers.py:37
|
||||
#, python-format
|
||||
msgid "%(phase)s (over its time limit)"
|
||||
|
|
@ -10520,10 +10554,25 @@ msgstr "Yalnızca dayandığı yedekten sonra değişenleri kopyalar"
|
|||
msgid "Incremental"
|
||||
msgstr "Artımlı"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:4
|
||||
msgid "A verification found this backup damaged:"
|
||||
msgstr "Bir doğrulama bu yedeği hasarlı buldu:"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:4
|
||||
#, python-format
|
||||
msgid ""
|
||||
"It builds on the backup taken %(time)s, which a verification found damaged:"
|
||||
msgstr ""
|
||||
"%(time)s tarihli yedeğe dayanıyor; bir doğrulama o yedeği hasarlı buldu:"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:5
|
||||
msgid "The restored disks may be damaged too."
|
||||
msgstr "Geri yüklenen diskler de hasarlı olabilir."
|
||||
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:4
|
||||
#: vmbackups/templates/vmbackups/restore.html:9
|
||||
#: vmbackups/templates/vmbackups/restore.html:19
|
||||
#: vmbackups/templates/vmbackups/restore_disk.html:18
|
||||
#: vmbackups/templates/vmbackups/restore.html:20
|
||||
#: vmbackups/templates/vmbackups/restore_disk.html:19
|
||||
msgid "Restore"
|
||||
msgstr "Geri yükle"
|
||||
|
||||
|
|
@ -10740,7 +10789,7 @@ msgstr ""
|
|||
"%(vm)s sanal makinesinin %(time)s tarihli, %(target)s hedefindeki yedeği "
|
||||
"kendi UUID'si ve MAC adresleriyle yeni bir sanal makine olarak geri yüklenir."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore.html:17
|
||||
#: vmbackups/templates/vmbackups/restore.html:18
|
||||
#, python-format
|
||||
msgid ""
|
||||
"On %(compute)s, in storage pool %(pool)s: the VM's host and the pool of its "
|
||||
|
|
@ -10765,7 +10814,7 @@ msgstr ""
|
|||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:6
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:8
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:34
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:35
|
||||
msgid "Restore over the VM"
|
||||
msgstr "VM'in üzerine geri yükle"
|
||||
|
||||
|
|
@ -10780,29 +10829,29 @@ msgstr ""
|
|||
"geri yüklenir: diskleri yeni birimler olarak kopyalanır ve VM bunlara "
|
||||
"geçirilir. Ayarları, MAC adresleri ve UUID'si aynı kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "After the restore"
|
||||
msgstr "Geri yüklemeden sonra"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:26
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:27
|
||||
msgid "The old volumes stay in their pools until you delete them."
|
||||
msgstr "Eski birimler siz silene kadar havuzlarında kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:27
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:28
|
||||
msgid ""
|
||||
"The disks the VM runs from now are deleted once it is switched to the new "
|
||||
"ones."
|
||||
msgstr "VM yeni disklere geçirilince şu an çalıştığı diskler silinir."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:28
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:29
|
||||
msgid "The UEFI variables return to the backup's."
|
||||
msgstr "UEFI değişkenleri yedekteki haline döner."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:29
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:30
|
||||
msgid "The TPM state returns to the backup's."
|
||||
msgstr "TPM durumu yedekteki haline döner."
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:34
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:35
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Restore the backup over %(vm)s? What the VM wrote since the backup is no "
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-19 13:10+0000\n"
|
||||
"POT-Creation-Date: 2026-11-19 14:12+0000\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
|
@ -793,7 +793,7 @@ msgstr "内存"
|
|||
#: instances/templates/create_instance_w2.html:118
|
||||
#: instances/templates/instances/settings_tab.html:25
|
||||
#: instances/templates/instances/stats_tab.html:53 vmbackups/forms.py:57
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "Disk"
|
||||
msgstr "磁盘"
|
||||
|
||||
|
|
@ -1883,102 +1883,128 @@ msgstr "对所有用户生效"
|
|||
msgid "Change theme"
|
||||
msgstr "更改主题"
|
||||
|
||||
#: appsettings/templates/appsettings.html:98
|
||||
#: appsettings/templates/appsettings.html:99
|
||||
msgid "Send a test alert"
|
||||
msgstr "发送测试告警"
|
||||
|
||||
#: appsettings/templates/appsettings.html:101
|
||||
#, python-format
|
||||
msgid "Save %(group_title)s"
|
||||
msgstr "保存%(group_title)s"
|
||||
|
||||
#: appsettings/views.py:45
|
||||
#: appsettings/views.py:46
|
||||
msgid "New VM defaults"
|
||||
msgstr "新建虚拟机默认值"
|
||||
|
||||
#: appsettings/views.py:48 instances/templates/instance.html:71
|
||||
#: appsettings/views.py:49 instances/templates/instance.html:71
|
||||
#: instances/templates/instances/destroy_instance_form.html:33
|
||||
#: instances/templates/instances/resize_tab.html:21
|
||||
#: instances/templates/instances/settings_tab.html:197
|
||||
msgid "Disks"
|
||||
msgstr "磁盘"
|
||||
|
||||
#: appsettings/views.py:52
|
||||
#: appsettings/views.py:53
|
||||
msgid "Clones"
|
||||
msgstr "克隆"
|
||||
|
||||
#: appsettings/views.py:53 console/templates/console-base.html:10
|
||||
#: appsettings/views.py:54 console/templates/console-base.html:10
|
||||
#: console/templates/console-base.html:23
|
||||
#: instances/templates/instance_actions.html:11
|
||||
#: instances/templates/instances/settings_tab.html:32
|
||||
msgid "Console"
|
||||
msgstr "控制台"
|
||||
|
||||
#: appsettings/views.py:54
|
||||
#: appsettings/views.py:55
|
||||
msgid "VM access and owners"
|
||||
msgstr "虚拟机访问与所有者"
|
||||
|
||||
#: appsettings/views.py:56
|
||||
#: appsettings/views.py:57
|
||||
msgid "Snapshots and jobs"
|
||||
msgstr "快照与任务"
|
||||
|
||||
#: appsettings/views.py:58
|
||||
#: appsettings/views.py:59
|
||||
msgid "Login"
|
||||
msgstr "登录"
|
||||
|
||||
#: appsettings/views.py:59
|
||||
#: appsettings/views.py:60
|
||||
msgid "Alerts"
|
||||
msgstr "告警"
|
||||
|
||||
#: appsettings/views.py:60
|
||||
#: appsettings/views.py:61
|
||||
msgid "Lists and pages"
|
||||
msgstr "列表与页面"
|
||||
|
||||
#: appsettings/views.py:68
|
||||
#: appsettings/views.py:69
|
||||
#, python-format
|
||||
msgid "%(setting)s takes at most %(length)s characters"
|
||||
msgstr "%(setting)s 最多 %(length)s 个字符"
|
||||
|
||||
#: appsettings/views.py:73
|
||||
#: appsettings/views.py:74
|
||||
#, python-format
|
||||
msgid "%(setting)s must be a whole number between %(low)s and %(high)s"
|
||||
msgstr "%(setting)s 必须是 %(low)s 到 %(high)s 之间的整数"
|
||||
|
||||
#: appsettings/views.py:76
|
||||
#: appsettings/views.py:77
|
||||
#, python-format
|
||||
msgid "%(setting)s must be one of %(choices)s"
|
||||
msgstr "%(setting)s 必须是以下之一:%(choices)s"
|
||||
|
||||
#: appsettings/views.py:80
|
||||
#: appsettings/views.py:81
|
||||
#, python-format
|
||||
msgid "%(setting)s takes letters, digits and '-' only"
|
||||
msgstr "%(setting)s 只能包含字母、数字和 '-'"
|
||||
|
||||
#: appsettings/views.py:90
|
||||
#: appsettings/views.py:91
|
||||
#, python-format
|
||||
msgid "%(setting)s: %(value)s is not an e-mail address or an http(s) URL"
|
||||
msgstr "%(setting)s:%(value)s 不是电子邮件地址或 http(s) URL"
|
||||
|
||||
#: appsettings/views.py:99
|
||||
#: appsettings/views.py:100
|
||||
msgid "Disk I/O native needs disk cache none or directsync"
|
||||
msgstr "磁盘 I/O native 需要磁盘缓存为 none 或 directsync"
|
||||
|
||||
#: appsettings/views.py:116
|
||||
#: appsettings/views.py:117
|
||||
msgid "Set an alert e-mail address or webhook and save it first"
|
||||
msgstr "请先设置并保存告警邮件地址或 Webhook"
|
||||
|
||||
#: appsettings/views.py:119
|
||||
msgid "E-mail"
|
||||
msgstr "电子邮件"
|
||||
|
||||
#: appsettings/views.py:119
|
||||
msgid "Webhook"
|
||||
msgstr "Webhook"
|
||||
|
||||
#: appsettings/views.py:121
|
||||
#, python-format
|
||||
msgid "%(channel)s: the test alert was sent"
|
||||
msgstr "%(channel)s:测试告警已发送"
|
||||
|
||||
#: appsettings/views.py:123
|
||||
#, python-format
|
||||
msgid "%(channel)s: the test alert failed: %(error)s"
|
||||
msgstr "%(channel)s:测试告警发送失败:%(error)s"
|
||||
|
||||
#: appsettings/views.py:128
|
||||
#, python-format
|
||||
msgid "Unknown theme: %(theme)s"
|
||||
msgstr "未知主题:%(theme)s"
|
||||
|
||||
#: appsettings/views.py:122
|
||||
#: appsettings/views.py:134
|
||||
#, python-format
|
||||
msgid "Theme is changed. Now: %(theme)s"
|
||||
msgstr "主题已更改。当前:%(theme)s"
|
||||
|
||||
#: appsettings/views.py:159
|
||||
#: appsettings/views.py:171
|
||||
#, python-format
|
||||
msgid "Saved: %(settings)s"
|
||||
msgstr "已保存:%(settings)s"
|
||||
|
||||
#: appsettings/views.py:161
|
||||
#: appsettings/views.py:173
|
||||
msgid "Nothing changed"
|
||||
msgstr "没有任何更改"
|
||||
|
||||
#: appsettings/views.py:168 vrtManager/nodedevs.py:294
|
||||
#: appsettings/views.py:180 vrtManager/nodedevs.py:294
|
||||
#: vrtManager/nodedevs.py:333
|
||||
msgid "Other"
|
||||
msgstr "其他"
|
||||
|
|
@ -2229,7 +2255,7 @@ msgstr "这些主机正在维护,未计入:"
|
|||
|
||||
#: computes/templates/computes/balance.html:32
|
||||
#: instances/templates/instances/snapshots_tab.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "Now"
|
||||
msgstr "现在"
|
||||
|
||||
|
|
@ -8203,6 +8229,14 @@ msgid ""
|
|||
"rules and references."
|
||||
msgstr "字母、数字、点、短横线和下划线。副本包含该过滤器的规则和引用。"
|
||||
|
||||
#: operations/alerts.py:49
|
||||
msgid "Test alert"
|
||||
msgstr "测试告警"
|
||||
|
||||
#: operations/alerts.py:49
|
||||
msgid "WebVirtCloud sends its alerts here."
|
||||
msgstr "WebVirtCloud 会将告警发送到这里。"
|
||||
|
||||
#: operations/api/serializers.py:37
|
||||
#, python-format
|
||||
msgid "%(phase)s (over its time limit)"
|
||||
|
|
@ -9899,10 +9933,24 @@ msgstr "只复制其所依赖的备份之后变化的部分"
|
|||
msgid "Incremental"
|
||||
msgstr "增量"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:4
|
||||
msgid "A verification found this backup damaged:"
|
||||
msgstr "验证发现此备份已损坏:"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:4
|
||||
#, python-format
|
||||
msgid ""
|
||||
"It builds on the backup taken %(time)s, which a verification found damaged:"
|
||||
msgstr "它基于 %(time)s 的备份,验证发现该备份已损坏:"
|
||||
|
||||
#: vmbackups/templates/vmbackups/damage_warning.html:5
|
||||
msgid "The restored disks may be damaged too."
|
||||
msgstr "恢复的磁盘也可能已损坏。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/delete_form.html:4
|
||||
#: vmbackups/templates/vmbackups/restore.html:9
|
||||
#: vmbackups/templates/vmbackups/restore.html:19
|
||||
#: vmbackups/templates/vmbackups/restore_disk.html:18
|
||||
#: vmbackups/templates/vmbackups/restore.html:20
|
||||
#: vmbackups/templates/vmbackups/restore_disk.html:19
|
||||
msgid "Restore"
|
||||
msgstr "恢复"
|
||||
|
||||
|
|
@ -10111,7 +10159,7 @@ msgid ""
|
|||
"with its own UUID and MAC addresses."
|
||||
msgstr "%(vm)s 在 %(time)s 的备份(位于 %(target)s)将恢复为一台拥有自己 UUID 和 MAC 地址的新虚拟机。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore.html:17
|
||||
#: vmbackups/templates/vmbackups/restore.html:18
|
||||
#, python-format
|
||||
msgid ""
|
||||
"On %(compute)s, in storage pool %(pool)s: the VM's host and the pool of its "
|
||||
|
|
@ -10132,7 +10180,7 @@ msgstr "%(vm)s 于 %(time)s 在 %(target)s 中的备份的一个磁盘将复制
|
|||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:6
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:8
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:34
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:35
|
||||
msgid "Restore over the VM"
|
||||
msgstr "恢复到虚拟机上"
|
||||
|
||||
|
|
@ -10146,29 +10194,29 @@ msgstr ""
|
|||
"%(vm)s 于 %(time)s 在 %(target)s 中的备份将恢复到该虚拟机上:其磁盘复制为新卷,虚拟机切换到这些卷。其设置、MAC 地址和 "
|
||||
"UUID 保持不变。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:18
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:19
|
||||
msgid "After the restore"
|
||||
msgstr "恢复之后"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:26
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:27
|
||||
msgid "The old volumes stay in their pools until you delete them."
|
||||
msgstr "旧卷会保留在其存储池中,直到您删除它们。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:27
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:28
|
||||
msgid ""
|
||||
"The disks the VM runs from now are deleted once it is switched to the new "
|
||||
"ones."
|
||||
msgstr "虚拟机切换到新磁盘后,其当前运行的磁盘将被删除。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:28
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:29
|
||||
msgid "The UEFI variables return to the backup's."
|
||||
msgstr "UEFI 变量恢复为备份中的状态。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:29
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:30
|
||||
msgid "The TPM state returns to the backup's."
|
||||
msgstr "TPM 状态恢复为备份中的状态。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:34
|
||||
#: vmbackups/templates/vmbackups/restore_over.html:35
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Restore the backup over %(vm)s? What the VM wrote since the backup is no "
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from django.conf import settings
|
|||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.utils import timezone, translation
|
||||
from django.utils.translation import gettext
|
||||
|
||||
from appsettings.models import AppSettings
|
||||
|
||||
|
|
@ -42,6 +43,27 @@ def alert(subject, text):
|
|||
logger.exception("queueing an alert failed")
|
||||
|
||||
|
||||
def test():
|
||||
"""A test notice sent at once to the channels saved: {channel: None when it took it, else the error}."""
|
||||
emails, url = channels()
|
||||
subject, text = gettext("Test alert"), gettext("WebVirtCloud sends its alerts here.")
|
||||
results = {}
|
||||
if emails:
|
||||
results["mail"] = _attempt(lambda: send_mail(f"WebVirtCloud: {subject}", text, None, emails))
|
||||
if url:
|
||||
results["webhook"] = _attempt(lambda: _post(url, json.dumps(
|
||||
{"subject": subject, "text": f"{subject}\n{text}", "time": timezone.now().isoformat()}).encode()))
|
||||
return results
|
||||
|
||||
|
||||
def _attempt(deliver):
|
||||
try:
|
||||
deliver()
|
||||
except Exception as err:
|
||||
return safe_text(err)
|
||||
return None
|
||||
|
||||
|
||||
def send():
|
||||
"""The notices not sent yet, oldest first, ROWS a pass. A channel that fails is not tried again in the
|
||||
pass, so a server that does not answer holds the worker's periodic pass (and the backup schedules) for
|
||||
|
|
|
|||
|
|
@ -171,6 +171,22 @@ class AlertTests(TestCase):
|
|||
self.assertContains(self.client.get(reverse("appsettings")), 'maxlength="255"')
|
||||
|
||||
|
||||
def test_a_test_alert_goes_at_once_to_each_channel_saved(self):
|
||||
self.client.force_login(self.user)
|
||||
channels("", "")
|
||||
response = self.client.post(reverse("appsettings"), {"test_alert": "1"}, follow=True)
|
||||
self.assertContains(response, "Set an alert e-mail address or webhook and save it first")
|
||||
channels("ops@example.com", "https://hooks.example.com/x")
|
||||
with patch("operations.alerts._post", side_effect=OSError("refused")):
|
||||
response = self.client.post(reverse("appsettings"), {"test_alert": "1"}, follow=True)
|
||||
self.assertContains(response, "E-mail: the test alert was sent")
|
||||
self.assertContains(response, "Webhook: the test alert failed: refused")
|
||||
self.assertEqual(mail.outbox[0].subject, "WebVirtCloud: Test alert")
|
||||
self.assertFalse(Alert.objects.exists()) # not queued
|
||||
page = self.client.get(reverse("appsettings")).content.decode()
|
||||
self.assertLess(page.index("Save Alerts"), page.index('name="test_alert"')) # Enter saves
|
||||
|
||||
|
||||
class HealthzTests(TestCase):
|
||||
def test_without_a_login_it_tells_whether_the_worker_runs(self):
|
||||
response = self.client.get(reverse("healthz"))
|
||||
|
|
|
|||
|
|
@ -136,6 +136,14 @@ class Backup(models.Model):
|
|||
deleted like a failed one."""
|
||||
return self.state == self.CREATING and self.operation_id is not None and self.operation.state in Operation.ACTIVE
|
||||
|
||||
def damaged_in_chain(self):
|
||||
"""It, or the first backup it builds on, that a verification found damaged; None."""
|
||||
backup, seen = self, set()
|
||||
while backup is not None and not backup.damage and backup.pk not in seen: # a broken chain may loop
|
||||
seen.add(backup.pk)
|
||||
backup = backup.parent
|
||||
return backup if backup is not None and backup.damage else None
|
||||
|
||||
def depended_on(self):
|
||||
"""Whether a backup builds on this one: a failed one holds nothing."""
|
||||
return self.children.filter(state__in=self.LIVING).exists()
|
||||
|
|
|
|||
7
vmbackups/templates/vmbackups/damage_warning.html
Normal file
7
vmbackups/templates/vmbackups/damage_warning.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{% load i18n %}{% load operations %}{% load bootstrap_icons %}{# a restore page: the backup or one it builds on found damaged #}
|
||||
{% with damaged=backup.damaged_in_chain %}{% if damaged %}
|
||||
<div class="alert alert-danger" role="alert">{% bs_icon 'exclamation-triangle' %}
|
||||
{% if damaged == backup %}{% trans "A verification found this backup damaged:" %}{% else %}{% blocktrans with time=damaged.created_at|date:"Y-m-d H:i" %}It builds on the backup taken {{ time }}, which a verification found damaged:{% endblocktrans %}{% endif %}
|
||||
{{ damaged.damage|words }} {% trans "The restored disks may be damaged too." %}
|
||||
</div>
|
||||
{% endif %}{% endwith %}
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with vm=backup.vm_name time=backup.created_at|date:"Y-m-d H:i" target=backup.target.name %}The backup of {{ vm }} taken {{ time }}, in {{ target }}, is restored as a new VM with its own UUID and MAC addresses.{% endblocktrans %}</p>
|
||||
{% include "vmbackups/damage_warning.html" %}
|
||||
<div class="card" style="max-width: 40rem;">
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with vm=backup.vm_name time=backup.created_at|date:"Y-m-d H:i" target=backup.target.name %}A disk of the backup of {{ vm }} taken {{ time }}, in {{ target }}, is copied as a new volume, attached to no VM.{% endblocktrans %}</p>
|
||||
{% include "vmbackups/damage_warning.html" %}
|
||||
<div class="card" style="max-width: 40rem;">
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with vm=backup.vm_name time=backup.created_at|date:"Y-m-d H:i" target=backup.target.name %}The backup of {{ vm }} taken {{ time }}, in {{ target }}, is restored over the VM: its disks are copied as new volumes and the VM is switched to them. Its settings, MAC addresses and UUID stay.{% endblocktrans %}</p>
|
||||
{% include "vmbackups/damage_warning.html" %}
|
||||
{% if problem %}
|
||||
<div class="alert alert-warning" role="status">{% bs_icon 'exclamation-triangle' %} {{ problem }}</div>
|
||||
{% else %}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{% load i18n %}{% load operations %}{% if backup.uuid|stringformat:"s" in pending_deletes %}<span class="badge text-bg-warning" data-backup-pending>{% trans "Deleting" %}</span>{% elif backup.state == "deleting" %}<span class="badge text-bg-warning" title="{% trans "Its deletion did not end; delete it again" %}">{% trans "Deleting" %}</span>{% elif backup.state == "ready" and backup.damage %}<span class="badge text-bg-danger" title="{{ backup.damage|words }}">{% trans "Damaged" %}</span>{% elif backup.state == "ready" %}<span class="badge text-bg-success"{% if backup.verified_at %} title="{% blocktrans with time=backup.verified_at|date:"Y-m-d H:i" %}Verified {{ time }}{% endblocktrans %}"{% endif %}>{% trans "Ready" %}</span>{% if backup.verified_at %} <span class="small text-body-secondary">{% trans "verified" %}</span>{% endif %}{% elif backup.being_made %}<span class="badge text-bg-info" data-backup-pending>{% trans "Creating" %}</span>{% if backup.operation_id %}{% if user.is_superuser or backup.operation.user_id == user.id %} <a class="small" href="{% url 'operations:job' backup.operation_id %}">{% trans "Progress" %}</a>{% endif %}{% endif %}{% elif backup.state == "missing" %}<span class="badge text-bg-danger" title="{% trans "Files of the backup are missing from the target" %}">{% trans "Missing" %}</span>{% else %}<span class="badge text-bg-danger">{% trans "Failed" %}</span>{% if backup.operation_id %}{% if user.is_superuser or backup.operation.user_id == user.id %} <a class="small" href="{% url 'operations:job' backup.operation_id %}">{% trans "Why?" %}</a>{% endif %}{% endif %}{% endif %}
|
||||
{% load i18n %}{% load operations %}{% if backup.uuid|stringformat:"s" in pending_deletes %}<span class="badge text-bg-warning" data-backup-pending>{% trans "Deleting" %}</span>{% elif backup.state == "deleting" %}<span class="badge text-bg-warning" title="{% trans "Its deletion did not end; delete it again" %}">{% trans "Deleting" %}</span>{% elif backup.state == "ready" and backup.damage %}<span class="badge text-bg-danger">{% trans "Damaged" %}</span><div class="small text-danger text-break">{{ backup.damage|words }}</div>{% elif backup.state == "ready" %}<span class="badge text-bg-success"{% if backup.verified_at %} title="{% blocktrans with time=backup.verified_at|date:"Y-m-d H:i" %}Verified {{ time }}{% endblocktrans %}"{% endif %}>{% trans "Ready" %}</span>{% if backup.verified_at %} <span class="small text-body-secondary">{% trans "verified" %}</span>{% endif %}{% elif backup.being_made %}<span class="badge text-bg-info" data-backup-pending>{% trans "Creating" %}</span>{% if backup.operation_id %}{% if user.is_superuser or backup.operation.user_id == user.id %} <a class="small" href="{% url 'operations:job' backup.operation_id %}">{% trans "Progress" %}</a>{% endif %}{% endif %}{% elif backup.state == "missing" %}<span class="badge text-bg-danger" title="{% trans "Files of the backup are missing from the target" %}">{% trans "Missing" %}</span>{% else %}<span class="badge text-bg-danger">{% trans "Failed" %}</span>{% if backup.operation_id %}{% if user.is_superuser or backup.operation.user_id == user.id %} <a class="small" href="{% url 'operations:job' backup.operation_id %}">{% trans "Why?" %}</a>{% endif %}{% endif %}{% endif %}
|
||||
|
|
|
|||
|
|
@ -289,3 +289,18 @@ class VerifyBackupTests(TransactionTestCase):
|
|||
page = self.client.get(reverse("vmbackups:index"))
|
||||
self.assertContains(page, "Damaged")
|
||||
self.assertContains(page, "The backup's file f is missing from the target")
|
||||
|
||||
def test_a_restore_page_tells_of_damage_in_the_chain(self):
|
||||
self.client.force_login(self.admin)
|
||||
damage = [{"text": "The backup's file %(name)s is missing from the target", "values": {"name": "base-vda.qcow2"}}]
|
||||
page = self.client.get(reverse("vmbackups:restore_disk", args=[self.incremental.uuid]))
|
||||
self.assertNotContains(page, "found damaged")
|
||||
Backup.objects.filter(pk=self.full.pk).update(damage=damage)
|
||||
self.assertEqual(Backup.objects.get(pk=self.incremental.pk).damaged_in_chain(), Backup.objects.get(pk=self.full.pk))
|
||||
page = self.client.get(reverse("vmbackups:restore_disk", args=[self.incremental.uuid]))
|
||||
self.assertContains(page, "which a verification found damaged")
|
||||
self.assertContains(page, "base-vda.qcow2 is missing from the target")
|
||||
page = self.client.get(reverse("vmbackups:index"))
|
||||
self.assertContains(page, "base-vda.qcow2 is missing from the target") # under the badge, not only a tooltip
|
||||
Backup.objects.filter(pk=self.full.pk).update(damage=[], parent=self.incremental) # a chain that loops
|
||||
self.assertIsNone(Backup.objects.get(pk=self.incremental.pk).damaged_in_chain())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue