diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index ea285002..77b4ecfb 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index f49a4c37..09d91326 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -75,7 +75,7 @@ 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 vmbackups/forms.py:22 +#: virtsecrets/forms.py:36 vmbackups/forms.py:22 vmbackups/forms.py:35 #: vmbackups/templates/vmbackups/targets.html:17 msgid "Name" msgstr "Ad" @@ -3246,7 +3246,7 @@ msgstr "" msgid "A password takes no line breaks or other control characters." msgstr "Parola satır sonu ya da başka denetim karakteri içeremez." -#: instances/forms.py:114 vrtManager/instance.py:1657 +#: instances/forms.py:114 vrtManager/instance.py:1719 msgid "" "The console listens on no address (on a network, a socket or nowhere); change" " it in the XML editor" @@ -3266,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:74 +#: instances/jobs.py:73 vmbackups/jobs.py:83 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ı" @@ -3287,17 +3287,17 @@ msgstr "Klonun adını boş adlar listesinden seçin" msgid "%(quota)s: cannot create '%(clone_name)s'." msgstr "%(quota)s: '%(clone_name)s' oluşturulamıyor." -#: instances/jobs.py:206 instances/jobs.py:646 +#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:499 #, python-format msgid "Instance '%(clone_name)s' already exists!" msgstr "'%(clone_name)s' sanal makinesi zaten mevcut!" -#: instances/jobs.py:208 +#: instances/jobs.py:208 vmbackups/jobs.py:501 #, python-format msgid "Instance name '%(clone_name)s' is longer than 64 characters" msgstr "'%(clone_name)s' sanal makine adı 64 karakterden uzun" -#: instances/jobs.py:211 +#: instances/jobs.py:211 vmbackups/jobs.py:503 #, python-format msgid "Instance name '%(clone_name)s' contains invalid characters!" msgstr "Sanal makine adı '%(clone_name)s' geçersiz karakterler içermektedir!" @@ -3340,7 +3340,7 @@ msgstr "" msgid "Delete snapshot" msgstr "Anlık görüntüyü sil" -#: instances/jobs.py:357 vrtManager/instance.py:2416 +#: instances/jobs.py:357 vrtManager/instance.py:2478 #, python-format msgid "The VM has no external snapshot named %(name)s" msgstr "Sanal makinede %(name)s adında harici anlık görüntü yok" @@ -3375,7 +3375,7 @@ msgstr "Sanal makine artık işin çalıştığı sunucuda değil" msgid "Take snapshot" msgstr "Anlık görüntü al" -#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2007 +#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2069 #, python-format msgid "A snapshot named %(name)s already exists" msgstr "%(name)s adında bir anlık görüntü zaten var" @@ -3454,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:211 +#: vmbackups/jobs.py:220 vmbackups/jobs.py:603 msgid "Copying disks" msgstr "Diskler kopyalanıyor" -#: instances/jobs.py:715 vmbackups/jobs.py:287 +#: instances/jobs.py:715 vmbackups/jobs.py:296 msgid "libvirt has no result of the copy" msgstr "libvirt'te kopyanın sonucu yok" @@ -3471,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:293 +#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:302 msgid "The copy failed" msgstr "Kopyalama başarısız oldu" @@ -3493,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:330 +#: instances/jobs.py:801 vmbackups/jobs.py:339 msgid "The job stopped before the copy started" msgstr "İş, kopyalama başlamadan durdu" -#: instances/jobs.py:808 vmbackups/jobs.py:378 +#: instances/jobs.py:808 vmbackups/jobs.py:387 msgid "libvirt is still copying the disks" msgstr "libvirt diskleri hâlâ kopyalıyor" @@ -3538,12 +3538,12 @@ msgstr "" msgid "Each network card needs a network" msgstr "Her ağ kartının bir ağı olmalı" -#: instances/jobs.py:868 vrtManager/instance.py:2860 +#: instances/jobs.py:868 vrtManager/backup.py:260 vrtManager/instance.py:2871 #, python-format msgid "This host has no network %(name)s" msgstr "Bu sunucuda %(name)s ağı yok" -#: instances/jobs.py:870 vrtManager/instance.py:2862 +#: instances/jobs.py:870 vrtManager/backup.py:264 vrtManager/instance.py:2873 #, python-format msgid "This host has no network filter %(name)s" msgstr "Bu sunucuda %(name)s ağ filtresi yok" @@ -3617,7 +3617,7 @@ msgstr "cloud-init tohumu, disk için bir dizin depolama havuzu gerektirir" msgid "This host offers no firmware %(firmware)s" msgstr "Bu sunucu %(firmware)s firmware'ini sunmuyor" -#: instances/jobs.py:957 vrtManager/instance.py:3209 +#: instances/jobs.py:957 vrtManager/instance.py:3221 msgid "This host offers no TPM 2.0: install swtpm on it" msgstr "Bu sunucu TPM 2.0 sunmuyor: üzerine swtpm kurun" @@ -4556,6 +4556,7 @@ 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/restore.html:9 #: vmbackups/templates/vmbackups/targets.html:17 msgid "Backups" msgstr "Yedekler" @@ -4926,7 +4927,7 @@ msgid "Add USB device" msgstr "USB aygıtı ekle" #: instances/templates/instances/host_devices_form.html:18 -#: vrtManager/instance.py:3113 +#: vrtManager/instance.py:3124 msgid "" "A VM with a saved state does not change its USB devices: start it, or start " "it without its saved state" @@ -6944,7 +6945,7 @@ msgstr "Birim başarıyla değiştirildi." msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "%(dev)s diski bu sanal makinenin bir depolama birimi değil" -#: instances/views.py:1603 vrtManager/instance.py:2426 +#: instances/views.py:1603 vrtManager/instance.py:2488 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "" "Sanal makinenin kaydedilmiş durumu var; önce başlatın veya kaydedilmiş durumu" @@ -7006,7 +7007,7 @@ msgstr "Anlık görüntü silinmedi: %(err)s" msgid "Add at least one device to the boot order." msgstr "Ön yükleme sırasına en az bir aygıt ekleyin." -#: instances/views.py:1916 vrtManager/instance.py:1198 +#: instances/views.py:1916 vrtManager/instance.py:1260 msgid "Invalid Device Type for boot order" msgstr "Ön yükleme sırası için geçersiz aygıt türü" @@ -9723,7 +9724,7 @@ msgstr "" "Eski değerin yerini hemen alır; bir parolanın şifrelediği veriler yeniden " "şifrelenmez." -#: vmbackups/forms.py:12 +#: vmbackups/forms.py:12 vmbackups/forms.py:36 msgid "Compute" msgstr "Sunucu" @@ -9731,17 +9732,37 @@ msgstr "Sunucu" msgid "A backup target with this name exists" msgstr "Bu adla bir yedek hedefi zaten var" -#: vmbackups/jobs.py:47 +#: vmbackups/forms.py:37 +msgid "Storage pool for the disks" +msgstr "Diskler için depolama havuzu" + +#: vmbackups/forms.py:38 +msgid "Connect the network" +msgstr "Ağı bağla" + +#: vmbackups/forms.py:39 +msgid "" +"The restored guest keeps the VM's addresses and host name: connected beside " +"the VM, they clash." +msgstr "" +"Geri yüklenen konuk, sanal makinenin adreslerini ve ana bilgisayar adını " +"taşır: sanal makinenin yanında ağa bağlanırsa çakışırlar." + +#: vmbackups/forms.py:41 +msgid "Start after restore" +msgstr "Geri yüklendikten sonra başlat" + +#: vmbackups/jobs.py:56 #, 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:57 +#: vmbackups/jobs.py:66 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:61 +#: vmbackups/jobs.py:70 msgid "" "A running VM's backup needs libvirt 11.10 or later; shut the VM down to back " "it up" @@ -9749,35 +9770,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:63 +#: vmbackups/jobs.py:72 msgid "A paused VM's file systems cannot be frozen" msgstr "Duraklatılmış bir sanal makinenin dosya sistemleri dondurulamaz" -#: vmbackups/jobs.py:65 +#: vmbackups/jobs.py:74 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:115 +#: vmbackups/jobs.py:124 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:176 +#: vmbackups/jobs.py:185 msgid "Back up VM" msgstr "Sanal makineyi yedekle" -#: vmbackups/jobs.py:227 vmbackups/jobs.py:294 +#: vmbackups/jobs.py:236 vmbackups/jobs.py:303 msgid "Writing the backup's files" msgstr "Yedeğin dosyaları yazılıyor" -#: vmbackups/jobs.py:306 +#: vmbackups/jobs.py:315 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:355 +#: vmbackups/jobs.py:364 #, python-format msgid "" "The VM is no longer on the compute the job ran on; check these volumes of the" @@ -9786,7 +9807,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:372 +#: vmbackups/jobs.py:381 #, python-format msgid "" "A disk was being copied when the job stopped; check these volumes of the " @@ -9795,7 +9816,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:382 +#: vmbackups/jobs.py:391 #, python-format msgid "" "Another backup runs on the VM; check these volumes of the backup target, then" @@ -9804,7 +9825,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:388 +#: vmbackups/jobs.py:397 #, python-format msgid "" "libvirt has no result of the copy; check these volumes of the backup target, " @@ -9813,29 +9834,89 @@ msgstr "" "libvirt'te kopyanın sonucu yok; yedek hedefindeki şu birimleri kontrol edin, " "sonra bu işi çözün: %(volumes)s" -#: vmbackups/jobs.py:396 +#: vmbackups/jobs.py:405 msgid "The job stopped before the copy ended" msgstr "İş, kopyalama bitmeden durdu" -#: vmbackups/jobs.py:403 +#: vmbackups/jobs.py:412 #, 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 +#: vmbackups/jobs.py:430 #, 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 +#: vmbackups/jobs.py:443 msgid "Delete backup" msgstr "Yedeği sil" -#: vmbackups/jobs.py:443 +#: vmbackups/jobs.py:452 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/jobs.py:516 +#, python-format +msgid "The backup's file %(name)s is missing from the target" +msgstr "Yedeğin %(name)s dosyası hedefte yok" + +#: vmbackups/jobs.py:519 vmbackups/jobs.py:521 +#, python-format +msgid "The backup's file %(name)s differs from the one written" +msgstr "Yedeğin %(name)s dosyası yazılandan farklı" + +#: vmbackups/jobs.py:531 vmbackups/templates/vmbackups/restore.html:7 +msgid "Restore backup" +msgstr "Yedeği geri yükle" + +#: vmbackups/jobs.py:544 +msgid "Only a ready backup is restored" +msgstr "Yalnızca hazır bir yedek geri yüklenir" + +#: vmbackups/jobs.py:574 +#, python-format +msgid "A VM named %(name)s exists on %(compute)s" +msgstr "%(compute)s üzerinde %(name)s adlı bir sanal makine var" + +#: vmbackups/jobs.py:582 +#, python-format +msgid "This host has no active directory storage pool %(pool)s" +msgstr "Bu sunucuda %(pool)s adlı etkin bir dizin depolama havuzu yok" + +#: vmbackups/jobs.py:599 +#, python-format +msgid "The NVRAM file %(path)s exists already" +msgstr "%(path)s NVRAM dosyası zaten var" + +#: vmbackups/jobs.py:630 +#, python-format +msgid "The VM was restored; it did not start: %(error)s" +msgstr "Sanal makine geri yüklendi; başlamadı: %(error)s" + +#: vmbackups/jobs.py:652 +#, python-format +msgid "" +"A disk was being copied when the job stopped; check this volume, then resolve" +" this job: %(volumes)s" +msgstr "" +"İş durduğunda bir disk kopyalanıyordu; bu birimi kontrol edin, sonra bu işi " +"çözün: %(volumes)s" + +#: vmbackups/jobs.py:657 +#, python-format +msgid "" +"Storage pool %(pool)s is not active; the restore's copies in it are removed " +"when it is" +msgstr "" +"%(pool)s depolama havuzu etkin değil; geri yüklemenin içindeki kopyaları " +"havuz etkin olunca kaldırılır" + +#: vmbackups/jobs.py:666 +msgid "The VM was not defined; its copies were removed" +msgstr "Sanal makine tanımlanmadı; kopyaları kaldırıldı" + #: vmbackups/templates/vmbackups/consistency.html:1 msgid "Shut off" msgstr "Kapalı" @@ -9848,6 +9929,12 @@ msgstr "Dondurulmuş" msgid "Crash-consistent" msgstr "Çökme tutarlı" +#: vmbackups/templates/vmbackups/delete_form.html:1 +#: vmbackups/templates/vmbackups/restore.html:9 +#: vmbackups/templates/vmbackups/restore.html:18 +msgid "Restore" +msgstr "Geri yükle" + #: vmbackups/templates/vmbackups/delete_form.html:3 #, python-format msgid "" @@ -9916,6 +10003,15 @@ msgstr "Süzgece uyan yedek yok." 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/restore.html:12 +#, python-format +msgid "" +"The backup of %(vm)s taken %(time)s, in %(target)s, is restored as a new VM " +"with its own UUID and MAC addresses." +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/target.html:11 #, python-format msgid "%(counter)s backup." @@ -10154,6 +10250,25 @@ msgid "" "written" msgstr "Yedek hedefinden geri okunan %(name)s dosyası yazılandan farklı" +#: vrtManager/backup.py:254 +#, python-format +msgid "" +"This host cannot run the VM's emulator %(emulator)s with machine type " +"%(machine)s: %(error)s" +msgstr "" +"Bu sunucu sanal makinenin %(emulator)s öykünücüsünü %(machine)s makine " +"türüyle çalıştıramıyor: %(error)s" + +#: vrtManager/backup.py:258 +#, python-format +msgid "This host has no firmware %(loader)s" +msgstr "Bu sunucuda %(loader)s firmware'i yok" + +#: vrtManager/backup.py:262 +#, python-format +msgid "This host has no bridge %(name)s" +msgstr "Bu sunucuda %(name)s köprüsü yok" + #: vrtManager/connection.py:45 msgid "Connection closed (error)" msgstr "Bağlantı kapandı (hata)" @@ -10413,7 +10528,13 @@ msgstr "" "Anlık görüntü adları 1-64 harf, rakam, '.', '_' veya '-' karakterinden oluşur" " ve '.' ile başlamaz" -#: vrtManager/instance.py:1186 +#: vrtManager/instance.py:732 +msgid "A VM with a host's or an external TPM is not cloned; remove it first" +msgstr "" +"Ana makinenin ya da harici bir TPM'i olan sanal makine klonlanmaz; önce onu " +"kaldırın" + +#: vrtManager/instance.py:1248 msgid "" "A device other than a disk or NIC is in the boot order: change it in the XML " "editor" @@ -10421,47 +10542,47 @@ msgstr "" "Önyükleme sırasında disk veya NIC dışında bir aygıt var: bunu XML " "düzenleyicide değiştirin" -#: vrtManager/instance.py:1201 +#: vrtManager/instance.py:1263 #, python-format msgid "Boot device %(dev)s is not in the definition" msgstr "Ön yükleme aygıtı %(dev)s tanımda yok" -#: vrtManager/instance.py:1221 +#: vrtManager/instance.py:1283 #, python-format msgid "CD-ROM %(dev)s is not in the running definition" msgstr "CD-ROM %(dev)s çalışan tanımda yok" -#: vrtManager/instance.py:1222 +#: vrtManager/instance.py:1284 #, python-format msgid "CD-ROM %(dev)s is not in the persistent definition" msgstr "CD-ROM %(dev)s kalıcı tanımda yok" -#: vrtManager/instance.py:1235 +#: vrtManager/instance.py:1297 #, python-format msgid "Media of %(dev)s changed in the running VM only: %(err)s" msgstr "%(dev)s ortamı yalnızca çalışan sanal makinede değişti: %(err)s" -#: vrtManager/instance.py:1246 +#: vrtManager/instance.py:1308 #, python-format msgid "ISO image %(image)s was not found" msgstr "ISO imajı %(image)s bulunamadı" -#: vrtManager/instance.py:1248 +#: vrtManager/instance.py:1310 #, python-format msgid "ISO image %(image)s is in more than one storage pool" msgstr "ISO imajı %(image)s birden fazla depolama havuzunda var" -#: vrtManager/instance.py:1343 +#: vrtManager/instance.py:1405 #, python-format msgid "Disk %(target_dev)s is not in the VM's definition" msgstr "Disk %(target_dev)s sanal makinenin tanımında yok" -#: vrtManager/instance.py:1475 +#: vrtManager/instance.py:1537 msgid "Please shutdown the instance then try to enable vCPU hotplug" msgstr "" "vCPU hotplug özelliğini etkinleştirmek için önce sanal makineyi kapatın" -#: vrtManager/instance.py:1678 +#: vrtManager/instance.py:1740 #, python-format msgid "" "The serial console is a %(type)s one, the browser opens only a pty one; " @@ -10470,11 +10591,11 @@ msgstr "" "Seri konsol %(type)s türünde, tarayıcı yalnızca pty türünü açar; bunu XML " "düzenleyicide değiştirin" -#: vrtManager/instance.py:1789 +#: vrtManager/instance.py:1851 msgid "The VM has no video card" msgstr "Sanal makinede ekran kartı yok" -#: vrtManager/instance.py:1799 +#: vrtManager/instance.py:1861 #, python-format msgid "" "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set" @@ -10483,62 +10604,62 @@ msgstr "" "VM'nin CPU topolojisi %(count)s vCPU içeriyor: başka bir en fazla değer için " "onu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:1825 +#: vrtManager/instance.py:1887 #, python-format msgid "The VM's next start has a maximum memory of %(max)s MiB" msgstr "" "Sanal makinenin bir sonraki başlangıcındaki en yüksek bellek %(max)s MiB" -#: vrtManager/instance.py:1966 +#: vrtManager/instance.py:2028 msgid "" "The VM has external snapshots; internal snapshots cannot be mixed with them" msgstr "" "Sanal makinenin harici anlık görüntüleri var; dahili anlık görüntüler " "bunlarla karıştırılamaz" -#: vrtManager/instance.py:1998 +#: vrtManager/instance.py:2060 msgid "A snapshot with memory is not quiesced; it keeps the whole guest state" msgstr "" "Bellekli bir anlık görüntüde dosya sistemleri dondurulmaz; tüm konuk durumunu" " saklar" -#: vrtManager/instance.py:2000 +#: vrtManager/instance.py:2062 msgid "Only a running VM's file systems can be frozen" msgstr "Yalnızca çalışan bir sanal makinenin dosya sistemleri dondurulabilir" -#: vrtManager/instance.py:2002 +#: vrtManager/instance.py:2064 msgid "The QEMU guest agent is not connected; it freezes the file systems" msgstr "QEMU konuk aracısı bağlı değil; dosya sistemlerini o dondurur" -#: vrtManager/instance.py:2005 +#: vrtManager/instance.py:2067 msgid "" "The VM has internal snapshots; external snapshots cannot be mixed with them" msgstr "" "Sanal makinenin dahili anlık görüntüleri var; harici anlık görüntüler " "bunlarla karıştırılamaz" -#: vrtManager/instance.py:2010 +#: vrtManager/instance.py:2072 msgid "Newer snapshots exist after the last revert; delete them first" msgstr "" "Son geri dönüşten sonra daha yeni anlık görüntüler var; önce onları silin" -#: vrtManager/instance.py:2013 +#: vrtManager/instance.py:2075 msgid "No snapshot is current; revert to a snapshot first" msgstr "Geçerli anlık görüntü yok; önce bir anlık görüntüye geri dönün" -#: vrtManager/instance.py:2019 +#: vrtManager/instance.py:2081 #, python-format msgid "Eject the media from %(dev)s first" msgstr "Önce %(dev)s içindeki ortamı çıkarın" -#: vrtManager/instance.py:2021 +#: vrtManager/instance.py:2083 #, python-format msgid "Disk %(dev)s is not a file; external snapshots need file disks" msgstr "" "Disk %(dev)s bir dosya değil; harici anlık görüntüler dosya diskleri " "gerektirir" -#: vrtManager/instance.py:2029 +#: vrtManager/instance.py:2091 #, python-format msgid "" "The storage pools could not be refreshed, so their free space is unknown: " @@ -10546,21 +10667,21 @@ msgid "" msgstr "" "Depolama havuzları yenilenemedi, bu yüzden boş alanları bilinmiyor: %(err)s" -#: vrtManager/instance.py:2050 +#: vrtManager/instance.py:2112 msgid "Memory is saved only from a running VM" msgstr "Bellek yalnızca çalışan bir sanal makineden kaydedilir" -#: vrtManager/instance.py:2052 +#: vrtManager/instance.py:2114 msgid "The VM has no disk to keep its memory next to" msgstr "Sanal makinenin, belleğinin yanına kaydedileceği bir diski yok" -#: vrtManager/instance.py:2056 +#: vrtManager/instance.py:2118 #, python-format msgid "%(disk)s is not in a storage pool; memory is saved only into one" msgstr "" "%(disk)s bir depolama havuzunda değil; bellek yalnızca bir havuza kaydedilir" -#: vrtManager/instance.py:2087 +#: vrtManager/instance.py:2149 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the snapshot needs %(size).1f " @@ -10571,7 +10692,7 @@ msgstr "" "%(size).1f GiB gerektiriyor (sanal makinenin oradaki disklerinin " "%%%(percent)g kadarı, en az %(minimum)g GiB, ve kaydediliyorsa bellek)" -#: vrtManager/instance.py:2105 +#: vrtManager/instance.py:2167 msgid "" "This snapshot was taken by an older version on a UEFI VM and cannot be " "reverted; delete it instead" @@ -10579,7 +10700,7 @@ msgstr "" "Bu anlık görüntü UEFI bir sanal makinede eski bir sürümle alındı ve geri " "dönülemez; bunun yerine silin" -#: vrtManager/instance.py:2135 +#: vrtManager/instance.py:2197 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is " @@ -10588,7 +10709,7 @@ msgstr "" "Geri dönüş iki kez başarısız oldu; biraz sonra tekrar deneyin (%(error)s). " "Sanal makine çalışıyor." -#: vrtManager/instance.py:2137 +#: vrtManager/instance.py:2199 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is shut " @@ -10597,13 +10718,13 @@ msgstr "" "Geri dönüş iki kez başarısız oldu; biraz sonra tekrar deneyin (%(error)s). " "Sanal makine kapalı." -#: vrtManager/instance.py:2305 +#: vrtManager/instance.py:2367 msgid "A disk moves when its VM is defined and running, paused or shut off" msgstr "" "Bir disk, sanal makinesi tanımlıyken ve çalışırken, duraklatılmışken veya " "kapalıyken taşınır" -#: vrtManager/instance.py:2307 +#: vrtManager/instance.py:2369 msgid "" "A disk of a VM with snapshots, a saved state or a running block job does not " "move" @@ -10611,7 +10732,7 @@ msgstr "" "Anlık görüntüleri, kaydedilmiş durumu veya çalışan bir blok işi olan sanal " "makinenin diski taşınmaz" -#: vrtManager/instance.py:2315 +#: vrtManager/instance.py:2377 #, python-format msgid "" "%(dev)s is not a disk file of the VM, the same in its running and next " @@ -10620,127 +10741,121 @@ msgstr "" "%(dev)s, sanal makinenin çalışan ve sonraki başlatma tanımlarında aynı olan " "bir disk dosyası değil" -#: vrtManager/instance.py:2320 +#: vrtManager/instance.py:2382 #, python-format msgid "%(dev)s does not move: only writable raw and qcow2 disks do" msgstr "%(dev)s taşınmaz: yalnızca yazılabilir raw ve qcow2 diskler taşınır" -#: vrtManager/instance.py:2327 +#: vrtManager/instance.py:2389 #, python-format msgid "%(dev)s does not move: no storage pool has %(path)s" msgstr "%(dev)s taşınmaz: hiçbir depolama havuzunda %(path)s yok" -#: vrtManager/instance.py:2329 +#: vrtManager/instance.py:2391 #, python-format msgid "%(dev)s does not move: it has a backing file" msgstr "%(dev)s taşınmaz: temel (backing) dosyası var" -#: vrtManager/instance.py:2332 +#: vrtManager/instance.py:2394 #, python-format msgid "%(pool_name)s is not an active pool of disk files of this host" msgstr "%(pool_name)s bu sunucunun etkin bir disk dosyası havuzu değil" -#: vrtManager/instance.py:2335 +#: vrtManager/instance.py:2397 #, python-format msgid "%(dev)s is in pool %(pool_name)s already" msgstr "%(dev)s zaten %(pool_name)s havuzunda" -#: vrtManager/instance.py:2339 +#: vrtManager/instance.py:2401 #, python-format msgid "Pool %(pool_name)s already has a file %(name)s" msgstr "%(pool_name)s havuzunda zaten %(name)s dosyası var" -#: vrtManager/instance.py:2363 +#: vrtManager/instance.py:2425 #, python-format msgid "The copy of %(dev)s ended before it was complete" msgstr "%(dev)s kopyası tamamlanmadan sona erdi" -#: vrtManager/instance.py:2408 +#: vrtManager/instance.py:2470 #, python-format msgid "%(error)s; remove %(dest)s if it is there: %(cleanup_error)s" msgstr "%(error)s; varsa %(dest)s dosyasını kaldırın: %(cleanup_error)s" -#: vrtManager/instance.py:2410 +#: vrtManager/instance.py:2472 #, python-format msgid "%(error)s; the VM may use %(dest)s now: check its disk %(dev)s" msgstr "" "%(error)s; sanal makine şu anda %(dest)s dosyasını kullanıyor olabilir: " "%(dev)s diskini kontrol edin" -#: vrtManager/instance.py:2417 +#: vrtManager/instance.py:2479 #, python-format msgid "The VM has no internal snapshot named %(name)s" msgstr "Sanal makinenin %(name)s adlı dahili anlık görüntüsü yok" -#: vrtManager/instance.py:2428 +#: vrtManager/instance.py:2490 msgid "A snapshot job is still running on this VM; try again when it ends" msgstr "" "Bu sanal makinede hâlâ bir anlık görüntü işi çalışıyor; bittiğinde tekrar " "deneyin" -#: vrtManager/instance.py:2438 +#: vrtManager/instance.py:2500 msgid "Shut the VM down to revert to an internal snapshot" msgstr "Dahili bir anlık görüntüye geri dönmek için sanal makineyi kapatın" -#: vrtManager/instance.py:2525 -msgid "A VM with a host's or an external TPM is not cloned; remove it first" -msgstr "" -"Ana makinenin ya da harici bir TPM'i olan sanal makine klonlanmaz; önce onu " -"kaldırın" - -#: vrtManager/instance.py:2556 +#: vrtManager/instance.py:2567 msgid "Cannot clone a VM whose NVRAM is not a file" msgstr "NVRAM'i dosya olmayan bir sanal makine klonlanamaz" -#: vrtManager/instance.py:2627 +#: vrtManager/instance.py:2638 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(path)s" msgstr "" "Klonlama başarısız oldu (%(err)s); bu kopyaları elle kaldırın: %(path)s" -#: vrtManager/instance.py:2638 +#: vrtManager/instance.py:2649 msgid "Shut the VM down before cloning it" msgstr "Klonlamadan önce sanal makineyi kapatın" -#: vrtManager/instance.py:2665 +#: vrtManager/instance.py:2676 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(leftovers)s" msgstr "" "Klonlama başarısız oldu (%(err)s); bu kopyaları elle kaldırın: %(leftovers)s" -#: vrtManager/instance.py:2676 +#: vrtManager/instance.py:2687 msgid "Live clone needs libvirt 11.10 or later; shut the VM down to clone it" msgstr "" "Canlı klonlama libvirt 11.10 veya sonrasını gerektirir; klonlamak için sanal " "makineyi kapatın" -#: vrtManager/instance.py:2679 +#: vrtManager/instance.py:2690 msgid "A VM with a TPM is cloned only shut down" msgstr "TPM'i olan bir sanal makine yalnızca kapalıyken klonlanır" -#: vrtManager/instance.py:2682 +#: vrtManager/instance.py:2693 #, python-format msgid "Disk %(dev)s is not a local file; shut the VM down to clone it" msgstr "" "Disk %(dev)s yerel bir dosya değil; klonlamak için sanal makineyi kapatın" -#: vrtManager/instance.py:2684 +#: vrtManager/instance.py:2695 #, python-format msgid "Disk %(dev)s is shareable; shut the VM down to clone it" msgstr "Disk %(dev)s paylaşılabilir; klonlamak için sanal makineyi kapatın" -#: vrtManager/instance.py:2689 +#: vrtManager/instance.py:2700 #, python-format msgid "Disk %(dev)s changes at the next start; shut the VM down to clone it" msgstr "" "Disk %(dev)s sonraki başlatmada değişiyor; klonlamak için sanal makineyi " "kapatın" -#: vrtManager/instance.py:2691 +#: vrtManager/instance.py:2702 msgid "Another job is running on the VM; clone it when that ends" msgstr "Sanal makinede başka bir iş çalışıyor; o bittiğinde klonlayın" -#: vrtManager/instance.py:2717 +#: vrtManager/instance.py:2728 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the clone needs %(size).1f GiB" @@ -10750,25 +10865,25 @@ msgstr "" "gerektiriyor (kopyalanan diskler, artı bunların %%%(percent)g kadarı, en az " "%(minimum)g GiB)" -#: vrtManager/instance.py:2734 +#: vrtManager/instance.py:2745 #, python-format msgid "Volume %(name)s already exists in storage pool %(pool)s" msgstr "%(name)s birimi %(pool)s depolama havuzunda zaten var" -#: vrtManager/instance.py:2899 +#: vrtManager/instance.py:2910 msgid "A network interface that is a host device is removed in the XML editor" msgstr "Sunucu aygıtı olan bir ağ arabirimi XML düzenleyicide kaldırılır" -#: vrtManager/instance.py:2915 +#: vrtManager/instance.py:2926 #, python-format msgid "No network interface with MAC %(old_mac)s" msgstr "MAC adresi %(old_mac)s olan ağ arabirimi yok" -#: vrtManager/instance.py:2918 +#: vrtManager/instance.py:2929 msgid "A network interface that is a host device is changed in the XML editor" msgstr "Sunucu aygıtı olan bir ağ arabirimi XML düzenleyicide değiştirilir" -#: vrtManager/instance.py:3012 +#: vrtManager/instance.py:3023 msgid "" "A VM changes its PCI devices while it runs, or is shut off without a saved " "state" @@ -10776,43 +10891,43 @@ msgstr "" "Sanal makine PCI aygıtlarını çalışırken veya kaydedilmiş durumu olmadan " "kapalıyken değiştirir" -#: vrtManager/instance.py:3033 +#: vrtManager/instance.py:3044 #, python-format msgid "%(err)s; whether the VM has %(device)s now is not known" msgstr "%(err)s; sanal makinede şu anda %(device)s olup olmadığı bilinmiyor" -#: vrtManager/instance.py:3035 +#: vrtManager/instance.py:3046 #, python-format msgid "%(err)s; %(device)s: the VM is not running, its next start has it" msgstr "%(err)s; %(device)s: sanal makine çalışmıyor, sonraki başlatmada var" -#: vrtManager/instance.py:3036 +#: vrtManager/instance.py:3047 #, python-format msgid "" "%(err)s; %(device)s: the VM is not running, its next start does not have it" msgstr "%(err)s; %(device)s: sanal makine çalışmıyor, sonraki başlatmada yok" -#: vrtManager/instance.py:3037 +#: vrtManager/instance.py:3048 #, python-format msgid "%(err)s; %(device)s: the running VM has it, its next start has it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede var, sonraki başlatmada var" -#: vrtManager/instance.py:3038 +#: vrtManager/instance.py:3049 #, python-format msgid "" "%(err)s; %(device)s: the running VM has it, its next start does not have it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede var, sonraki başlatmada yok" -#: vrtManager/instance.py:3039 +#: vrtManager/instance.py:3050 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start has it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede yok, sonraki başlatmada var" -#: vrtManager/instance.py:3041 +#: vrtManager/instance.py:3052 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start does not" @@ -10820,48 +10935,48 @@ msgid "" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede yok, sonraki başlatmada yok" -#: vrtManager/instance.py:3075 +#: vrtManager/instance.py:3086 #, python-format msgid "The VM has no PCI device %(address)s" msgstr "Sanal makinede %(address)s PCI aygıtı yok" -#: vrtManager/instance.py:3096 +#: vrtManager/instance.py:3107 msgid "The VM has no USB controller" msgstr "Sanal makinede USB denetleyicisi yok" -#: vrtManager/instance.py:3130 +#: vrtManager/instance.py:3141 msgid "The VM has no such USB device" msgstr "Sanal makinede böyle bir USB aygıtı yok" -#: vrtManager/instance.py:3144 +#: vrtManager/instance.py:3155 #, python-format msgid "The VM has no network interface %(mac)s" msgstr "Sanal makinede %(mac)s ağ arabirimi yok" -#: vrtManager/instance.py:3175 +#: vrtManager/instance.py:3187 msgid "The VM has its own RNG device: change it in the XML editor" msgstr "" "Sanal makinenin kendi RNG aygıtı var: bunu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:3202 +#: vrtManager/instance.py:3214 msgid "The VM has its own TPM: change it in the XML editor" msgstr "Sanal makinenin kendi TPM'i var: bunu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:3221 +#: vrtManager/instance.py:3233 #, python-format msgid "Unknown crash action %(action)s" msgstr "Bilinmeyen çökme eylemi %(action)s" -#: vrtManager/instance.py:3248 +#: vrtManager/instance.py:3260 #, python-format msgid "Network interface %(mac)s is not in the definition" msgstr "%(mac)s ağ arayüzü tanımda yok" -#: vrtManager/instance.py:3339 +#: vrtManager/instance.py:3351 msgid "The guest agent did not answer in time; nothing was changed" msgstr "Konuk ajanı zamanında yanıt vermedi; hiçbir şey değiştirilmedi" -#: vrtManager/instance.py:3342 +#: vrtManager/instance.py:3354 msgid "The VM runs Windows: its guest agent sets no root password or SSH key" msgstr "" "Sanal makinede Windows çalışıyor: konuk ajanı root parolası ya da SSH " diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 89be5e04..aacd3e07 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index 0c8204ff..15d15fdb 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -72,7 +72,7 @@ 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 vmbackups/forms.py:22 +#: virtsecrets/forms.py:36 vmbackups/forms.py:22 vmbackups/forms.py:35 #: vmbackups/templates/vmbackups/targets.html:17 msgid "Name" msgstr "名称" @@ -3095,7 +3095,7 @@ msgstr "VNC 密码最多 8 个字母、数字或符号,不能有带重音的 msgid "A password takes no line breaks or other control characters." msgstr "密码不能包含换行或其他控制字符。" -#: instances/forms.py:114 vrtManager/instance.py:1657 +#: instances/forms.py:114 vrtManager/instance.py:1719 msgid "" "The console listens on no address (on a network, a socket or nowhere); change" " it in the XML editor" @@ -3111,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:74 +#: instances/jobs.py:73 vmbackups/jobs.py:83 msgid "The VM moved to another compute after the job was queued" msgstr "任务排队后,虚拟机已移到另一个计算节点" @@ -3132,17 +3132,17 @@ msgstr "请从可用名称列表中选择克隆的名称" msgid "%(quota)s: cannot create '%(clone_name)s'." msgstr "%(quota)s:无法创建“%(clone_name)s”。" -#: instances/jobs.py:206 instances/jobs.py:646 +#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:499 #, python-format msgid "Instance '%(clone_name)s' already exists!" msgstr "虚拟机 '%(clone_name)s' 已存在!" -#: instances/jobs.py:208 +#: instances/jobs.py:208 vmbackups/jobs.py:501 #, python-format msgid "Instance name '%(clone_name)s' is longer than 64 characters" msgstr "虚拟机名称“%(clone_name)s”超过 64 个字符" -#: instances/jobs.py:211 +#: instances/jobs.py:211 vmbackups/jobs.py:503 #, python-format msgid "Instance name '%(clone_name)s' contains invalid characters!" msgstr "虚拟机名称 '%(clone_name)s' 包含无效字符!" @@ -3182,7 +3182,7 @@ msgstr "虚拟机未定义;请检查这些卷,然后处理此任务:%(volu msgid "Delete snapshot" msgstr "删除快照" -#: instances/jobs.py:357 vrtManager/instance.py:2416 +#: instances/jobs.py:357 vrtManager/instance.py:2478 #, python-format msgid "The VM has no external snapshot named %(name)s" msgstr "虚拟机没有名为 %(name)s 的外部快照" @@ -3214,7 +3214,7 @@ msgstr "虚拟机已不在运行该任务的计算节点上" msgid "Take snapshot" msgstr "创建快照" -#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2007 +#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2069 #, python-format msgid "A snapshot named %(name)s already exists" msgstr "名为 %(name)s 的快照已存在" @@ -3284,11 +3284,11 @@ msgid "Clone VM" msgstr "克隆虚拟机" #: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005 -#: vmbackups/jobs.py:211 +#: vmbackups/jobs.py:220 vmbackups/jobs.py:603 msgid "Copying disks" msgstr "正在复制磁盘" -#: instances/jobs.py:715 vmbackups/jobs.py:287 +#: instances/jobs.py:715 vmbackups/jobs.py:296 msgid "libvirt has no result of the copy" msgstr "libvirt 没有复制的结果" @@ -3299,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:293 +#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:302 msgid "The copy failed" msgstr "复制失败" @@ -3317,11 +3317,11 @@ msgid "" "this job: %(volumes)s" msgstr "克隆的一个卷正在创建中;请检查这些卷,然后处理此任务:%(volumes)s" -#: instances/jobs.py:801 vmbackups/jobs.py:330 +#: instances/jobs.py:801 vmbackups/jobs.py:339 msgid "The job stopped before the copy started" msgstr "任务在复制开始前停止" -#: instances/jobs.py:808 vmbackups/jobs.py:378 +#: instances/jobs.py:808 vmbackups/jobs.py:387 msgid "libvirt is still copying the disks" msgstr "libvirt 仍在复制磁盘" @@ -3354,12 +3354,12 @@ msgstr "镜像已存在。请检查卷或更改虚拟机名称" msgid "Each network card needs a network" msgstr "每个网卡都需要一个网络" -#: instances/jobs.py:868 vrtManager/instance.py:2860 +#: instances/jobs.py:868 vrtManager/backup.py:260 vrtManager/instance.py:2871 #, python-format msgid "This host has no network %(name)s" msgstr "此主机没有网络 %(name)s" -#: instances/jobs.py:870 vrtManager/instance.py:2862 +#: instances/jobs.py:870 vrtManager/backup.py:264 vrtManager/instance.py:2873 #, python-format msgid "This host has no network filter %(name)s" msgstr "此主机没有网络过滤器 %(name)s" @@ -3429,7 +3429,7 @@ msgstr "cloud-init 种子需要为磁盘使用目录类型的存储池" msgid "This host offers no firmware %(firmware)s" msgstr "此主机不提供固件 %(firmware)s" -#: instances/jobs.py:957 vrtManager/instance.py:3209 +#: instances/jobs.py:957 vrtManager/instance.py:3221 msgid "This host offers no TPM 2.0: install swtpm on it" msgstr "此主机不提供 TPM 2.0:请在主机上安装 swtpm" @@ -4341,6 +4341,7 @@ 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/restore.html:9 #: vmbackups/templates/vmbackups/targets.html:17 msgid "Backups" msgstr "备份" @@ -4683,7 +4684,7 @@ msgid "Add USB device" msgstr "添加 USB 设备" #: instances/templates/instances/host_devices_form.html:18 -#: vrtManager/instance.py:3113 +#: vrtManager/instance.py:3124 msgid "" "A VM with a saved state does not change its USB devices: start it, or start " "it without its saved state" @@ -6544,7 +6545,7 @@ msgstr "卷已成功更改。" msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "磁盘 %(dev)s 不是此虚拟机的存储卷" -#: instances/views.py:1603 vrtManager/instance.py:2426 +#: instances/views.py:1603 vrtManager/instance.py:2488 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "虚拟机有保存的状态;请先启动它或删除保存的状态" @@ -6598,7 +6599,7 @@ msgstr "快照未删除:%(err)s" msgid "Add at least one device to the boot order." msgstr "请至少向启动顺序中添加一个设备。" -#: instances/views.py:1916 vrtManager/instance.py:1198 +#: instances/views.py:1916 vrtManager/instance.py:1260 msgid "Invalid Device Type for boot order" msgstr "启动顺序的设备类型无效" @@ -9168,7 +9169,7 @@ msgid "" "encrypted anew." msgstr "新值会立即替换旧值;之前用口令加密的内容不会重新加密。" -#: vmbackups/forms.py:12 +#: vmbackups/forms.py:12 vmbackups/forms.py:36 msgid "Compute" msgstr "计算节点" @@ -9176,96 +9177,170 @@ msgstr "计算节点" msgid "A backup target with this name exists" msgstr "已存在同名的备份目标" -#: vmbackups/jobs.py:47 +#: vmbackups/forms.py:37 +msgid "Storage pool for the disks" +msgstr "磁盘的存储池" + +#: vmbackups/forms.py:38 +msgid "Connect the network" +msgstr "连接网络" + +#: vmbackups/forms.py:39 +msgid "" +"The restored guest keeps the VM's addresses and host name: connected beside " +"the VM, they clash." +msgstr "恢复的客户机保留虚拟机的地址和主机名:与原虚拟机同时联网会发生冲突。" + +#: vmbackups/forms.py:41 +msgid "Start after restore" +msgstr "恢复后启动" + +#: vmbackups/jobs.py:56 #, python-format msgid "Backup target %(target)s has no storage pool on %(compute)s" msgstr "备份目标 %(target)s 在 %(compute)s 上没有存储池" -#: vmbackups/jobs.py:57 +#: vmbackups/jobs.py:66 msgid "The VM must be running, paused or shut off to be backed up" msgstr "虚拟机必须处于运行、暂停或关闭状态才能备份" -#: vmbackups/jobs.py:61 +#: vmbackups/jobs.py:70 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:63 +#: vmbackups/jobs.py:72 msgid "A paused VM's file systems cannot be frozen" msgstr "无法冻结已暂停虚拟机的文件系统" -#: vmbackups/jobs.py:65 +#: vmbackups/jobs.py:74 msgid "The guest agent does not answer: the file systems cannot be frozen" msgstr "客户机代理没有响应:无法冻结文件系统" -#: vmbackups/jobs.py:115 +#: vmbackups/jobs.py:124 msgid "" "The VM's NVRAM file changed while it was backed up; back the VM up again" msgstr "虚拟机的 NVRAM 文件在备份期间发生了变化;请重新备份该虚拟机" -#: vmbackups/jobs.py:176 +#: vmbackups/jobs.py:185 msgid "Back up VM" msgstr "备份虚拟机" -#: vmbackups/jobs.py:227 vmbackups/jobs.py:294 +#: vmbackups/jobs.py:236 vmbackups/jobs.py:303 msgid "Writing the backup's files" msgstr "正在写入备份文件" -#: vmbackups/jobs.py:306 +#: vmbackups/jobs.py:315 msgid "The guest's file systems could not be thawed; trying again" msgstr "无法解冻客户机的文件系统;正在重试" -#: vmbackups/jobs.py:355 +#: vmbackups/jobs.py:364 #, 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:372 +#: vmbackups/jobs.py:381 #, 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:382 +#: vmbackups/jobs.py:391 #, 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:388 +#: vmbackups/jobs.py:397 #, 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:396 +#: vmbackups/jobs.py:405 msgid "The job stopped before the copy ended" msgstr "作业在复制结束前停止" -#: vmbackups/jobs.py:403 +#: vmbackups/jobs.py:412 #, python-format msgid "The backup's files could not be written: %(error)s" msgstr "无法写入备份文件:%(error)s" -#: vmbackups/jobs.py:421 +#: vmbackups/jobs.py:430 #, python-format msgid "No compute of backup target %(target)s reaches its storage pool" msgstr "备份目标 %(target)s 的计算节点都无法访问其存储池" -#: vmbackups/jobs.py:434 +#: vmbackups/jobs.py:443 msgid "Delete backup" msgstr "删除备份" -#: vmbackups/jobs.py:443 +#: vmbackups/jobs.py:452 msgid "This backup is being made; cancel its job to stop it" msgstr "此备份正在创建;要停止它,请取消其作业" +#: vmbackups/jobs.py:516 +#, python-format +msgid "The backup's file %(name)s is missing from the target" +msgstr "目标中缺少备份文件 %(name)s" + +#: vmbackups/jobs.py:519 vmbackups/jobs.py:521 +#, python-format +msgid "The backup's file %(name)s differs from the one written" +msgstr "备份文件 %(name)s 与写入的不同" + +#: vmbackups/jobs.py:531 vmbackups/templates/vmbackups/restore.html:7 +msgid "Restore backup" +msgstr "恢复备份" + +#: vmbackups/jobs.py:544 +msgid "Only a ready backup is restored" +msgstr "只能恢复就绪的备份" + +#: vmbackups/jobs.py:574 +#, python-format +msgid "A VM named %(name)s exists on %(compute)s" +msgstr "%(compute)s 上已存在名为 %(name)s 的虚拟机" + +#: vmbackups/jobs.py:582 +#, python-format +msgid "This host has no active directory storage pool %(pool)s" +msgstr "此主机没有名为 %(pool)s 的活动目录存储池" + +#: vmbackups/jobs.py:599 +#, python-format +msgid "The NVRAM file %(path)s exists already" +msgstr "NVRAM 文件 %(path)s 已存在" + +#: vmbackups/jobs.py:630 +#, python-format +msgid "The VM was restored; it did not start: %(error)s" +msgstr "虚拟机已恢复;但未能启动:%(error)s" + +#: vmbackups/jobs.py:652 +#, python-format +msgid "" +"A disk was being copied when the job stopped; check this volume, then resolve" +" this job: %(volumes)s" +msgstr "作业停止时正在复制磁盘;请检查此卷,然后解决此作业:%(volumes)s" + +#: vmbackups/jobs.py:657 +#, python-format +msgid "" +"Storage pool %(pool)s is not active; the restore's copies in it are removed " +"when it is" +msgstr "存储池 %(pool)s 未激活;其中恢复的副本将在其激活后删除" + +#: vmbackups/jobs.py:666 +msgid "The VM was not defined; its copies were removed" +msgstr "虚拟机未定义;其副本已删除" + #: vmbackups/templates/vmbackups/consistency.html:1 msgid "Shut off" msgstr "已关闭" @@ -9278,6 +9353,12 @@ msgstr "已冻结" msgid "Crash-consistent" msgstr "崩溃一致" +#: vmbackups/templates/vmbackups/delete_form.html:1 +#: vmbackups/templates/vmbackups/restore.html:9 +#: vmbackups/templates/vmbackups/restore.html:18 +msgid "Restore" +msgstr "恢复" + #: vmbackups/templates/vmbackups/delete_form.html:3 #, python-format msgid "" @@ -9344,6 +9425,13 @@ msgstr "没有符合筛选条件的备份。" msgid "No backup yet. Back a VM up from its Backups tab." msgstr "还没有备份。请在虚拟机的备份选项卡中备份虚拟机。" +#: vmbackups/templates/vmbackups/restore.html:12 +#, python-format +msgid "" +"The backup of %(vm)s taken %(time)s, in %(target)s, is restored as a new VM " +"with its own UUID and MAC addresses." +msgstr "%(vm)s 在 %(time)s 的备份(位于 %(target)s)将恢复为一台拥有自己 UUID 和 MAC 地址的新虚拟机。" + #: vmbackups/templates/vmbackups/target.html:11 #, python-format msgid "%(counter)s backup." @@ -9554,6 +9642,23 @@ msgid "" "written" msgstr "从备份目标读回的文件 %(name)s 与写入的不同" +#: vrtManager/backup.py:254 +#, python-format +msgid "" +"This host cannot run the VM's emulator %(emulator)s with machine type " +"%(machine)s: %(error)s" +msgstr "此主机无法以机器类型 %(machine)s 运行虚拟机的模拟器 %(emulator)s:%(error)s" + +#: vrtManager/backup.py:258 +#, python-format +msgid "This host has no firmware %(loader)s" +msgstr "此主机没有固件 %(loader)s" + +#: vrtManager/backup.py:262 +#, python-format +msgid "This host has no bridge %(name)s" +msgstr "此主机没有网桥 %(name)s" + #: vrtManager/connection.py:45 msgid "Connection closed (error)" msgstr "连接已关闭(错误)" @@ -9794,135 +9899,139 @@ msgid "" "with '.'" msgstr "快照名称为 1-64 个字母、数字、'.'、'_' 或 '-',且不能以 '.' 开头" -#: vrtManager/instance.py:1186 +#: vrtManager/instance.py:732 +msgid "A VM with a host's or an external TPM is not cloned; remove it first" +msgstr "带有主机 TPM 或外部 TPM 的虚拟机无法克隆;请先将其移除" + +#: vrtManager/instance.py:1248 msgid "" "A device other than a disk or NIC is in the boot order: change it in the XML " "editor" msgstr "启动顺序中有磁盘或网卡以外的设备:请在 XML 编辑器中修改" -#: vrtManager/instance.py:1201 +#: vrtManager/instance.py:1263 #, python-format msgid "Boot device %(dev)s is not in the definition" msgstr "启动设备 %(dev)s 不在定义中" -#: vrtManager/instance.py:1221 +#: vrtManager/instance.py:1283 #, python-format msgid "CD-ROM %(dev)s is not in the running definition" msgstr "CD-ROM %(dev)s 不在运行中的定义中" -#: vrtManager/instance.py:1222 +#: vrtManager/instance.py:1284 #, python-format msgid "CD-ROM %(dev)s is not in the persistent definition" msgstr "CD-ROM %(dev)s 不在持久定义中" -#: vrtManager/instance.py:1235 +#: vrtManager/instance.py:1297 #, python-format msgid "Media of %(dev)s changed in the running VM only: %(err)s" msgstr "%(dev)s 的介质仅在运行中的虚拟机中更改:%(err)s" -#: vrtManager/instance.py:1246 +#: vrtManager/instance.py:1308 #, python-format msgid "ISO image %(image)s was not found" msgstr "未找到 ISO 镜像 %(image)s" -#: vrtManager/instance.py:1248 +#: vrtManager/instance.py:1310 #, python-format msgid "ISO image %(image)s is in more than one storage pool" msgstr "ISO 镜像 %(image)s 位于多个存储池中" -#: vrtManager/instance.py:1343 +#: vrtManager/instance.py:1405 #, python-format msgid "Disk %(target_dev)s is not in the VM's definition" msgstr "磁盘 %(target_dev)s 不在虚拟机的定义中" -#: vrtManager/instance.py:1475 +#: vrtManager/instance.py:1537 msgid "Please shutdown the instance then try to enable vCPU hotplug" msgstr "请先关闭虚拟机,再启用 vCPU 热插拔" -#: vrtManager/instance.py:1678 +#: vrtManager/instance.py:1740 #, python-format msgid "" "The serial console is a %(type)s one, the browser opens only a pty one; " "change it in the XML editor" msgstr "串行控制台的类型是 %(type)s,浏览器只能打开 pty 类型的;请在 XML 编辑器中更改" -#: vrtManager/instance.py:1789 +#: vrtManager/instance.py:1851 msgid "The VM has no video card" msgstr "虚拟机没有显卡" -#: vrtManager/instance.py:1799 +#: vrtManager/instance.py:1861 #, python-format msgid "" "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set" " another maximum" msgstr "该虚拟机的 CPU 拓扑为 %(count)s 个 vCPU:要设置其他最大值,请在 XML 编辑器中修改拓扑" -#: vrtManager/instance.py:1825 +#: vrtManager/instance.py:1887 #, python-format msgid "The VM's next start has a maximum memory of %(max)s MiB" msgstr "虚拟机下次启动时的最大内存为 %(max)s MiB" -#: vrtManager/instance.py:1966 +#: vrtManager/instance.py:2028 msgid "" "The VM has external snapshots; internal snapshots cannot be mixed with them" msgstr "虚拟机有外部快照;内部快照不能与其混用" -#: vrtManager/instance.py:1998 +#: vrtManager/instance.py:2060 msgid "A snapshot with memory is not quiesced; it keeps the whole guest state" msgstr "含内存的快照不会静默文件系统;它保存整个客户机状态" -#: vrtManager/instance.py:2000 +#: vrtManager/instance.py:2062 msgid "Only a running VM's file systems can be frozen" msgstr "只有运行中的虚拟机的文件系统可以冻结" -#: vrtManager/instance.py:2002 +#: vrtManager/instance.py:2064 msgid "The QEMU guest agent is not connected; it freezes the file systems" msgstr "QEMU 客户机代理未连接;文件系统由它冻结" -#: vrtManager/instance.py:2005 +#: vrtManager/instance.py:2067 msgid "" "The VM has internal snapshots; external snapshots cannot be mixed with them" msgstr "虚拟机有内部快照;外部快照不能与其混用" -#: vrtManager/instance.py:2010 +#: vrtManager/instance.py:2072 msgid "Newer snapshots exist after the last revert; delete them first" msgstr "上次还原后存在更新的快照;请先删除它们" -#: vrtManager/instance.py:2013 +#: vrtManager/instance.py:2075 msgid "No snapshot is current; revert to a snapshot first" msgstr "没有当前快照;请先还原到某个快照" -#: vrtManager/instance.py:2019 +#: vrtManager/instance.py:2081 #, python-format msgid "Eject the media from %(dev)s first" msgstr "请先弹出 %(dev)s 中的介质" -#: vrtManager/instance.py:2021 +#: vrtManager/instance.py:2083 #, python-format msgid "Disk %(dev)s is not a file; external snapshots need file disks" msgstr "磁盘 %(dev)s 不是文件;外部快照需要文件磁盘" -#: vrtManager/instance.py:2029 +#: vrtManager/instance.py:2091 #, python-format msgid "" "The storage pools could not be refreshed, so their free space is unknown: " "%(err)s" msgstr "无法刷新存储池,其可用空间未知:%(err)s" -#: vrtManager/instance.py:2050 +#: vrtManager/instance.py:2112 msgid "Memory is saved only from a running VM" msgstr "只能保存运行中的虚拟机的内存" -#: vrtManager/instance.py:2052 +#: vrtManager/instance.py:2114 msgid "The VM has no disk to keep its memory next to" msgstr "虚拟机没有可存放其内存的磁盘" -#: vrtManager/instance.py:2056 +#: vrtManager/instance.py:2118 #, python-format msgid "%(disk)s is not in a storage pool; memory is saved only into one" msgstr "%(disk)s 不在存储池中;内存只能保存到存储池中" -#: vrtManager/instance.py:2087 +#: vrtManager/instance.py:2149 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the snapshot needs %(size).1f " @@ -9932,151 +10041,147 @@ msgstr "" "存储池 %(pool)s 可用 %(free).1f GiB;快照需要 %(size).1f GiB(其中虚拟机磁盘的 %(percent)g%%,至少 " "%(minimum)g GiB,若保存内存则另加内存)" -#: vrtManager/instance.py:2105 +#: vrtManager/instance.py:2167 msgid "" "This snapshot was taken by an older version on a UEFI VM and cannot be " "reverted; delete it instead" msgstr "此快照由旧版本在 UEFI 虚拟机上创建,无法还原;请将其删除" -#: vrtManager/instance.py:2135 +#: vrtManager/instance.py:2197 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is " "running." msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机正在运行。" -#: vrtManager/instance.py:2137 +#: vrtManager/instance.py:2199 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is shut " "off." msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机已关机。" -#: vrtManager/instance.py:2305 +#: vrtManager/instance.py:2367 msgid "A disk moves when its VM is defined and running, paused or shut off" msgstr "仅当虚拟机已定义且处于运行、暂停或关机状态时才能移动磁盘" -#: vrtManager/instance.py:2307 +#: vrtManager/instance.py:2369 msgid "" "A disk of a VM with snapshots, a saved state or a running block job does not " "move" msgstr "有快照、保存的状态或正在运行块任务的虚拟机的磁盘不能移动" -#: vrtManager/instance.py:2315 +#: vrtManager/instance.py:2377 #, python-format msgid "" "%(dev)s is not a disk file of the VM, the same in its running and next " "start's definition" msgstr "%(dev)s 不是该虚拟机在运行中的定义和下次启动定义中相同的磁盘文件" -#: vrtManager/instance.py:2320 +#: vrtManager/instance.py:2382 #, python-format msgid "%(dev)s does not move: only writable raw and qcow2 disks do" msgstr "%(dev)s 不能移动:只能移动可写的 raw 和 qcow2 磁盘" -#: vrtManager/instance.py:2327 +#: vrtManager/instance.py:2389 #, python-format msgid "%(dev)s does not move: no storage pool has %(path)s" msgstr "%(dev)s 不能移动:没有存储池包含 %(path)s" -#: vrtManager/instance.py:2329 +#: vrtManager/instance.py:2391 #, python-format msgid "%(dev)s does not move: it has a backing file" msgstr "%(dev)s 不能移动:它有后备文件" -#: vrtManager/instance.py:2332 +#: vrtManager/instance.py:2394 #, python-format msgid "%(pool_name)s is not an active pool of disk files of this host" msgstr "%(pool_name)s 不是此主机上活动的磁盘文件存储池" -#: vrtManager/instance.py:2335 +#: vrtManager/instance.py:2397 #, python-format msgid "%(dev)s is in pool %(pool_name)s already" msgstr "%(dev)s 已在存储池 %(pool_name)s 中" -#: vrtManager/instance.py:2339 +#: vrtManager/instance.py:2401 #, python-format msgid "Pool %(pool_name)s already has a file %(name)s" msgstr "存储池 %(pool_name)s 中已有文件 %(name)s" -#: vrtManager/instance.py:2363 +#: vrtManager/instance.py:2425 #, python-format msgid "The copy of %(dev)s ended before it was complete" msgstr "%(dev)s 的复制在完成前结束" -#: vrtManager/instance.py:2408 +#: vrtManager/instance.py:2470 #, python-format msgid "%(error)s; remove %(dest)s if it is there: %(cleanup_error)s" msgstr "%(error)s;如果 %(dest)s 存在请将其删除:%(cleanup_error)s" -#: vrtManager/instance.py:2410 +#: vrtManager/instance.py:2472 #, python-format msgid "%(error)s; the VM may use %(dest)s now: check its disk %(dev)s" msgstr "%(error)s;虚拟机现在可能在使用 %(dest)s:请检查其磁盘 %(dev)s" -#: vrtManager/instance.py:2417 +#: vrtManager/instance.py:2479 #, python-format msgid "The VM has no internal snapshot named %(name)s" msgstr "虚拟机没有名为 %(name)s 的内部快照" -#: vrtManager/instance.py:2428 +#: vrtManager/instance.py:2490 msgid "A snapshot job is still running on this VM; try again when it ends" msgstr "此虚拟机上仍有快照任务在运行;请在其结束后重试" -#: vrtManager/instance.py:2438 +#: vrtManager/instance.py:2500 msgid "Shut the VM down to revert to an internal snapshot" msgstr "请关闭虚拟机后再还原到内部快照" -#: vrtManager/instance.py:2525 -msgid "A VM with a host's or an external TPM is not cloned; remove it first" -msgstr "带有主机 TPM 或外部 TPM 的虚拟机无法克隆;请先将其移除" - -#: vrtManager/instance.py:2556 +#: vrtManager/instance.py:2567 msgid "Cannot clone a VM whose NVRAM is not a file" msgstr "NVRAM 不是文件的虚拟机无法克隆" -#: vrtManager/instance.py:2627 +#: vrtManager/instance.py:2638 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(path)s" msgstr "克隆失败(%(err)s);请手动删除这些副本:%(path)s" -#: vrtManager/instance.py:2638 +#: vrtManager/instance.py:2649 msgid "Shut the VM down before cloning it" msgstr "请先关闭虚拟机再克隆" -#: vrtManager/instance.py:2665 +#: vrtManager/instance.py:2676 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(leftovers)s" msgstr "克隆失败(%(err)s);请手动删除这些副本:%(leftovers)s" -#: vrtManager/instance.py:2676 +#: vrtManager/instance.py:2687 msgid "Live clone needs libvirt 11.10 or later; shut the VM down to clone it" msgstr "在线克隆需要 libvirt 11.10 或更高版本;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2679 +#: vrtManager/instance.py:2690 msgid "A VM with a TPM is cloned only shut down" msgstr "带 TPM 的虚拟机只能在关机时克隆" -#: vrtManager/instance.py:2682 +#: vrtManager/instance.py:2693 #, python-format msgid "Disk %(dev)s is not a local file; shut the VM down to clone it" msgstr "磁盘 %(dev)s 不是本地文件;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2684 +#: vrtManager/instance.py:2695 #, python-format msgid "Disk %(dev)s is shareable; shut the VM down to clone it" msgstr "磁盘 %(dev)s 是可共享的;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2689 +#: vrtManager/instance.py:2700 #, python-format msgid "Disk %(dev)s changes at the next start; shut the VM down to clone it" msgstr "磁盘 %(dev)s 在下次启动时会改变;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2691 +#: vrtManager/instance.py:2702 msgid "Another job is running on the VM; clone it when that ends" msgstr "虚拟机上有另一个任务正在运行;请在其结束后再克隆" -#: vrtManager/instance.py:2717 +#: vrtManager/instance.py:2728 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the clone needs %(size).1f GiB" @@ -10085,111 +10190,111 @@ msgstr "" "存储池 %(pool)s 可用 %(free).1f GiB;克隆需要 %(size).1f GiB(复制的磁盘,再加其 %(percent)g%%,至少" " %(minimum)g GiB)" -#: vrtManager/instance.py:2734 +#: vrtManager/instance.py:2745 #, python-format msgid "Volume %(name)s already exists in storage pool %(pool)s" msgstr "卷 %(name)s 已存在于存储池 %(pool)s 中" -#: vrtManager/instance.py:2899 +#: vrtManager/instance.py:2910 msgid "A network interface that is a host device is removed in the XML editor" msgstr "作为主机设备的网络接口需在 XML 编辑器中删除" -#: vrtManager/instance.py:2915 +#: vrtManager/instance.py:2926 #, python-format msgid "No network interface with MAC %(old_mac)s" msgstr "没有 MAC 为 %(old_mac)s 的网络接口" -#: vrtManager/instance.py:2918 +#: vrtManager/instance.py:2929 msgid "A network interface that is a host device is changed in the XML editor" msgstr "作为主机设备的网络接口需在 XML 编辑器中修改" -#: vrtManager/instance.py:3012 +#: vrtManager/instance.py:3023 msgid "" "A VM changes its PCI devices while it runs, or is shut off without a saved " "state" msgstr "虚拟机只能在运行时或无保存的状态的关机时更改其 PCI 设备" -#: vrtManager/instance.py:3033 +#: vrtManager/instance.py:3044 #, python-format msgid "%(err)s; whether the VM has %(device)s now is not known" msgstr "%(err)s;虚拟机现在是否有 %(device)s 未知" -#: vrtManager/instance.py:3035 +#: vrtManager/instance.py:3046 #, python-format msgid "%(err)s; %(device)s: the VM is not running, its next start has it" msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时有它" -#: vrtManager/instance.py:3036 +#: vrtManager/instance.py:3047 #, python-format msgid "" "%(err)s; %(device)s: the VM is not running, its next start does not have it" msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时没有它" -#: vrtManager/instance.py:3037 +#: vrtManager/instance.py:3048 #, python-format msgid "%(err)s; %(device)s: the running VM has it, its next start has it" msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时有它" -#: vrtManager/instance.py:3038 +#: vrtManager/instance.py:3049 #, python-format msgid "" "%(err)s; %(device)s: the running VM has it, its next start does not have it" msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时没有它" -#: vrtManager/instance.py:3039 +#: vrtManager/instance.py:3050 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start has it" msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时有它" -#: vrtManager/instance.py:3041 +#: vrtManager/instance.py:3052 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start does not" " have it" msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时没有它" -#: vrtManager/instance.py:3075 +#: vrtManager/instance.py:3086 #, python-format msgid "The VM has no PCI device %(address)s" msgstr "虚拟机没有 PCI 设备 %(address)s" -#: vrtManager/instance.py:3096 +#: vrtManager/instance.py:3107 msgid "The VM has no USB controller" msgstr "虚拟机没有 USB 控制器" -#: vrtManager/instance.py:3130 +#: vrtManager/instance.py:3141 msgid "The VM has no such USB device" msgstr "虚拟机没有此 USB 设备" -#: vrtManager/instance.py:3144 +#: vrtManager/instance.py:3155 #, python-format msgid "The VM has no network interface %(mac)s" msgstr "虚拟机没有网络接口 %(mac)s" -#: vrtManager/instance.py:3175 +#: vrtManager/instance.py:3187 msgid "The VM has its own RNG device: change it in the XML editor" msgstr "虚拟机有自己的 RNG 设备:请在 XML 编辑器中修改" -#: vrtManager/instance.py:3202 +#: vrtManager/instance.py:3214 msgid "The VM has its own TPM: change it in the XML editor" msgstr "虚拟机有自己的 TPM:请在 XML 编辑器中修改" -#: vrtManager/instance.py:3221 +#: vrtManager/instance.py:3233 #, python-format msgid "Unknown crash action %(action)s" msgstr "未知的崩溃操作 %(action)s" -#: vrtManager/instance.py:3248 +#: vrtManager/instance.py:3260 #, python-format msgid "Network interface %(mac)s is not in the definition" msgstr "网络接口 %(mac)s 不在定义中" -#: vrtManager/instance.py:3339 +#: vrtManager/instance.py:3351 msgid "The guest agent did not answer in time; nothing was changed" msgstr "客户机代理未及时响应;未做任何更改" -#: vrtManager/instance.py:3342 +#: vrtManager/instance.py:3354 msgid "The VM runs Windows: its guest agent sets no root password or SSH key" msgstr "该虚拟机运行 Windows:其客户机代理不能设置 root 密码或 SSH 密钥" diff --git a/vmbackups/api.py b/vmbackups/api.py index 6eafb943..e82102f2 100644 --- a/vmbackups/api.py +++ b/vmbackups/api.py @@ -1,6 +1,7 @@ from django.urls import reverse from drf_spectacular.utils import extend_schema from rest_framework import mixins, status, viewsets +from rest_framework.decorators import action from rest_framework.response import Response from admin.permissions import IsSuperUser @@ -9,7 +10,7 @@ from operations.api.serializers import OperationSerializer from webvirtcloud.serializers import ErrorSerializer from .models import Backup -from .serializers import BackupSerializer, CreateBackupSerializer, SubmissionSerializer +from .serializers import BackupSerializer, CreateBackupSerializer, RestoreBackupSerializer, SubmissionSerializer def _accepted(request, op): @@ -42,3 +43,14 @@ class BackupViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.G 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)) + + @extend_schema(request=RestoreBackupSerializer, responses={202: OperationSerializer, 400: dict, 409: ErrorSerializer}) + @action(detail=True, methods=["post"]) + def restore(self, request, uuid=None): + backup = self.get_object() + serializer = RestoreBackupSerializer(data=request.data) + serializer.is_valid(raise_exception=True) + data = dict(serializer.validated_data) + key = data.pop("submission_key") + raw = {**data, "backup": str(backup.uuid), "compute": data["compute"].pk} + return _accepted(request, jobs.submit("backup.restore", request.user, raw, key)) diff --git a/vmbackups/forms.py b/vmbackups/forms.py index 87ffe7d3..9444ac2b 100644 --- a/vmbackups/forms.py +++ b/vmbackups/forms.py @@ -27,3 +27,20 @@ class TargetForm(TargetPoolForm): if BackupTarget.objects.filter(name=name).exists(): raise forms.ValidationError(_("A backup target with this name exists")) return name + + +class RestoreForm(forms.Form): + """A backup restored as a new VM, on a compute that has its target's pool.""" + + name = forms.CharField(label=_("Name"), max_length=64) + compute = forms.ModelChoiceField(Compute.objects.none(), label=_("Compute")) + pool = forms.CharField(label=_("Storage pool for the disks"), max_length=128, initial="default") + connect = forms.BooleanField(label=_("Connect the network"), required=False, + help_text=_("The restored guest keeps the VM's addresses and host name: " + "connected beside the VM, they clash.")) + start = forms.BooleanField(label=_("Start after restore"), required=False) + + def __init__(self, *args, backup, **kwargs): + super().__init__(*args, **kwargs) + self.fields["compute"].queryset = Compute.objects.filter(backuptargetpool__target=backup.target).order_by("name") + self.fields["name"].initial = f"{backup.vm_name}-restored" diff --git a/vmbackups/jobs.py b/vmbackups/jobs.py index 407b6b22..f197131a 100644 --- a/vmbackups/jobs.py +++ b/vmbackups/jobs.py @@ -2,25 +2,34 @@ import hashlib import json +import os +import re import time from uuid import UUID, uuid4 from django.core.exceptions import PermissionDenied +from django.urls import reverse from django.db import transaction from django.utils import timezone from django.utils.translation import gettext_noop as _ -from libvirt import VIR_DOMAIN_PAUSED, VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF, VIR_ERR_NO_DOMAIN, libvirtError +from lxml import etree +from libvirt import VIR_DOMAIN_PAUSED, VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF, VIR_ERR_NO_DOMAIN, VIR_ERR_NO_STORAGE_VOL, libvirtError from appsettings.settings import app_settings -from instances.jobs import PAUSED_FROZEN, THAW_FAILED, _instance, _log, _snapshot_free_space +from computes.models import Compute +from instances.jobs import PAUSED_FROZEN, THAW_FAILED, _instance, _log, _snapshot_free_space, record_vm, vm_claims +from instances.utils import get_random_mac_address from instances.models import Instance from operations import claims from operations.jobs import Cancelled, Kind, Outcome, Plan, register 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.backup import (backup_file_names, check_restore_host, check_target_space, get_file, put_file, remove_files, + restore_definition, target_pool, volume_exists, wvmBackup) +from vrtManager.connection import NVRAM_DIR, wvmConnect +from vrtManager.instance import wvmInstance +from vrtManager.storage import wvmStorage from vrtManager.instance import LIVE_CLONE_MIN_LIBVIRT from .models import Backup, BackupFile, BackupTarget @@ -478,3 +487,188 @@ class DeleteBackup(Kind): 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 + + +def _connect(compute): + return wvmConnect(compute.hostname, compute.login, compute.password, compute.type) + + +def _check_name(name): + """A new VM's name, as the clone's.""" + if Instance.objects.filter(name=name).exists(): + raise util.OperationError(_("Instance '%(clone_name)s' already exists!"), clone_name=name) + if len(name) > 64: + raise util.OperationError(_("Instance name '%(clone_name)s' is longer than 64 characters"), clone_name=name) + if not re.fullmatch(r"[a-zA-Z0-9-]+", name): + raise util.OperationError(_("Instance name '%(clone_name)s' contains invalid characters!"), clone_name=name) + + +def _check_files(conn, pool, backup): + """Each file of the backup is in the target: disks at their size, the + small files with their SHA-256.""" + pool.refresh(0) + for f in backup.files.all(): + try: + vol = pool.storageVolLookupByName(f.volume) + except libvirtError as err: + if err.get_error_code() != VIR_ERR_NO_STORAGE_VOL: + raise + raise util.OperationError(_("The backup's file %(name)s is missing from the target"), name=f.volume) from err + if f.role == BackupFile.DISK: + if vol.info()[1] != f.capacity: + raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f.volume) + elif hashlib.sha256(get_file(conn, pool, f.volume)).hexdigest() != f.sha256: + raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f.volume) + + +@register +class RestoreBackup(Kind): + """A ready backup made a new VM on a compute that has the target's pool: + its disks copied from the target into one of the compute's pools, its + NVRAM file into libvirt's directory, then the VM defined, last.""" + + name = "backup.restore" + label = _("Restore backup") + progress_bytes = True + + def normalize(self, raw): + return {"backup": str(UUID(str(raw["backup"]))), "compute": int(raw["compute"]), + "pool": str(raw.get("pool", "")).strip(), "name": str(raw.get("name", "")).strip(), + "connect": str(raw.get("connect", "")).lower() in ("1", "true", "on"), + "start": str(raw.get("start", "")).lower() in ("1", "true", "on")} + + def plan(self, user, params): + _superuser(user) + backup = _backup(params) + if backup.state != Backup.READY: + raise util.OperationError(_("Only a ready backup is restored")) + compute = Compute.objects.get(pk=params["compute"]) + _target_row(backup.target, compute) + compute.refuse_new_vms() + _check_name(params["name"]) + volumes = {f.dev: f"{params['name']}-{f.dev}.{'qcow2' if f.format == 'qcow2' else 'raw'}" + for f in backup.files.filter(role=BackupFile.DISK)} + keys = vm_claims(compute, params["name"]) + for name in volumes.values(): # no other job makes a volume of these names meanwhile + keys[claims.volume_key(compute.pk, params["pool"], name)] = Claim.EXCLUSIVE + keys[claims.backup_key(backup.uuid)] = Claim.SHARED + keys[claims.backup_target_key(backup.target_id)] = Claim.EXCLUSIVE + return Plan( + claims=keys, + resource=claims.backup_key(backup.uuid), + label=f"{compute.name}/{params['name']}", + intent={"compute": compute.pk, "uuid": str(uuid4()), "name": params["name"], "from": backup.vm_name, + "volumes": volumes, "pool": params["pool"], + "time": timezone.localtime(backup.created_at).strftime("%Y-%m-%d %H:%M")}, + ) + + def run(self, op, ctx): + _superuser(op.user) + p = op.params + backup = _backup(p) + compute = Compute.objects.get(pk=p["compute"]) + compute.refuse_new_vms() + _check_name(p["name"]) + conn = _connect(compute) + if p["name"] in conn.get_instances(): + raise util.OperationError(_("A VM named %(name)s exists on %(compute)s"), name=p["name"], compute=compute.name) + row = _target_row(backup.target, compute) + tpool = target_pool(conn, row.pool, row.pool_uuid) + _check_files(conn, tpool, backup) + definition = get_file(conn, tpool, backup.files.get(role=BackupFile.DOMAIN).volume).decode() + check_restore_host(conn, definition) + pools = conn.file_pools() + if p["pool"] not in pools: + raise util.OperationError(_("This host has no active directory storage pool %(pool)s"), pool=p["pool"]) + dest = pools[p["pool"]][0] + disks = list(backup.files.filter(role=BackupFile.DISK).order_by("dev")) + check_target_space(dest, [{"capacity": d.capacity} for d in disks], **_free_space()) + volumes = op.intent["volumes"] + for name in volumes.values(): + wvmInstance._refuse_taken(dest, name) + nvram_file = backup.files.filter(role=BackupFile.NVRAM).first() + tree = etree.fromstring(definition) + old_nvram = tree.xpath("string(os/nvram/source/@file)") or (tree.findtext("os/nvram") or "").strip() + # the VM's own file in libvirt's directory; libvirt makes it from the template when none was kept + nvram = os.path.join(NVRAM_DIR, p["name"] + "_VARS" + os.path.splitext(old_nvram)[1]) if old_nvram else None + macs = [get_random_mac_address() for _nic in tree.findall("devices/interface")] + if nvram: + # a file of that name may be a removed VM's kept one, or another VM's: never taken, never removed + with conn._nvram_pool() as nvram_pool: + if volume_exists(nvram_pool, os.path.basename(nvram)): + raise util.OperationError(_("The NVRAM file %(path)s exists already"), path=nvram) + + # what the VM is made of, before anything is made: recovery finds and removes it by these + ctx.record_intent(nvram=nvram, macs=macs) + ctx.set_phase(_("Copying disks")) + storage = wvmStorage(compute.hostname, compute.login, compute.password, compute.type, p["pool"]) + paths = {} + for disk in disks: + ctx.record_intent(copying=disk.dev) + paths[disk.dev] = storage.clone_volume(tpool.storageVolLookupByName(disk.volume), volumes[disk.dev], + vol_fmt=disk.format, disk_owner_uid=_owner()[0], + disk_owner_gid=_owner()[1]) + ctx.record_intent(copied=[*op.intent.get("copied", []), disk.dev], copying=None) + if nvram and nvram_file: + data = get_file(conn, tpool, nvram_file.volume) + with conn._nvram_pool() as nvram_pool: + # QEMU's, as the clone's copy: qemu may run without libvirt changing a file's owner + conn.upload_volume(nvram_pool, os.path.basename(nvram), data, owner=_owner(), mode="0600") + + compute.refuse_new_vms() # again: the host may have gone in maintenance while the disks were copied + xml = restore_definition(definition, name=p["name"], uuid=op.intent["uuid"], macs=macs, + disks={d.dev: (paths[d.dev], d.format) for d in disks}, nvram=nvram, + connect=p["connect"]) + conn.wvm.defineXML(xml) + record_vm(op, owner=True) + result = {"open": _vm_page(op)} + if p["start"]: + try: + compute.refuse_start() + conn.wvm.lookupByUUIDString(op.intent["uuid"]).create() + except libvirtError as err: + result["warning"] = say(_("The VM was restored; it did not start: %(error)s"), error=err) + return result + + def progress(self, op): + disks = Backup.objects.filter(uuid=op.params["backup"]).values_list("files__dev", "files__capacity", "files__role") + copied = set(op.intent.get("copied", [])) + sizes = {dev: capacity for dev, capacity, role in disks if role == BackupFile.DISK} + return sum(c for dev, c in sizes.items() if dev in copied), sum(sizes.values()) + + def reconcile(self, op): + compute = Compute.objects.get(pk=op.intent["compute"]) + conn = _connect(compute) + try: + conn.wvm.lookupByUUIDString(op.intent["uuid"]) + except libvirtError as err: + if err.get_error_code() != VIR_ERR_NO_DOMAIN: + raise # unreachable: recovery waits and retries + else: # defined last: the restore is done + record_vm(op, owner=True) + return Outcome(Operation.SUCCEEDED, result={"open": _vm_page(op)}) + if op.intent.get("copying"): # libvirt's answer to that copy is unknown + return Outcome(Operation.UNCERTAIN, error=say(_( + "A disk was being copied when the job stopped; check this volume, then resolve this job: %(volumes)s"), + volumes=op.intent["volumes"][op.intent["copying"]])) + if copied := [op.intent["volumes"][dev] for dev in op.intent.get("copied", [])]: + pools = conn.file_pools() + if op.intent["pool"] not in pools: # recovery waits: the copies are removed once it runs + raise util.OperationError(_("Storage pool %(pool)s is not active; the restore's copies in it are " + "removed when it is"), pool=op.intent["pool"]) + pool = pools[op.intent["pool"]][0] + pool.refresh(0) + remove_files(pool, copied) + if nvram := op.intent.get("nvram"): + with conn._nvram_pool() as nvram_pool: + remove_files(nvram_pool, [os.path.basename(nvram)]) + ended = Operation.CANCELLED if op.cancel_requested else Operation.FAILED + return Outcome(ended, error=say(_("The VM was not defined; its copies were removed"))) + + def log_entry(self, op, state): + return _log(op, state, f"restored from the backup of {op.intent['from']} taken {op.intent['time']}") + + +def _vm_page(op): + vm = Instance.objects.get(compute_id=op.intent["compute"], uuid=op.intent["uuid"]) + return reverse("instances:instance", args=[vm.pk]) diff --git a/vmbackups/serializers.py b/vmbackups/serializers.py index b56e03b7..aca57718 100644 --- a/vmbackups/serializers.py +++ b/vmbackups/serializers.py @@ -1,5 +1,6 @@ from rest_framework import serializers +from computes.models import Compute from instances.models import Instance from .models import Backup, BackupFile, BackupTarget @@ -31,3 +32,12 @@ class CreateBackupSerializer(serializers.Serializer): class SubmissionSerializer(serializers.Serializer): submission_key = serializers.CharField(write_only=True) + + +class RestoreBackupSerializer(serializers.Serializer): + compute = serializers.PrimaryKeyRelatedField(queryset=Compute.objects.all()) + pool = serializers.CharField(default="default") + name = serializers.CharField(max_length=64) + connect = serializers.BooleanField(default=False) + start = serializers.BooleanField(default=False) + submission_key = serializers.CharField(write_only=True) diff --git a/vmbackups/templates/vmbackups/delete_form.html b/vmbackups/templates/vmbackups/delete_form.html index fe2e1a3a..cf9c6370 100644 --- a/vmbackups/templates/vmbackups/delete_form.html +++ b/vmbackups/templates/vmbackups/delete_form.html @@ -1,3 +1,3 @@ -{% load i18n %}{% load operations %}{% load bootstrap_icons %}{% if backup.state != "creating" %}
{% csrf_token %}{% submission_key %} +{% load i18n %}{% load operations %}{% load bootstrap_icons %}{% if backup.state == "ready" %}{% trans "Restore" %}{% endif %}{% if backup.state != "creating" %}{% csrf_token %}{% submission_key %}
{% endif %} diff --git a/vmbackups/templates/vmbackups/restore.html b/vmbackups/templates/vmbackups/restore.html new file mode 100644 index 00000000..238c8c03 --- /dev/null +++ b/vmbackups/templates/vmbackups/restore.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% load i18n %} +{% load bootstrap_icons %} +{% load django_bootstrap5 %} +{% load operations %} + +{% block title %}{% trans "Restore backup" %}{% endblock %} + +{% block page_heading %}{% trans "Backups" %} / {% trans "Restore" %}{% endblock page_heading %} + +{% block content %} +

{% 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 %}

+
+
+
+ {% csrf_token %}{% submission_key %} + {% bootstrap_form form %} + +
+
+
+{% endblock %} diff --git a/vmbackups/tests/test_restore.py b/vmbackups/tests/test_restore.py new file mode 100644 index 00000000..f8ae1b71 --- /dev/null +++ b/vmbackups/tests/test_restore.py @@ -0,0 +1,277 @@ +"""backup.restore: a ready backup made a new VM, its values recorded before +anything is made, checked again before it is defined, recovered by UUID.""" + +import contextlib +import hashlib +from types import SimpleNamespace +from unittest.mock import MagicMock, patch +from uuid import uuid4 + +import libvirt +from django.contrib.auth import get_user_model +from django.test import TransactionTestCase +from django.urls import reverse +from django.utils import timezone + +from accounts.models import UserInstance +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 RestoreBackup, _owner +from vmbackups.models import Backup, BackupFile, BackupTarget, BackupTargetPool +from vrtManager.util import OperationError + +GIB = 1024**3 +WORKER = "wvc-test:1:a" +DEFINITION = ( + "vm141414141-0000-4000-8000-000000000001" + "hvm/var/lib/libvirt/qemu/nvram/vm1_VARS.fd" + "/usr/libexec/qemu-kvm" + "" + "" + "" +).encode() + + +def error(code): + err = libvirt.libvirtError("x") + err.err = (code,) + return err + + +class RestoreTests(TransactionTestCase): + def setUp(self): + get_settings() + self.admin = get_user_model().objects.create_superuser("rs_admin", "a@example.com", "pw") + self.compute = Compute.objects.create(name="h1", hostname="192.0.2.41", 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="u") + self.backup = Backup.objects.create(target=self.target, vm_uuid="41414141-0000-4000-8000-000000000001", + vm_name="vm1", compute_name="h1", state=Backup.READY) + prefix = self.backup.prefix + self.files = {f"{prefix}-domain.xml": DEFINITION, f"{prefix}-nvram.fd": b"vars"} + BackupFile.objects.create(backup=self.backup, role=BackupFile.DISK, dev="vda", volume=f"{prefix}-vda.qcow2", + format="qcow2", capacity=GIB) + for role, name in ((BackupFile.DOMAIN, "domain.xml"), (BackupFile.NVRAM, "nvram.fd")): + data = self.files[f"{prefix}-{name}"] + BackupFile.objects.create(backup=self.backup, role=role, volume=f"{prefix}-{name}", size=len(data), + sha256=hashlib.sha256(data).hexdigest()) + + self.conn = MagicMock() + self.conn.get_instances.return_value = ["vm1"] + self.dest = MagicMock() + self.dest.info.return_value = [2, 100 * GIB, 0, 100 * GIB] + self.dest.storageVolLookupByName.side_effect = error(libvirt.VIR_ERR_NO_STORAGE_VOL) + self.conn.file_pools.return_value = {"default": (self.dest, "/dest")} + self.conn.wvm.lookupByUUIDString.side_effect = error(libvirt.VIR_ERR_NO_DOMAIN) + self.nvram_pool = MagicMock() + self.nvram_pool.storageVolLookupByName.side_effect = error(libvirt.VIR_ERR_NO_STORAGE_VOL) + self.conn._nvram_pool.side_effect = lambda: contextlib.nullcontext(self.nvram_pool) + self.tpool = MagicMock() + self.tpool.storageVolLookupByName.return_value.info.return_value = [0, GIB, GIB] + self.storage = MagicMock() + self.storage.clone_volume.side_effect = lambda vol, name, **kw: f"/dest/{name}" + self.removed = [] + for name, value in ( + ("vmbackups.jobs.wvmConnect", MagicMock(return_value=self.conn)), + ("vmbackups.jobs.target_pool", MagicMock(return_value=self.tpool)), + ("vmbackups.jobs.get_file", MagicMock(side_effect=lambda conn, pool, name: self.files[name])), + ("vmbackups.jobs.check_restore_host", MagicMock()), + ("vmbackups.jobs.wvmStorage", MagicMock(return_value=self.storage)), + ("vmbackups.jobs.remove_files", MagicMock(side_effect=lambda pool, names: self.removed.extend(names))), + ): + patcher = patch(name, value) + patcher.start() + self.addCleanup(patcher.stop) + + def submit(self, **fields): + raw = {"backup": str(self.backup.uuid), "compute": self.compute.pk, "pool": "default", "name": "vm1-restored", + **fields} + op = jobs.submit("backup.restore", self.admin, raw, 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 RestoreBackup().run(op, Context(op, SimpleNamespace(identity=WORKER))) + + def defined(self): + from lxml import etree + + return etree.fromstring(self.conn.wvm.defineXML.call_args.args[0]) + + def test_the_restored_vm_is_the_restorers(self): + op = self.submit() + result = self.run_job(op) + vm = Instance.objects.get(uuid=op.intent["uuid"]) + self.assertEqual((vm.name, vm.compute), ("vm1-restored", self.compute)) + self.assertTrue(UserInstance.objects.filter(instance=vm, user=self.admin).exists()) + self.assertEqual(result, {"open": reverse("instances:instance", args=[vm.pk])}) + tree = self.defined() + self.assertEqual(tree.findtext("uuid"), op.intent["uuid"]) + self.assertEqual(tree.xpath("devices/disk/source/@file"), ["/dest/vm1-restored-vda.qcow2"]) + self.assertEqual(tree.xpath("devices/interface/mac/@address"), op.intent["macs"]) + self.assertEqual(tree.xpath("devices/interface/link/@state"), ["down"]) + self.assertEqual(tree.findtext("os/nvram"), "/var/lib/libvirt/qemu/nvram/vm1-restored_VARS.fd") + self.storage.clone_volume.assert_called_once() + self.conn.upload_volume.assert_called_once_with(self.nvram_pool, "vm1-restored_VARS.fd", b"vars", owner=_owner(), + mode="0600") + self.conn.wvm.lookupByUUIDString.assert_not_called() # not started + + def test_start_after_restore(self): + self.conn.wvm.lookupByUUIDString.side_effect = None + op = self.submit(start=True, connect=True) + self.run_job(op) + self.conn.wvm.lookupByUUIDString.return_value.create.assert_called_once_with() + self.assertEqual(self.defined().xpath("devices/interface/link"), []) + + def test_a_name_used_on_the_host_is_refused_before_copying(self): + op = self.submit() + self.conn.get_instances.return_value = ["vm1", "vm1-restored"] # made with virsh, unknown to the panel + with self.assertRaisesMessage(OperationError, "A VM named vm1-restored exists on h1"): + self.run_job(op) + self.storage.clone_volume.assert_not_called() + + def test_a_name_the_panel_knows_is_refused(self): + Instance.objects.create(compute=self.compute, name="vm1-restored", uuid="41414141-0000-4000-8000-000000000009") + with self.assertRaisesMessage(OperationError, "already exists"): + self.submit() + + def test_a_missing_network_is_refused(self): + op = self.submit() + with patch("vmbackups.jobs.check_restore_host", + side_effect=OperationError("This host has no network %(name)s", name="default")): + with self.assertRaisesMessage(OperationError, "no network default"): + self.run_job(op) + self.storage.clone_volume.assert_not_called() + + def test_missing_files_are_refused(self): + op = self.submit() + self.tpool.storageVolLookupByName.side_effect = error(libvirt.VIR_ERR_NO_STORAGE_VOL) + with self.assertRaisesMessage(OperationError, "is missing from the target"): + self.run_job(op) + self.storage.clone_volume.assert_not_called() + + def test_a_changed_small_file_is_refused(self): + op = self.submit() + self.files[f"{self.backup.prefix}-domain.xml"] = b"" + with self.assertRaisesMessage(OperationError, "differs from the one written"): + self.run_job(op) + + def test_a_taken_volume_name_is_refused(self): + op = self.submit() + self.dest.storageVolLookupByName.side_effect = None + with self.assertRaisesMessage(OperationError, "vm1-restored-vda.qcow2 already exists"): + self.run_job(op) + + def test_an_existing_nvram_file_is_refused_and_never_removed(self): + # a file of that name may be a removed VM's kept one, or another VM's + self.nvram_pool.storageVolLookupByName.side_effect = None + op = self.submit() + with self.assertRaisesMessage(OperationError, "vm1-restored_VARS.fd"): + self.run_job(op) + op.refresh_from_db() + self.assertNotIn("nvram", op.intent) + self.storage.clone_volume.assert_not_called() + + def test_recovery_waits_for_an_inactive_destination_pool(self): + self.conn.upload_volume.side_effect = RuntimeError("worker gone") # after the disk was copied + op = self.submit() + with self.assertRaises(RuntimeError): + self.run_job(op) + op.refresh_from_db() + self.conn.file_pools.return_value = {} # the destination pool stopped + with self.assertRaisesMessage(OperationError, "default"): + RestoreBackup().reconcile(op) + self.assertEqual(self.removed, []) + + def test_the_copies_names_are_claimed(self): + from operations.models import Claim + + op = self.submit() + self.assertEqual(op.intent["volumes"], {"vda": "vm1-restored-vda.qcow2"}) + self.assertTrue(Claim.objects.filter(operation=op, resource=f"volume:{self.compute.pk}:default/vm1-restored-vda.qcow2", + mode=Claim.EXCLUSIVE).exists()) + + def test_a_copy_in_flight_is_not_removed(self): + # its name may have been taken meanwhile by another volume: the job is left to the administrator + self.storage.clone_volume.side_effect = RuntimeError("worker gone") + op = self.submit() + with self.assertRaises(RuntimeError): + self.run_job(op) + op.refresh_from_db() + outcome = RestoreBackup().reconcile(op) + self.assertEqual(outcome.state, Operation.UNCERTAIN) + self.assertIn("vm1-restored-vda.qcow2", outcome.error[0]["values"]["volumes"]) + self.assertEqual(self.removed, []) + + def test_the_nvram_file_is_qemus(self): + self.run_job(self.submit()) + self.assertEqual(self.conn.upload_volume.call_args.kwargs, {"owner": _owner(), "mode": "0600"}) + + def test_maintenance_is_checked_again_before_define(self): + def copy(vol, name, **kw): + Compute.objects.filter(pk=self.compute.pk).update(maintenance_since=timezone.now()) + return f"/dest/{name}" + + self.storage.clone_volume.side_effect = copy + op = self.submit() + with self.assertRaisesMessage(OperationError, "maintenance"): + self.run_job(op) + self.conn.wvm.defineXML.assert_not_called() + op.refresh_from_db() + outcome = RestoreBackup().reconcile(op) + self.assertEqual(outcome.state, Operation.FAILED) + self.assertEqual(self.removed, ["vm1-restored-vda.qcow2", "vm1-restored_VARS.fd"]) + + def test_a_host_in_maintenance_is_refused(self): + Compute.objects.filter(pk=self.compute.pk).update(maintenance_since=timezone.now()) + with self.assertRaisesMessage(OperationError, "maintenance"): + self.submit() + + def test_recovery_records_a_defined_vm_instead_of_defining_again(self): + op = self.submit() + with patch("vmbackups.jobs.record_vm", side_effect=RuntimeError("worker gone")): + with self.assertRaises(RuntimeError): + self.run_job(op) + op.refresh_from_db() + self.conn.wvm.lookupByUUIDString.side_effect = None + self.assertEqual(RestoreBackup().reconcile(op).state, Operation.SUCCEEDED) + self.assertTrue(Instance.objects.filter(uuid=op.intent["uuid"]).exists()) + self.conn.wvm.defineXML.assert_called_once() + self.assertEqual(self.removed, []) + + def test_only_a_ready_backup_is_restored(self): + Backup.objects.filter(pk=self.backup.pk).update(state=Backup.FAILED) + with self.assertRaisesMessage(OperationError, "ready"): + self.submit() + + def test_the_log_row(self): + op = self.submit() + self.run_job(op) + entry = RestoreBackup().log_entry(op, Operation.SUCCEEDED) + self.assertEqual(entry[:3], ("h1", "vm1-restored", op.intent["uuid"])) + self.assertRegex(entry[3], r"^VM vm1-restored: restored from the backup of vm1 taken \d{4}-") + + def test_api_restore(self): + self.client.force_login(self.admin) + response = self.client.post(f"/api/v1/backups/{self.backup.uuid}/restore/", + {"compute": self.compute.pk, "name": "vm1-restored", "submission_key": "key-api-rst1"}, + content_type="application/json") + self.assertEqual(response.status_code, 202, response.content) + self.assertEqual(response.json()["kind"], "backup.restore") + + def test_the_restore_page(self): + self.client.force_login(self.admin) + url = reverse("vmbackups:restore", args=[self.backup.uuid]) + page = self.client.get(url) + self.assertContains(page, 'value="vm1-restored"') + self.assertContains(page, ">h1") + response = self.client.post(url, {"name": "vm1-restored", "compute": self.compute.pk, "pool": "default", + "submission_key": "key-page-rst1"}) + op = Operation.objects.get() + self.assertRedirects(response, reverse("operations:job", args=[op.pk]), fetch_redirect_response=False) diff --git a/vmbackups/urls.py b/vmbackups/urls.py index ab025463..687eca6a 100644 --- a/vmbackups/urls.py +++ b/vmbackups/urls.py @@ -7,6 +7,7 @@ app_name = "vmbackups" urlpatterns = [ path("", views.index, name="index"), path("/delete/", views.delete, name="delete"), + path("/restore/", views.restore, name="restore"), path("targets/", views.targets, name="targets"), path("targets//", views.target, name="target"), path("vm//create/", views.create, name="create"), diff --git a/vmbackups/views.py b/vmbackups/views.py index fc399c1e..85dd8d2b 100644 --- a/vmbackups/views.py +++ b/vmbackups/views.py @@ -18,7 +18,7 @@ from vrtManager.backup import pool_space, target_pool from vrtManager.connection import wvmConnect from vrtManager.util import OperationError -from .forms import TargetForm, TargetPoolForm +from .forms import RestoreForm, TargetForm, TargetPoolForm from .models import Backup, BackupTarget from .utils import inside_vm_pool @@ -159,3 +159,23 @@ def delete(request, uuid): # 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"))) + + +@superuser_only +def restore(request, uuid): + """Restore a ready backup as a new VM: a backup.restore job, followed on its page.""" + backup = get_object_or_404(Backup.objects.select_related("target"), uuid=uuid, state=Backup.READY) + form = RestoreForm(request.POST or None, backup=backup) + if form.is_valid(): + data = form.cleaned_data + raw = {"backup": str(backup.uuid), "compute": data["compute"].pk, "pool": data["pool"], "name": data["name"], + "connect": data["connect"], "start": data["start"]} + try: + op = jobs.submit("backup.restore", request.user, raw, request.POST.get("submission_key", "")) + except claims.Busy as busy: + form.add_error(None, busy_message(busy, request.user)) + except (jobs.SubmissionConflict, libvirtError) as err: + form.add_error(None, error_text(request, err)) + else: + return redirect("operations:job", op.pk) + return render(request, "vmbackups/restore.html", {"backup": backup, "form": form}) diff --git a/vrtManager/backup.py b/vrtManager/backup.py index 76154f41..bd6e4c55 100644 --- a/vrtManager/backup.py +++ b/vrtManager/backup.py @@ -8,7 +8,7 @@ from django.utils.translation import gettext_noop from lxml import etree from vrtManager.connection import NVRAM_DIR, wvmConnect -from vrtManager.instance import PERSISTENT_XML, wvmInstance +from vrtManager.instance import PERSISTENT_XML, rewrite_for_new_vm, wvmInstance from vrtManager.util import OperationError # pools that keep their volumes as files in one directory @@ -190,6 +190,75 @@ def remove_files(pool, names): vol.delete(0) +def volume_exists(pool, name): + return wvmConnect._find_volume(pool, name) is not None + + def manifest_names(pool): pool.refresh(0) return sorted(name for name in pool.listVolumes() if name.startswith("wvc-") and name.endswith("-manifest.json")) + + +def restore_definition(definition, *, name, uuid, macs, disks, nvram, connect): + """A backup's kept definition made a new VM's: rewrite_for_new_vm's + changes (macs: one per NIC, in order), its media ejected, a new generation ID, each disk's + source the restored file (disks: {dev: (path, format)}) with nothing of + the old one's chain, the NVRAM file at nvram, and each NIC's link down + unless connect: the restored guest keeps the VM's addresses and names.""" + tree = etree.fromstring(definition) + clone_data = {"name": name, "clone-title": tree.findtext("title") or "", + "clone-description": tree.findtext("description") or "", + **{f"clone-net-mac-{number}": mac for number, mac in enumerate(macs)}} + rewrite_for_new_vm(tree, clone_data, uuid) + # media are not in the backup: the restore host may not have them, and the VM would not start + for source in tree.xpath("devices/disk[@device='cdrom' or @device='floppy']/source"): + source.getparent().remove(source) + if (genid := tree.find("genid")) is not None: + genid.text = None # libvirt makes a new one + for disk in tree.xpath("devices/disk[@device='disk']"): + path, disk_format = disks[disk.find("target").get("dev")] + disk.set("type", "file") + for old in disk.xpath("source|backingStore"): + disk.remove(old) + driver = disk.find("driver") + if driver is None: + driver = etree.SubElement(disk, "driver", name="qemu") + driver.set("type", disk_format) + source = etree.Element("source", file=path) + disk.insert(list(disk).index(driver) + 1, source) + if (element := tree.find("os/nvram")) is not None: + if element.find("source") is not None: + element.find("source").set("file", nvram) + else: + element.text = nvram + if not connect: + for interface in tree.findall("devices/interface"): + link = interface.find("link") + if link is None: + link = etree.SubElement(interface, "link") + link.set("state", "down") + return etree.tostring(tree).decode() + + +def check_restore_host(conn, definition): + """Refuses a host that cannot run the backup's definition: its emulator, + machine type and firmware, the networks, bridges and network filters + its NICs name.""" + tree = etree.fromstring(definition) + emulator = tree.findtext("devices/emulator") + os_type = tree.find("os/type") + arch, machine = os_type.get("arch"), os_type.get("machine") + try: + caps = etree.fromstring(conn.wvm.getDomainCapabilities(emulator, arch, machine, tree.get("type"), 0)) + except libvirt.libvirtError as err: + raise OperationError(gettext_noop("This host cannot run the VM's emulator %(emulator)s with machine type %(machine)s: %(error)s"), + emulator=emulator, machine=machine, error=err) from err + loader = (tree.findtext("os/loader") or "").strip() + if loader and loader not in caps.xpath("os/loader/value/text()"): + raise OperationError(gettext_noop("This host has no firmware %(loader)s"), loader=loader) + for network in sorted(set(tree.xpath("devices/interface[@type='network']/source/@network")) - set(conn.get_networks())): + raise OperationError(gettext_noop("This host has no network %(name)s"), name=network) + for bridge in sorted(set(tree.xpath("devices/interface[@type='bridge']/source/@bridge")) - set(conn.get_ifaces())): + raise OperationError(gettext_noop("This host has no bridge %(name)s"), name=bridge) + for nwfilter in sorted(set(tree.xpath("devices/interface/filterref/@filter")) - set(conn.get_nwfilters())): + raise OperationError(gettext_noop("This host has no network filter %(name)s"), name=nwfilter) diff --git a/vrtManager/instance.py b/vrtManager/instance.py index 45d8504e..592c62cb 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -697,6 +697,68 @@ def agent_interfaces(dom): return interfaces + +def rewrite_for_new_vm(tree, clone_data, uuid): + """A VM's persistent definition (tree) made another VM's, in place: its + name, UUID, title and description, each NIC's MAC (clone-net-mac-) + and its filter parameters, a new VNC password, no host device, an + empty TPM and no cloud-init seed of the VM's. The clone and the restore + of a backup share it.""" + # the cloud-init seed holds the VM's own instance-id and hostname: the clone's drive stays empty + seed = f"cidata-{tree.findtext('uuid')}.iso" + for source in tree.xpath("devices/disk[@device='cdrom']/source"): + if os.path.basename(source.get("file") or "") == seed: + source.getparent().remove(source) + tree.find("name").text = clone_data["name"] + uuid_el = tree.find("uuid") + if uuid_el is None: + uuid_el = etree.SubElement(tree, "uuid") + uuid_el.text = uuid + # libvirt refuses an SMBIOS UUID other than the domain's + for entry in tree.xpath("sysinfo/system/entry[@name='uuid']"): + entry.text = uuid + wvmInstance._set_options( + tree, + { + "title": clone_data.get("clone-title", ""), + "description": clone_data.get("clone-description", ""), + }, + ) + + # the clone gets a new, empty TPM (the clone form says so): an emulated + # one without the VM's state path; a host's or another process's would be shared + for backend in tree.xpath("devices/tpm/backend"): + if backend.get("type") != "emulator": + raise util.OperationError(gettext_noop("A VM with a host's or an external TPM is not cloned; remove it first")) + for source in backend.findall("source"): + backend.remove(source) + + # a host device is one VM's: the clone gets none (the clone form says so) + for hostdev in tree.findall("devices/hostdev"): + hostdev.getparent().remove(hostdev) + for num, net in enumerate(tree.findall("devices/interface")): + if net.get("type") == "hostdev": # numbered as the form numbers the VM's NICs + net.getparent().remove(net) + continue + mac = clone_data.get(f"clone-net-mac-{num}") + if not mac: + raise ValueError(f"No MAC address for network interface {num}") + net.find("mac").set("address", wvmInstance.fix_mac(mac)) + # a filter's parameters of the source's own addresses would block the clone's traffic: + # its MAC is the clone's, its IP the one it learns (clean-traffic's default), unless + # learning is off; libvirt learns no IPv6 address, so IPV6 stays for the admin to change + for parameter in net.xpath("filterref/parameter[@name='MAC']"): + parameter.set("value", wvmInstance.fix_mac(mac)) + if not net.xpath("filterref/parameter[@name='CTRL_IP_LEARNING'][@value='none']"): + for parameter in net.xpath("filterref/parameter[@name='IP']"): + parameter.getparent().remove(parameter) + + # the clone's console gets a password of its own: one copied from the source would open both + for graphics in tree.findall("devices/graphics[@type='vnc']"): + graphics.set("passwd", util.randomPasswd(8)) # the length VNC allows + graphics.attrib.pop("passwdValidTo", None) # an expired source's would leave it unusable + + class wvmInstance(wvmConnect): # set by cached_reads(): libvirt answers reused within the block _read_cache = None @@ -2463,7 +2525,8 @@ class wvmInstance(wvmConnect): if pool is not None: pool.refresh(0) - def fix_mac(self, mac): + @staticmethod + def fix_mac(mac): if ":" in mac: return mac # if mac does not contain ":", try to split into tuples and join with ":" @@ -2480,26 +2543,7 @@ class wvmInstance(wvmConnect): raise ValueError("An instance with the clone name already exists") tree = etree.fromstring(self._XMLDesc(PERSISTENT_XML)) - # the cloud-init seed holds the VM's own instance-id and hostname: the clone's drive stays empty - seed = f"cidata-{tree.findtext('uuid')}.iso" - for source in tree.xpath("devices/disk[@device='cdrom']/source"): - if os.path.basename(source.get("file") or "") == seed: - source.getparent().remove(source) - tree.find("name").text = clone_data["name"] - uuid_el = tree.find("uuid") - if uuid_el is None: - uuid_el = etree.SubElement(tree, "uuid") - uuid_el.text = uuid - # libvirt refuses an SMBIOS UUID other than the domain's - for entry in tree.xpath("sysinfo/system/entry[@name='uuid']"): - entry.text = uuid - self._set_options( - tree, - { - "title": clone_data.get("clone-title", ""), - "description": clone_data.get("clone-description", ""), - }, - ) + rewrite_for_new_vm(tree, clone_data, uuid) disks = [] for disk in list(tree.findall("devices/disk")): @@ -2518,39 +2562,6 @@ class wvmInstance(wvmConnect): raise ValueError("Cannot clone a disk without a supported source and destination") disks.append((source, dev)) - # the clone gets a new, empty TPM (the clone form says so): an emulated - # one without the VM's state path; a host's or another process's would be shared - for backend in tree.xpath("devices/tpm/backend"): - if backend.get("type") != "emulator": - raise util.OperationError(gettext_noop("A VM with a host's or an external TPM is not cloned; remove it first")) - for source in backend.findall("source"): - backend.remove(source) - - # a host device is one VM's: the clone gets none (the clone form says so) - for hostdev in tree.findall("devices/hostdev"): - hostdev.getparent().remove(hostdev) - for num, net in enumerate(tree.findall("devices/interface")): - if net.get("type") == "hostdev": # numbered as the form numbers the VM's NICs - net.getparent().remove(net) - continue - mac = clone_data.get(f"clone-net-mac-{num}") - if not mac: - raise ValueError(f"No MAC address for network interface {num}") - net.find("mac").set("address", self.fix_mac(mac)) - # a filter's parameters of the source's own addresses would block the clone's traffic: - # its MAC is the clone's, its IP the one it learns (clean-traffic's default), unless - # learning is off; libvirt learns no IPv6 address, so IPV6 stays for the admin to change - for parameter in net.xpath("filterref/parameter[@name='MAC']"): - parameter.set("value", self.fix_mac(mac)) - if not net.xpath("filterref/parameter[@name='CTRL_IP_LEARNING'][@value='none']"): - for parameter in net.xpath("filterref/parameter[@name='IP']"): - parameter.getparent().remove(parameter) - - # the clone's console gets a password of its own: one copied from the source would open both - for graphics in tree.findall("devices/graphics[@type='vnc']"): - graphics.set("passwd", util.randomPasswd(8)) # the length VNC allows - graphics.attrib.pop("passwdValidTo", None) # an expired source's would leave it unusable - nvram = tree.find("os/nvram") if nvram is not None and nvram.get("type", "file") != "file": raise util.OperationError(gettext_noop("Cannot clone a VM whose NVRAM is not a file")) @@ -3143,7 +3154,8 @@ class wvmInstance(wvmConnect): if not found: raise util.OperationError(gettext_noop("The VM has no network interface %(mac)s"), mac=mac_address) - def _set_options(self, tree, options): + @staticmethod + def _set_options(tree, options): for o in ["title", "description"]: option = tree.find(o) option_value = options.get(o, "").strip() diff --git a/vrtManager/tests/test_backup.py b/vrtManager/tests/test_backup.py index ee06ea95..dcb6745c 100644 --- a/vrtManager/tests/test_backup.py +++ b/vrtManager/tests/test_backup.py @@ -198,3 +198,124 @@ class FilesTestCase(unittest.TestCase): self.assertEqual(volume.findtext("target/permissions/mode"), "0600") conn.upload_volume(pool, "g", b"ab") self.assertIsNone(etree.fromstring(pool.createXML.call_args.args[0]).find("target/permissions")) + + +SOURCE = """ + vm111111111-1111-4111-8111-11111111111122222222-2222-4222-8222-222222222222 + web + 11111111-1111-4111-8111-111111111111 + hvm/usr/share/edk2/ovmf/OVMF_CODE.fd + /var/lib/libvirt/qemu/nvram/vm1_VARS.fd + + /usr/libexec/qemu-kvm + + + + + + + + + + + + + +""" + + +class RestoreDefinitionTestCase(unittest.TestCase): + def restored(self, connect=False): + from lxml import etree + + from vrtManager.backup import restore_definition + + xml = restore_definition( + SOURCE, name="vm1-restored", uuid="33333333-3333-4333-8333-333333333333", + macs=["52:54:00:aa:00:01", "52:54:00:aa:00:02"], + disks={"vda": ("/dest/vm1-restored-vda.qcow2", "qcow2"), "vdb": ("/dest/vm1-restored-vdb.raw", "raw")}, + nvram="/var/lib/libvirt/qemu/nvram/vm1-restored_VARS.fd", connect=connect, + ) + return etree.fromstring(xml) + + def test_restore_definition(self): + tree = self.restored() + self.assertEqual(tree.findtext("name"), "vm1-restored") + self.assertEqual(tree.findtext("uuid"), "33333333-3333-4333-8333-333333333333") + self.assertEqual(tree.xpath("string(sysinfo/system/entry[@name='uuid'])"), "33333333-3333-4333-8333-333333333333") + self.assertEqual(tree.findtext("genid") or "", "") # libvirt makes a new one + self.assertIsNotNone(tree.find("genid")) + self.assertEqual(tree.xpath("devices/interface/mac/@address"), ["52:54:00:aa:00:01", "52:54:00:aa:00:02"]) + self.assertEqual(tree.xpath("devices/interface/filterref/parameter[@name='MAC']/@value"), ["52:54:00:aa:00:01"]) + self.assertEqual(tree.xpath("devices/interface/filterref/parameter[@name='IP']"), []) + self.assertEqual(tree.xpath("devices/disk[@device='disk']/source/@file"), + ["/dest/vm1-restored-vda.qcow2", "/dest/vm1-restored-vdb.raw"]) + self.assertEqual(tree.xpath("devices/disk[@device='disk']/driver/@type"), ["qcow2", "raw"]) + self.assertEqual(tree.xpath("devices/disk//backingStore|devices/disk//seclabel|devices/disk//dataStore"), []) + self.assertEqual(tree.xpath("devices/disk[@device='cdrom']/source"), []) # the old VM's cloud-init seed + self.assertEqual(len(tree.xpath("devices/disk[@device='cdrom']")), 2) # the drives stay + self.assertEqual(tree.findtext("os/nvram"), "/var/lib/libvirt/qemu/nvram/vm1-restored_VARS.fd") + self.assertEqual(tree.xpath("devices/interface/link/@state"), ["down", "down"]) + self.assertNotEqual(tree.xpath("string(devices/graphics/@passwd)"), "secret1") + self.assertEqual(tree.findtext("title"), "web") + + def test_media_are_ejected(self): + # not in the backup: the restore host may not have them, and the VM would not start + tree = self.restored() + self.assertEqual(tree.xpath("devices/disk[@device='cdrom' or @device='floppy']/source"), []) + self.assertEqual(len(tree.xpath("devices/disk[@device='cdrom' or @device='floppy']")), 3) + + def test_links_kept_when_connected(self): + self.assertEqual(self.restored(connect=True).xpath("devices/interface/link/@state"), ["up"]) + + +class RestoreHostTestCase(unittest.TestCase): + def conn(self): + conn = MagicMock() + conn.get_networks.return_value = ["default"] + conn.get_ifaces.return_value = ["br0", "eth0"] + conn.get_nwfilters.return_value = ["clean-traffic"] + conn.wvm.getDomainCapabilities.return_value = ( + "/usr/share/edk2/ovmf/OVMF_CODE.fd") + return conn + + def check(self, conn, *texts): + from vrtManager.backup import check_restore_host + + if not texts: + check_restore_host(conn, SOURCE) + return + with self.assertRaises(util.OperationError) as caught: + check_restore_host(conn, SOURCE) + for text in texts: + self.assertIn(text, str(caught.exception)) + + def test_a_host_that_offers_everything(self): + conn = self.conn() + self.check(conn) + conn.wvm.getDomainCapabilities.assert_called_once_with("/usr/libexec/qemu-kvm", "x86_64", "pc-q35-10.1", "kvm", 0) + + def test_a_missing_network_is_refused(self): + conn = self.conn() + conn.get_networks.return_value = [] + self.check(conn, "network default") + + def test_a_missing_bridge_is_refused(self): + conn = self.conn() + conn.get_ifaces.return_value = ["eth0"] + self.check(conn, "br0") + + def test_a_missing_filter_is_refused(self): + conn = self.conn() + conn.get_nwfilters.return_value = [] + self.check(conn, "clean-traffic") + + def test_an_emulator_or_machine_the_host_lacks_is_refused(self): + conn = self.conn() + conn.wvm.getDomainCapabilities.side_effect = error(libvirt.VIR_ERR_INVALID_ARG) + self.check(conn, "/usr/libexec/qemu-kvm", "pc-q35-10.1") + + def test_a_firmware_the_host_lacks_is_refused(self): + conn = self.conn() + conn.wvm.getDomainCapabilities.return_value = "" + self.check(conn, "OVMF_CODE.fd")