[pve-devel] [PATCH v2 manager 1/3] ui: restore: disallow empty storage selection if it wouldn't work

Fabian Ebner f.ebner at proxmox.com
Thu Apr 21 13:26:57 CEST 2022


Namely, if there is a storage in the backup configuration that's not
available on the current node.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

New in v2.

 www/manager6/window/Restore.js | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/www/manager6/window/Restore.js b/www/manager6/window/Restore.js
index e7b3e945..25babf89 100644
--- a/www/manager6/window/Restore.js
+++ b/www/manager6/window/Restore.js
@@ -15,6 +15,40 @@ Ext.define('PVE.window.Restore', {
 		},
 	    },
 	},
+
+	afterRender: function() {
+	    let view = this.getView();
+
+	    Proxmox.Utils.API2Request({
+		url: `/nodes/${view.nodename}/vzdump/extractconfig`,
+		method: 'GET',
+		params: {
+		    volume: view.volid,
+		},
+		failure: (response) => Ext.Msg.alert('Error', response.htmlStatus),
+		success: function(response, options) {
+		    let storagesAvailable = true;
+
+		    response.result.data.split('\n').forEach(function(line) {
+			let match = line.match(
+			    /^#qmdump#map:(\S+):(\S+):(\S*):(\S*):$/,
+			);
+			if (match) {
+			    let currentAvailable = !!PVE.data.ResourceStore.getById(
+				`storage/${view.nodename}/${match[3]}`,
+			    );
+			    storagesAvailable = storagesAvailable && currentAvailable;
+			}
+		    });
+
+		    if (!storagesAvailable) {
+			let storagesel = view.down('pveStorageSelector[name=storage]');
+			storagesel.allowBlank = false;
+			storagesel.setEmptyText('');
+		    }
+		},
+	    });
+	},
     },
 
     initComponent: function() {
-- 
2.30.2






More information about the pve-devel mailing list