]> git.proxmox.com Git - pve-manager.git/commitdiff
add cpu options form
authorAlexandre Derumier <aderumier@odiso.com>
Wed, 3 Jun 2015 23:58:45 +0000 (01:58 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 5 Jun 2015 05:39:55 +0000 (07:39 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
www/manager/Makefile
www/manager/qemu/CPUOptions.js [new file with mode: 0644]
www/manager/qemu/HardwareView.js

index 11403d84a5449c431a105075c0e7b4555b545c1e..05eee8945ca655f29c211b3c7abb7584599431e2 100644 (file)
@@ -127,6 +127,7 @@ JSSRC=                                                      \
        qemu/HDResize.js                                \
        qemu/HDMove.js                                  \
        qemu/HDThrottle.js                              \
+       qemu/CPUOptions.js                              \
        qemu/DisplayEdit.js                             \
        qemu/KeyboardEdit.js                            \
        qemu/HardwareView.js                            \
diff --git a/www/manager/qemu/CPUOptions.js b/www/manager/qemu/CPUOptions.js
new file mode 100644 (file)
index 0000000..9034164
--- /dev/null
@@ -0,0 +1,67 @@
+Ext.define('PVE.qemu.CPUOptionsInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+    alias: 'widget.PVE.qemu.CPUOptionsInputPanel',
+
+    initComponent : function() {
+       var me = this;
+
+        var items = [
+            {
+                xtype: 'numberfield',
+                name: 'vcpus',
+                minValue: 1,
+                maxValue: me.maxvcpus,
+                value: '',
+                fieldLabel: gettext('Vcpus'),
+                allowBlank: true,
+            },
+            {
+                xtype: 'numberfield',
+                name: 'cpulimit',
+                minValue: 0,
+                maxValue: me.maxvcpus,
+                value: '',
+                step: 1,
+                fieldLabel: gettext('CPU limit'),
+                allowBlank: false
+
+            },
+           {
+                xtype: 'numberfield',
+                name: 'cpuunits',
+                fieldLabel: gettext('CPU units'),
+                minValue: 8,
+                maxValue: 500000,
+                value: 1024,
+                allowBlank: false
+            }
+
+       ];
+
+       me.items = items;
+
+       me.callParent();
+    }
+});
+
+Ext.define('PVE.qemu.CPUOptions', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+       var me = this;
+
+        var ipanel = Ext.create('PVE.qemu.CPUOptionsInputPanel', {
+            maxvcpus: me.maxvcpus,
+        });
+       
+       Ext.apply(me, {
+           subject: gettext('CPU Options'),
+           items: ipanel,
+           width: 150
+       });
+
+       me.callParent();
+
+       me.load();
+    }
+});
index 6a97899b1fb83b385bf5250497bb4985d0747909..a432bac25cdf8db0f7bf78c4307f1e210160c02d 100644 (file)
@@ -64,13 +64,16 @@ Ext.define('PVE.qemu.HardwareView', {
                    'PVE.qemu.ProcessorEdit' : undefined,
                tdCls: 'pve-itype-icon-processor',
                defaultValue: 1,
-               multiKey: ['sockets', 'cpu', 'cores', 'numa'],
+               multiKey: ['sockets', 'cpu', 'cores', 'numa', 'vcpus', 'cpulimit', 'cpuunits'],
                renderer: function(value, metaData, record, rowIndex, colIndex, store, pending) {
 
                    var sockets = me.getObjectValue('sockets', 1, pending);
                    var model = me.getObjectValue('cpu', undefined, pending);
                    var cores = me.getObjectValue('cores', 1, pending);
                    var numa = me.getObjectValue('numa', undefined, pending);
+                   var vcpus = me.getObjectValue('vcpus', undefined, pending);
+                   var cpulimit = me.getObjectValue('cpulimit', undefined, pending);
+                   var cpuunits = me.getObjectValue('cpuunits', undefined, pending);
 
                    var res = (sockets*cores) + ' (' + sockets + ' sockets, ' + cores + ' cores)';
                    
@@ -82,49 +85,20 @@ Ext.define('PVE.qemu.HardwareView', {
                        res += ' [numa=' + numa +']';
                    }
 
-                   return res;
-               }
-           },
-           cpulimit: {
-               header: gettext('CPU limit'),
-               never_delete: true,
-               defaultValue: '',
-               renderer: function(value) {
-                   if (value && value !== '0') { return value; };
-                   return gettext('unlimited');
-               },
-               tdCls: 'pve-itype-icon-processor',
-               editor: caps.vms['VM.Config.CPU'] ? {
-                   xtype: 'pveWindowEdit',
-                   subject: gettext('CPU limit'),
-                   items: {
-                       xtype: 'numberfield',
-                       name: 'cpulimit',
-                       minValue: 0,
-                       value: '',
-                       step: 1,
-                       fieldLabel: gettext('CPU limit')
+                   if (vcpus) {
+                       res += ' [vcpus=' + vcpus +']';
                    }
-               } : undefined
-           },
-           cpuunits: {
-               header: gettext('CPU units'),
-               never_delete: true,
-               defaultValue: '1024',
-               tdCls: 'pve-itype-icon-processor',
-               editor: caps.vms['VM.Config.CPU'] ? {
-                   xtype: 'pveWindowEdit',
-                   subject: gettext('CPU units'),
-                   items: {
-                       xtype: 'numberfield',
-                       name: 'cpuunits',
-                       fieldLabel: gettext('CPU units'),
-                       minValue: 8,
-                       maxValue: 500000,
-                       value: 1024,
-                       allowBlank: false
+
+                   if (cpulimit) {
+                       res += ' [cpulimit=' + cpulimit +']';
                    }
-               } : undefined
+
+                   if (cpuunits) {
+                       res += ' [cpuunits=' + cpuunits +']';
+                   }
+
+                   return res;
+               }
            },
            keyboard: {
                header: gettext('Keyboard Layout'),
@@ -156,7 +130,17 @@ Ext.define('PVE.qemu.HardwareView', {
            },
            hotplug: {
                visible: false
+           },
+           vcpus: {
+               visible: false
+           },
+           cpuunits: {
+               visible: false
+           },
+           cpulimit: {
+               visible: false
            }
+
        };
 
        for (i = 0; i < 4; i++) {
@@ -313,6 +297,28 @@ Ext.define('PVE.qemu.HardwareView', {
            win.on('destroy', reload);
        };
 
+       var run_cpuoptions = function() {
+           var rec = sm.getSelection()[0];
+           if (!rec) {
+               return;
+           }
+
+           var sockets = me.getObjectValue('sockets', 1);
+           var cores = me.getObjectValue('cores', 1);
+
+           var win = Ext.create('PVE.qemu.CPUOptions', {
+               maxvcpus: sockets * cores,
+               vmid: vmid,
+               pveSelNode: me.pveSelNode,
+               confid: rec.data.key,
+               url: '/api2/extjs/' + baseurl
+           });
+
+           win.show();
+
+           win.on('destroy', reload);
+       };
+
        var run_move = function() {
            var rec = sm.getSelection()[0];
            if (!rec) {
@@ -358,6 +364,13 @@ Ext.define('PVE.qemu.HardwareView', {
            handler: run_diskthrottle
        });
 
+       var cpuoptions_btn = new PVE.button.Button({
+           text: gettext('CPU options'),
+           selModel: sm,
+           disabled: true,
+           handler: run_cpuoptions
+       });
+
        var remove_btn = new PVE.button.Button({
            text: gettext('Remove'),
            selModel: sm,
@@ -425,6 +438,7 @@ Ext.define('PVE.qemu.HardwareView', {
                resize_btn.disable();
                move_btn.disable();
                diskthrottle_btn.disable();
+               cpuoptions_btn.disable();
                revert_btn.disable();
                return;
            }
@@ -446,7 +460,10 @@ Ext.define('PVE.qemu.HardwareView', {
 
            diskthrottle_btn.setDisabled(pending || !isDisk);
 
+           cpuoptions_btn.setDisabled(rowdef.tdCls != 'pve-itype-icon-processor');
+
            revert_btn.setDisabled(!pending);
+
        };
 
        Ext.applyIf(me, {
@@ -506,6 +523,7 @@ Ext.define('PVE.qemu.HardwareView', {
                resize_btn,
                move_btn,
                diskthrottle_btn,
+               cpuoptions_btn,
                revert_btn
            ],
            rows: rows,