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 74AC0AFCD for ; Wed, 6 Apr 2022 10:05:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 18FB72731F for ; Wed, 6 Apr 2022 10:04:46 +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 3D80A272AE for ; Wed, 6 Apr 2022 10:04:43 +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 09E5F41FD2 for ; Wed, 6 Apr 2022 10:04:43 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 6 Apr 2022 10:04:16 +0200 Message-Id: <20220406080416.66227-20-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406080416.66227-1-f.ebner@proxmox.com> References: <20220406080416.66227-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v10 manager 19/19] ui: qemu: wizard: add import from OVF functionality 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: Wed, 06 Apr 2022 08:05:17 -0000 From: Dominic Jäger Signed-off-by: Dominic Jäger [FE: Split out preparatory work, and re-use existing classes Show message upon successfull readovf API call Simplify a few things] Signed-off-by: Fabian Ebner --- www/manager6/qemu/CreateWizard.js | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js index a785a882..d522c09b 100644 --- a/www/manager6/qemu/CreateWizard.js +++ b/www/manager6/qemu/CreateWizard.js @@ -22,6 +22,7 @@ Ext.define('PVE.qemu.CreateWizard', { { xtype: 'inputpanel', title: gettext('General'), + itemId: 'generalPanel', onlineHelp: 'qm_general_settings', column1: [ { @@ -63,6 +64,63 @@ Ext.define('PVE.qemu.CreateWizard', { value: '', allowBlank: true, }, + { + xtype: 'textfield', + name: 'ovfTextfield', + emptyText: '/path/to/manifest.ovf', + fieldLabel: gettext('Import from OVF'), + hidden: Proxmox.UserName !== 'root@pam', + }, + { + xtype: 'proxmoxButton', + text: gettext('Load .ovf'), + hidden: Proxmox.UserName !== 'root@pam', + handler: function() { + const inputpanel = this.up('#generalPanel'); + const nodename = inputpanel.down('pveNodeSelector').getValue(); + const ovfTextfieldValue = inputpanel.down('textfield[name=ovfTextfield]').getValue(); + const wizard = this.up('window'); + + Proxmox.Utils.API2Request({ + url: `/nodes/${nodename}/readovf`, + method: 'GET', + params: { + manifest: ovfTextfieldValue, + }, + success: function(response) { + const ovfData = response.result.data; + + wizard.down('textfield[name=name]').setValue(ovfData.name); + wizard.down('#cpuPanel').getViewModel().set('coreCount', ovfData.cores); + wizard.down('#memoryPanel').setMemory(ovfData.memory); + + delete ovfData.cores; + delete ovfData.name; + delete ovfData.memory; + + let multiDiskPanel = wizard.down('pveMultiHDPanel'); + multiDiskPanel.removeAllDisks(); + Object.keys(ovfData).sort().forEach(function(drive) { + multiDiskPanel.addDisk(drive, { 'importPath': ovfData[drive] }); + }); + + wizard.down('radiofield[inputValue=none]').setValue(true); + // Need to manually uncheck when not yet rendered. + wizard.down('radiofield[inputValue=iso]').setValue(false); + + Ext.Msg.show({ + title: gettext('Success'), + icon: Ext.Msg.INFO, + msg: gettext('VM settings updated'), + buttons: Ext.Msg.OK, + }); + }, + failure: function(response) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); + }, + }, ], advancedColumn1: [ { @@ -120,6 +178,7 @@ Ext.define('PVE.qemu.CreateWizard', { delete values.order; delete values.up; delete values.down; + delete values.ovfTextfield; return values; }, @@ -162,11 +221,13 @@ Ext.define('PVE.qemu.CreateWizard', { }, { xtype: 'pveQemuProcessorPanel', + itemId: 'cpuPanel', insideWizard: true, title: gettext('CPU'), }, { xtype: 'pveQemuMemoryPanel', + itemId: 'memoryPanel', insideWizard: true, title: gettext('Memory'), }, -- 2.30.2