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 A1BE397E3 for ; Tue, 26 Apr 2022 14:31:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 931341B8A6 for ; Tue, 26 Apr 2022 14:31:02 +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 901F11B834 for ; Tue, 26 Apr 2022 14:30:59 +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 6969142BA4 for ; Tue, 26 Apr 2022 14:30:59 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 26 Apr 2022 14:30:54 +0200 Message-Id: <20220426123055.110358-6-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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [params.storage, params.name] Subject: [pve-devel] [PATCH v3 manager 2/3] ui: restore: allow override of some settings 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:32 -0000 Signed-off-by: Fabian Ebner --- Dependency bump for qemu-server needed Changes from v2: * Improve style. www/manager6/window/Restore.js | 80 ++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/www/manager6/window/Restore.js b/www/manager6/window/Restore.js index 51f7d063..2d78eb56 100644 --- a/www/manager6/window/Restore.js +++ b/www/manager6/window/Restore.js @@ -47,8 +47,16 @@ Ext.define('PVE.window.Restore', { if (values.storage) { params.storage = values.storage; } - if (values.bwlimit !== undefined) { - params.bwlimit = values.bwlimit; + + ['bwlimit', 'cores', 'name', 'memory', 'sockets'].forEach(opt => { + if ((values[opt] ?? '') !== '') { + params[opt] = values[opt]; + } + }); + + if (params.name && view.vmtype === 'lxc') { + params.hostname = params.name; + delete params.name; } let confirmMsg; @@ -107,14 +115,25 @@ Ext.define('PVE.window.Restore', { }, 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; + let allStoragesAvailable = true; + + response.result.data.split('\n').forEach(line => { + let [_, key, value] = line.match(/^([^:]+):\s*(\S+)\s*$/) ?? []; + + if (!key) { + return; + } + + if (key === '#qmdump#map') { + let match = value.match(/^(\S+):(\S+):(\S*):(\S*):$/) ?? []; + // if a /dev/XYZ disk was backed up, ther is no storage hint + allStoragesAvailable &&= !!match[3] && !!PVE.data.ResourceStore.getById( + `storage/${view.nodename}/${match[3]}`); + } else if (key === 'name' || key === 'hostname') { + view.lookupReference('nameField').setEmptyText(value); + } else if (key === 'memory' || key === 'cores' || key === 'sockets') { + view.lookupReference(`${key}Field`).setEmptyText(value); } - // 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) { @@ -274,6 +293,49 @@ Ext.define('PVE.window.Restore', { }); } + items.push( + { + xtype: 'displayfield', + value: `${gettext('Override Settings')}:`, + }, + { + xtype: 'textfield', + fieldLabel: gettext('Name'), + name: 'name', + reference: 'nameField', + allowBlank: true, + }, + { + xtype: 'pveMemoryField', + fieldLabel: gettext('Memory'), + name: 'memory', + reference: 'memoryField', + value: '', + allowBlank: true, + }, + { + xtype: 'proxmoxintegerfield', + fieldLabel: gettext('Cores'), + name: 'cores', + reference: 'coresField', + minValue: 1, + maxValue: 128, + allowBlank: true, + }, + ); + + if (me.vmtype === 'qemu') { + items.push({ + xtype: 'proxmoxintegerfield', + fieldLabel: gettext('Sockets'), + name: 'sockets', + reference: 'socketsField', + minValue: 1, + maxValue: 4, + allowBlank: true, + }); + } + let title = gettext('Restore') + ": " + (me.vmtype === 'lxc' ? 'CT' : 'VM'); if (me.vmid) { title = `${gettext('Overwrite')} ${title} ${me.vmid}`; -- 2.30.2