From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7E26E973B for ; Tue, 26 Apr 2022 14:31:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 765331B850 for ; Tue, 26 Apr 2022 14:31:00 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id F20321B822 for ; Tue, 26 Apr 2022 14:30:58 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C2F0042BA4 for ; Tue, 26 Apr 2022 14:30:58 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 26 Apr 2022 14:30:53 +0200 Message-Id: <20220426123055.110358-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220426123055.110358-1-f.ebner@proxmox.com> References: <20220426123055.110358-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.083 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v3 manager 1/3] ui: restore: disallow empty storage selection if it wouldn't work X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2022 12:31:00 -0000 Namely, if there is a storage in the backup configuration that's not available on the current node. Signed-off-by: Fabian Ebner --- Changes from v2: * Improve style. * Handle when no storage hint is present correctly. www/manager6/window/Restore.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/www/manager6/window/Restore.js b/www/manager6/window/Restore.js index e48aac1a..51f7d063 100644 --- a/www/manager6/window/Restore.js +++ b/www/manager6/window/Restore.js @@ -94,6 +94,37 @@ Ext.define('PVE.window.Restore', { executeRestore(); } }, + + afterRender: function() { + let view = this.getView(); + + Proxmox.Utils.API2Request({ + url: `/nodes/${view.nodename}/vzdump/extractconfig`, + method: 'GET', + waitMsgTarget: view, + params: { + volume: view.volid, + }, + failure: response => Ext.Msg.alert('Error', response.htmlStatus), + success: function(response, options) { + let allStoragesAvailable = response.result.data.split('\n').every(line => { + let match = line.match(/^#qmdump#map:(\S+):(\S+):(\S*):(\S*):$/); + if (!match) { + return true; + } + // if a /dev/XYZ disk was backed up, ther is no storage hint + return !!match[3] && !!PVE.data.ResourceStore.getById( + `storage/${view.nodename}/${match[3]}`); + }); + + if (!allStoragesAvailable) { + let storagesel = view.down('pveStorageSelector[name=storage]'); + storagesel.allowBlank = false; + storagesel.setEmptyText(''); + } + }, + }); + }, }, initComponent: function() { -- 2.30.2