add cpu options form

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2015-06-04 01:58:45 +02:00 committed by Dietmar Maurer
parent ca34da232a
commit e8ee57105f
3 changed files with 128 additions and 42 deletions

View 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 \

View File

@ -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();
}
});

View 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,50 +85,21 @@ Ext.define('PVE.qemu.HardwareView', {
res += ' [numa=' + numa +']';
}
if (vcpus) {
res += ' [vcpus=' + vcpus +']';
}
if (cpulimit) {
res += ' [cpulimit=' + cpulimit +']';
}
if (cpuunits) {
res += ' [cpuunits=' + cpuunits +']';
}
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')
}
} : 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
}
} : undefined
},
keyboard: {
header: gettext('Keyboard Layout'),
never_delete: true,
@ -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,