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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6AD95BBC09 for ; Tue, 26 Mar 2024 14:25:58 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 530B91494F for ; Tue, 26 Mar 2024 14:25:58 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 26 Mar 2024 14:25:57 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 11954421B6 for ; Tue, 26 Mar 2024 14:25:57 +0100 (CET) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Tue, 26 Mar 2024 14:25:56 +0100 Message-Id: <20240326132556.4050167-1-a.lauterer@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.064 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 manager] ui: guest import: allow setting mac addresses to unique 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 Mar 2024 13:25:58 -0000 by adding a new checkbox and render the grid accordingly. If unique MAC addresses are enabled, set them to undefined when getting the values from the grid. Signed-off-by: Aaron Lauterer --- not sure if setting `uniqueMac` directly on the component is okay. Though we do that dynamically for the `vmConfig` as well. So probably okayish. www/manager6/window/GuestImport.js | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/www/manager6/window/GuestImport.js b/www/manager6/window/GuestImport.js index ae9bac5b..aee54706 100644 --- a/www/manager6/window/GuestImport.js +++ b/www/manager6/window/GuestImport.js @@ -15,6 +15,8 @@ Ext.define('PVE.window.GuestImport', { showTaskViewer: true, method: 'POST', + uniqueMac: false, + loadUrl: function(_url, { storage, nodename, volumeName }) { let args = Ext.Object.toQueryString({ volume: volumeName }); return `/nodes/${nodename}/storage/${storage}/import-metadata?${args}`; @@ -187,6 +189,7 @@ Ext.define('PVE.window.GuestImport', { refreshGrids: function() { this.lookup('diskGrid').reconfigure(); this.lookup('cdGrid').reconfigure(); + this.lookup('netGrid').reconfigure(); }, onOSTypeChange: function(_cb, value) { @@ -226,6 +229,21 @@ Ext.define('PVE.window.GuestImport', { me.getView().vmConfig.scsihw = value; }, + onUniqueMacChange: function(_cb, value) { + let me = this; + me.getView().uniqueMac = value; + + me.refreshGrids(); + }, + + renderMacAddress: function(value, metaData, record, rowIndex, colIndex, store, view) { + let me = this; + if (me.getView().uniqueMac) { + return 'auto'; + } + return value ? value : 'auto'; + }, + control: { 'grid field': { // update records from widgetcolumns @@ -256,6 +274,9 @@ Ext.define('PVE.window.GuestImport', { 'pveScsiHwSelector': { change: 'onScsiHwChange', }, + 'proxmoxcheckbox[reference=uniqueMac]': { + change: 'onUniqueMacChange', + }, }, }, @@ -364,6 +385,9 @@ Ext.define('PVE.window.GuestImport', { if (!data.bridge) { data.bridge = defaultBridge; } + if (grid.uniqueMac) { + data.macaddr = undefined; + } config[id] = PVE.Parser.printQemuNetwork(data); }); @@ -778,7 +802,7 @@ Ext.define('PVE.window.GuestImport', { text: gettext('MAC address'), flex: 1, dataIndex: 'macaddr', - renderer: value => value ?? 'auto', + renderer: 'renderMacAddress', }, { text: gettext('Model'), @@ -809,6 +833,19 @@ Ext.define('PVE.window.GuestImport', { }, ], }, + { + xtype: 'proxmoxcheckbox', + name: 'uniqueMACs', + reference: 'uniqueMac', + labelWidth: 200, + fieldLabel: gettext('Unique MAC addresses'), + uncheckedValue: false, + checked: false, + autoEl: { + tag: 'div', + 'data-qtip': gettext('Generate new unique MAC addresses.'), + }, + }, ], }, { -- 2.39.2