insideWizard: false,
- // defines the possible cpu flags and their labels
- flagsAvail: ['pcid', 'spec-ctrl'],
- flagLabels: ['PCID', 'SPEC-CTRL'],
+ viewModel: {
+ data: {
+ socketCount: 1,
+ coreCount: 1,
+ showCustomModelPermWarning: false,
+ },
+ formulas: {
+ totalCoreCount: get => get('socketCount') * get('coreCount'),
+ },
+ },
+
+ controller: {
+ xclass: 'Ext.app.ViewController',
+ },
onGetValues: function(values) {
var me = this;
- // build the cpu options:
- me.cpu.cputype = values.cputype;
+ if (Array.isArray(values['delete'])) {
+ values['delete'] = values['delete'].join(',');
+ }
- var flags = [];
+ PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
+ PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
- me.flagsAvail.forEach(function(flag) {
- if (values[flag]) {
- flags.push('+' + flag.toString());
- }
- delete values[flag];
- });
+ // build the cpu options:
+ me.cpu.cputype = values.cputype;
- me.cpu.flags = flags.length ? flags.join(';') : undefined;
+ if (values.flags) {
+ me.cpu.flags = values.flags;
+ } else {
+ delete me.cpu.flags;
+ }
delete values.cputype;
delete values.flags;
return values;
},
- initComponent : function() {
- var me = this;
+ setValues: function(values) {
+ let me = this;
- me.cpu = {};
-
- me.column1 = [
- {
- xtype: 'proxmoxintegerfield',
- name: 'sockets',
- minValue: 1,
- maxValue: 4,
- value: '1',
- fieldLabel: gettext('Sockets'),
- allowBlank: false,
- listeners: {
- change: function(f, value) {
- var sockets = me.down('field[name=sockets]').getValue();
- var cores = me.down('field[name=cores]').getValue();
- me.down('field[name=totalcores]').setValue(sockets*cores);
- }
- }
- },
- {
- xtype: 'proxmoxintegerfield',
- name: 'cores',
- minValue: 1,
- maxValue: 128,
- value: '1',
- fieldLabel: gettext('Cores'),
- allowBlank: false,
- listeners: {
- change: function(f, value) {
- var sockets = me.down('field[name=sockets]').getValue();
- var cores = me.down('field[name=cores]').getValue();
- me.down('field[name=totalcores]').setValue(sockets*cores);
- }
- }
- },
- {
- xtype: 'proxmoxcheckbox',
- fieldLabel: gettext('Enable NUMA'),
- name: 'numa',
- uncheckedValue: 0
+ let type = values.cputype;
+ let typeSelector = me.lookupReference('cputype');
+ let typeStore = typeSelector.getStore();
+ typeStore.on('load', (store, records, success) => {
+ if (!success || !type || records.some(x => x.data.name === type)) {
+ return;
}
- ];
-
-
- me.column2 = [
- {
- xtype: 'CPUModelSelector',
- name: 'cputype',
- value: '__default__',
- fieldLabel: gettext('Type')
- },
- {
- xtype: 'displayfield',
- fieldLabel: gettext('Total cores'),
- name: 'totalcores',
- value: '1'
- }
- ];
-
- me.flagsAvail.forEach(function(flag, i) {
- me.column2.push({
- hidden: me.insideWizard,
- disabled: me.insideWizard,
- xtype: 'proxmoxcheckbox',
- fieldLabel: me.flagLabels[i] || flag,
- name: flag,
- uncheckedValue: 0
+ // if we get here, a custom CPU model is selected for the VM but we
+ // don't have permission to configure it - it will not be in the
+ // list retrieved from the API, so add it manually to allow changing
+ // other processor options
+ typeStore.add({
+ name: type,
+ displayname: type.replace(/^custom-/, ''),
+ custom: 1,
+ vendor: gettext("Unknown"),
});
+ typeSelector.select(type);
});
- me.callParent();
- }
+ me.callParent([values]);
+ },
+
+ cpu: {},
+
+ column1: [
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'sockets',
+ minValue: 1,
+ maxValue: 4,
+ value: '1',
+ fieldLabel: gettext('Sockets'),
+ allowBlank: false,
+ bind: {
+ value: '{socketCount}',
+ },
+ },
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'cores',
+ minValue: 1,
+ maxValue: 128,
+ value: '1',
+ fieldLabel: gettext('Cores'),
+ allowBlank: false,
+ bind: {
+ value: '{coreCount}',
+ },
+ },
+ ],
+
+ column2: [
+ {
+ xtype: 'CPUModelSelector',
+ name: 'cputype',
+ reference: 'cputype',
+ fieldLabel: gettext('Type'),
+ },
+ {
+ xtype: 'displayfield',
+ fieldLabel: gettext('Total cores'),
+ name: 'totalcores',
+ isFormField: false,
+ bind: {
+ value: '{totalCoreCount}',
+ },
+ },
+ ],
+
+ columnB: [
+ {
+ xtype: 'displayfield',
+ userCls: 'pmx-hint',
+ value: gettext('WARNING: You do not have permission to configure custom CPU types, if you change the type you will not be able to go back!'),
+ hidden: true,
+ bind: {
+ hidden: '{!showCustomModelPermWarning}',
+ },
+ },
+ ],
+
+ advancedColumn1: [
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'vcpus',
+ minValue: 1,
+ maxValue: 1,
+ value: '',
+ fieldLabel: gettext('VCPUs'),
+ deleteEmpty: true,
+ allowBlank: true,
+ emptyText: '1',
+ bind: {
+ emptyText: '{totalCoreCount}',
+ maxValue: '{totalCoreCount}',
+ },
+ },
+ {
+ xtype: 'numberfield',
+ name: 'cpulimit',
+ minValue: 0,
+ maxValue: 128, // api maximum
+ value: '',
+ step: 1,
+ fieldLabel: gettext('CPU limit'),
+ allowBlank: true,
+ emptyText: gettext('unlimited'),
+ },
+ ],
+
+ advancedColumn2: [
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'cpuunits',
+ fieldLabel: gettext('CPU units'),
+ minValue: 8,
+ maxValue: 500000,
+ value: '1024',
+ deleteEmpty: true,
+ allowBlank: true,
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Enable NUMA'),
+ name: 'numa',
+ uncheckedValue: 0,
+ },
+ ],
+ advancedColumnB: [
+ {
+ xtype: 'label',
+ text: 'Extra CPU Flags:',
+ },
+ {
+ xtype: 'vmcpuflagselector',
+ name: 'flags',
+ },
+ ],
});
Ext.define('PVE.qemu.ProcessorEdit', {
extend: 'Proxmox.window.Edit',
- initComponent : function() {
+ width: 700,
+
+ initComponent: function() {
var me = this;
-
+
var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel');
Ext.apply(me, {
subject: gettext('Processors'),
- items: ipanel
+ items: ipanel,
});
me.callParent();
ipanel.cpu = cpu;
data.cputype = cpu.cputype;
if (cpu.flags) {
- var flags = cpu.flags.split(';');
- flags.forEach(function(flag) {
- var sign = flag.substr(0,1);
- flag = flag.substr(1);
- data[flag] = (sign === '+');
- });
+ data.flags = cpu.flags;
+ }
+
+ let caps = Ext.state.Manager.get('GuiCap');
+ if (data.cputype.indexOf('custom-') === 0 &&
+ !caps.nodes['Sys.Audit']) {
+ let vm = ipanel.getViewModel();
+ vm.set("showCustomModelPermWarning", true);
}
}
me.setValues(data);
- }
+ },
});
- }
+ },
});