]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: restore: add live-restore checkbox
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 3 Mar 2021 09:56:12 +0000 (10:56 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 15 Apr 2021 15:18:40 +0000 (17:18 +0200)
Add 'isPBS' parameter for Restore window so we can detect when to show
the 'live-restore' checkbox.

Includes a warning about this feature being experimental for now.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
www/manager6/grid/BackupView.js
www/manager6/storage/BackupView.js
www/manager6/window/Restore.js

index d4f693e801519c0f2482feb93ac6632652862d25..b50f52ed1b6cd48cf8ffda6e1256b6b8c9432a4b 100644 (file)
@@ -79,6 +79,7 @@ Ext.define('PVE.grid.BackupView', {
            }
        }, 100);
 
+       let isPBS = false;
        var setStorage = function(storage) {
            var url = '/api2/json/nodes/' + nodename + '/storage/' + storage + '/content';
            url += '?content=backup';
@@ -101,13 +102,15 @@ Ext.define('PVE.grid.BackupView', {
                change: function(f, value) {
                    let storage = f.getStore().findRecord('storage', value, 0, false, true, true);
                    if (storage) {
-                       let isPBS = storage.data.type === 'pbs';
+                       isPBS = storage.data.type === 'pbs';
                        me.getColumns().forEach((column) => {
                            let id = column.dataIndex;
                            if (id === 'verification' || id === 'encrypted') {
                                column.setHidden(!isPBS);
                            }
                        });
+                   } else {
+                       isPBS = false;
                    }
                    setStorage(value);
                },
@@ -176,6 +179,7 @@ Ext.define('PVE.grid.BackupView', {
                    volid: rec.data.volid,
                    volidText: PVE.Utils.render_storage_content(rec.data.volid, {}, rec),
                    vmtype: vmtype,
+                   isPBS: isPBS,
                });
                win.show();
                win.on('destroy', reload);
index 87d446ca5b92b91b05a233c9c0ac9b98be46a2fa..3dd500c2a14d5f7d2f8872a38b7b87e062d1b32a 100644 (file)
@@ -74,6 +74,8 @@ Ext.define('PVE.storage.BackupView', {
            }
        });
 
+       let isPBS = me.pluginType === 'pbs';
+
        me.tbar = [
            {
                xtype: 'proxmoxButton',
@@ -95,6 +97,7 @@ Ext.define('PVE.storage.BackupView', {
                        volid: rec.data.volid,
                        volidText: PVE.Utils.render_storage_content(rec.data.volid, {}, rec),
                        vmtype: vmtype,
+                       isPBS: isPBS,
                    });
                    win.show();
                    win.on('destroy', reload);
@@ -117,7 +120,7 @@ Ext.define('PVE.storage.BackupView', {
            pruneButton,
        ];
 
-       if (me.pluginType === 'pbs') {
+       if (isPBS) {
            me.extraColumns = {
                encrypted: {
                    header: gettext('Encrypted'),
index 9e47ebd6f2fed28c7f80394f13b048eb8650181a..91314596710dbdba5f498bfd7f6d12704dfae2bb 100644 (file)
@@ -3,6 +3,20 @@ Ext.define('PVE.window.Restore', {
 
     resizable: false,
 
+    controller: {
+       xclass: 'Ext.app.ViewController',
+       control: {
+           '#liveRestore': {
+               change: function(el, newVal) {
+                   let liveWarning = this.lookupReference('liveWarning');
+                   liveWarning.setHidden(!newVal);
+                   let start = this.lookupReference('start');
+                   start.setDisabled(newVal);
+               },
+           },
+       },
+    },
+
     initComponent: function() {
        var me = this;
 
@@ -85,6 +99,7 @@ Ext.define('PVE.window.Restore', {
                {
                    xtype: 'proxmoxcheckbox',
                    name: 'start',
+                   reference: 'start',
                    flex: 1,
                    fieldLabel: gettext('Start after restore'),
                    labelWidth: 105,
@@ -100,6 +115,26 @@ Ext.define('PVE.window.Restore', {
                value: true,
                fieldLabel: gettext('Unprivileged container'),
            });
+       } else if (me.vmtype === 'qemu') {
+           items.push({
+               xtype: 'proxmoxcheckbox',
+               name: 'live-restore',
+               itemId: 'liveRestore',
+               flex: 1,
+               fieldLabel: gettext('Live restore'),
+               checked: false,
+               hidden: !me.isPBS,
+               // align checkbox with 'start' if 'unique' is hidden
+               labelWidth: me.vmid ? 105 : 100,
+           });
+           items.push({
+               xtype: 'displayfield',
+               reference: 'liveWarning',
+               // TODO: Remove once more tested/stable?
+               value: gettext('Warning: Live-restore is experimental! The VM will start immediately (with a disk performance penalty) and restore will happen in the background. If anything goes wrong, data written by the VM during the restore will be lost.'),
+               userCls: 'pmx-hint',
+               hidden: true,
+           });
        }
 
        me.formPanel = Ext.create('Ext.form.Panel', {
@@ -145,7 +180,8 @@ Ext.define('PVE.window.Restore', {
                    force: me.vmid ? 1 : 0,
                };
                if (values.unique) { params.unique = 1; }
-               if (values.start) { params.start = 1; }
+               if (values.start && !values['live-restore']) { params.start = 1; }
+               if (values['live-restore']) { params['live-restore'] = 1; }
                if (values.storage) { params.storage = values.storage; }
 
                if (values.bwlimit !== undefined) {