[pve-devel] [PATCH v3 manager 2/3] ui: restore: allow override of some settings

Fabian Ebner f.ebner at proxmox.com
Tue Apr 26 14:30:54 CEST 2022


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

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






More information about the pve-devel mailing list