[pve-devel] [PATCH 2/2] add maxcpus field to processor form

Alexandre Derumier aderumier at odiso.com
Mon Jan 6 17:59:23 CET 2014


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/qemu/ProcessorEdit.js |   64 +++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/www/manager/qemu/ProcessorEdit.js b/www/manager/qemu/ProcessorEdit.js
index 1dc444b..404ec68 100644
--- a/www/manager/qemu/ProcessorEdit.js
+++ b/www/manager/qemu/ProcessorEdit.js
@@ -2,6 +2,38 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
     extend: 'PVE.panel.InputPanel',
     alias: 'widget.PVE.qemu.ProcessorInputPanel',
 
+    onGetValues: function(values) {
+        var me = this;
+
+        var res;
+	var deletearray = [];
+
+	if(!values.sockets){
+	    values.sockets = 1;
+	}
+	res = {
+	    sockets: values.sockets,
+	    cores: values.cores
+	};
+
+        if (Ext.isDefined(values.cpu) && (values.cpu !== "")) {
+            res.cpu = values.cpu;
+	} else {
+	    deletearray.push('cpu');
+        }
+
+        if (Ext.isDefined(values.maxcpus) && (values.maxcpus !== "")) {
+            res.maxcpus = values.maxcpus;
+	} else {
+	    deletearray.push('maxcpus');
+        }
+
+	res['delete'] = deletearray.join(',');
+
+        return res;
+    },
+
+
     initComponent : function() {
 	var me = this;
 
@@ -37,6 +69,38 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 			me.down('field[name=totalcores]').setValue(sockets*cores);
 		    }
 		}
+	    },
+	    {
+		xtype: 'numberfield',
+		name: 'maxcpus',
+		minValue: 2,
+		maxValue: 64,
+		value: '',
+		fieldLabel: gettext('Max hotplug cores'),
+		allowBlank: true,
+                emptyText: gettext('disabled'),
+                submitEmptyText: false,
+		listeners: {
+		    change: function(f, value) {
+
+			var sf = me.down('field[name=sockets]');
+			if(value){
+			    sf.setValue(1);
+			    sf.setMaxValue(1);
+			    sf.setDisabled(1);
+			}else{
+			    sf.setMaxValue(4);
+			    sf.setDisabled(0);
+			}
+
+			var cf = me.down('field[name=cores]');
+                        var cores = cf.getValue();
+                        if (value && cores > value) {
+                            cf.setValue(value);
+                        }
+                        cf.setMaxValue(value);
+		    }
+		}
 	    }
 	];
 
-- 
1.7.10.4




More information about the pve-devel mailing list