]>
Commit | Line | Data |
---|---|---|
59e85a54 | 1 | Ext.define('PVE.qemu.ProcessorInputPanel', { |
ef4ef788 | 2 | extend: 'Proxmox.panel.InputPanel', |
42902182 | 3 | alias: 'widget.pveQemuProcessorPanel', |
c8802a60 | 4 | onlineHelp: 'qm_cpu', |
59e85a54 | 5 | |
1eeb6f17 DC |
6 | insideWizard: false, |
7 | ||
b839766e SR |
8 | viewModel: { |
9 | data: { | |
10 | socketCount: 1, | |
11 | coreCount: 1, | |
7376c56e | 12 | showCustomModelPermWarning: false, |
5034f339 | 13 | }, |
b839766e SR |
14 | formulas: { |
15 | totalCoreCount: get => get('socketCount') * get('coreCount'), | |
16 | }, | |
17 | }, | |
5034f339 | 18 | |
b839766e SR |
19 | controller: { |
20 | xclass: 'Ext.app.ViewController', | |
5034f339 | 21 | }, |
76f56b02 | 22 | |
59e85a54 DM |
23 | onGetValues: function(values) { |
24 | var me = this; | |
25 | ||
399ffa76 TL |
26 | if (Array.isArray(values.delete)) { |
27 | values.delete = values.delete.join(','); | |
5034f339 DC |
28 | } |
29 | ||
61c03387 FE |
30 | PVE.Utils.delete_if_default(values, 'cpulimit', '0', me.insideWizard); |
31 | PVE.Utils.delete_if_default(values, 'cpuunits', '1024', me.insideWizard); | |
5034f339 | 32 | |
59e85a54 | 33 | // build the cpu options: |
ec0bd652 | 34 | me.cpu.cputype = values.cputype; |
1eeb6f17 | 35 | |
06064872 TL |
36 | if (values.flags) { |
37 | me.cpu.flags = values.flags; | |
38 | } else { | |
39 | delete me.cpu.flags; | |
40 | } | |
76f56b02 | 41 | |
ec0bd652 | 42 | delete values.cputype; |
1eeb6f17 | 43 | delete values.flags; |
59e85a54 DM |
44 | var cpustring = PVE.Parser.printQemuCpu(me.cpu); |
45 | ||
46 | // remove cputype delete request: | |
399ffa76 TL |
47 | var del = values.delete; |
48 | delete values.delete; | |
59e85a54 DM |
49 | if (del) { |
50 | del = del.split(','); | |
51 | Ext.Array.remove(del, 'cputype'); | |
52 | } else { | |
53 | del = []; | |
54 | } | |
55 | ||
56 | if (cpustring) { | |
ec0bd652 | 57 | values.cpu = cpustring; |
59e85a54 DM |
58 | } else { |
59 | del.push('cpu'); | |
60 | } | |
61 | ||
ec0bd652 DC |
62 | var delarr = del.join(','); |
63 | if (delarr) { | |
399ffa76 | 64 | values.delete = delarr; |
59e85a54 DM |
65 | } |
66 | ||
67 | return values; | |
68 | }, | |
69 | ||
7376c56e SR |
70 | setValues: function(values) { |
71 | let me = this; | |
72 | ||
73 | let type = values.cputype; | |
74 | let typeSelector = me.lookupReference('cputype'); | |
75 | let typeStore = typeSelector.getStore(); | |
76 | typeStore.on('load', (store, records, success) => { | |
77 | if (!success || !type || records.some(x => x.data.name === type)) { | |
78 | return; | |
79 | } | |
80 | ||
81 | // if we get here, a custom CPU model is selected for the VM but we | |
82 | // don't have permission to configure it - it will not be in the | |
83 | // list retrieved from the API, so add it manually to allow changing | |
84 | // other processor options | |
85 | typeStore.add({ | |
86 | name: type, | |
87 | displayname: type.replace(/^custom-/, ''), | |
88 | custom: 1, | |
89 | vendor: gettext("Unknown"), | |
90 | }); | |
91 | typeSelector.select(type); | |
92 | }); | |
93 | ||
94 | me.callParent([values]); | |
95 | }, | |
96 | ||
5034f339 DC |
97 | cpu: {}, |
98 | ||
99 | column1: [ | |
100 | { | |
101 | xtype: 'proxmoxintegerfield', | |
102 | name: 'sockets', | |
103 | minValue: 1, | |
104 | maxValue: 4, | |
105 | value: '1', | |
106 | fieldLabel: gettext('Sockets'), | |
b839766e SR |
107 | allowBlank: false, |
108 | bind: { | |
109 | value: '{socketCount}', | |
110 | }, | |
5034f339 DC |
111 | }, |
112 | { | |
113 | xtype: 'proxmoxintegerfield', | |
114 | name: 'cores', | |
115 | minValue: 1, | |
116 | maxValue: 128, | |
117 | value: '1', | |
118 | fieldLabel: gettext('Cores'), | |
b839766e SR |
119 | allowBlank: false, |
120 | bind: { | |
121 | value: '{coreCount}', | |
122 | }, | |
123 | }, | |
5034f339 DC |
124 | ], |
125 | ||
126 | column2: [ | |
127 | { | |
128 | xtype: 'CPUModelSelector', | |
129 | name: 'cputype', | |
7376c56e | 130 | reference: 'cputype', |
f6710aac | 131 | fieldLabel: gettext('Type'), |
5034f339 DC |
132 | }, |
133 | { | |
134 | xtype: 'displayfield', | |
135 | fieldLabel: gettext('Total cores'), | |
136 | name: 'totalcores', | |
b839766e SR |
137 | isFormField: false, |
138 | bind: { | |
139 | value: '{totalCoreCount}', | |
140 | }, | |
141 | }, | |
5034f339 DC |
142 | ], |
143 | ||
7376c56e SR |
144 | columnB: [ |
145 | { | |
146 | xtype: 'displayfield', | |
147 | userCls: 'pmx-hint', | |
148 | 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!'), | |
149 | hidden: true, | |
150 | bind: { | |
151 | hidden: '{!showCustomModelPermWarning}', | |
152 | }, | |
153 | }, | |
154 | ], | |
155 | ||
5034f339 DC |
156 | advancedColumn1: [ |
157 | { | |
158 | xtype: 'proxmoxintegerfield', | |
159 | name: 'vcpus', | |
160 | minValue: 1, | |
de63d77a | 161 | maxValue: 1, |
5034f339 DC |
162 | value: '', |
163 | fieldLabel: gettext('VCPUs'), | |
164 | deleteEmpty: true, | |
165 | allowBlank: true, | |
b839766e SR |
166 | emptyText: '1', |
167 | bind: { | |
168 | emptyText: '{totalCoreCount}', | |
169 | maxValue: '{totalCoreCount}', | |
170 | }, | |
5034f339 DC |
171 | }, |
172 | { | |
173 | xtype: 'numberfield', | |
174 | name: 'cpulimit', | |
175 | minValue: 0, | |
176 | maxValue: 128, // api maximum | |
177 | value: '', | |
178 | step: 1, | |
179 | fieldLabel: gettext('CPU limit'), | |
180 | allowBlank: true, | |
f6710aac TL |
181 | emptyText: gettext('unlimited'), |
182 | }, | |
06064872 TL |
183 | ], |
184 | ||
185 | advancedColumn2: [ | |
5034f339 DC |
186 | { |
187 | xtype: 'proxmoxintegerfield', | |
188 | name: 'cpuunits', | |
189 | fieldLabel: gettext('CPU units'), | |
87faaa0b TL |
190 | // FIXME: change to [1, 1000] once cgroup v1 support gets removed (PVE 8 ?) |
191 | minValue: 2, | |
192 | maxValue: 262144, | |
5034f339 DC |
193 | value: '1024', |
194 | deleteEmpty: true, | |
f6710aac | 195 | allowBlank: true, |
06064872 | 196 | }, |
5034f339 DC |
197 | { |
198 | xtype: 'proxmoxcheckbox', | |
199 | fieldLabel: gettext('Enable NUMA'), | |
200 | name: 'numa', | |
f6710aac TL |
201 | uncheckedValue: 0, |
202 | }, | |
06064872 TL |
203 | ], |
204 | advancedColumnB: [ | |
5034f339 | 205 | { |
06064872 | 206 | xtype: 'label', |
f6710aac | 207 | text: 'Extra CPU Flags:', |
5034f339 DC |
208 | }, |
209 | { | |
06064872 | 210 | xtype: 'vmcpuflagselector', |
f6710aac TL |
211 | name: 'flags', |
212 | }, | |
213 | ], | |
59e85a54 DM |
214 | }); |
215 | ||
216 | Ext.define('PVE.qemu.ProcessorEdit', { | |
9fccc702 | 217 | extend: 'Proxmox.window.Edit', |
59e85a54 | 218 | |
06064872 TL |
219 | width: 700, |
220 | ||
8058410f | 221 | initComponent: function() { |
59e85a54 | 222 | var me = this; |
5034f339 | 223 | |
a764c5f7 | 224 | var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel'); |
59e85a54 DM |
225 | |
226 | Ext.apply(me, { | |
227 | subject: gettext('Processors'), | |
f6710aac | 228 | items: ipanel, |
59e85a54 DM |
229 | }); |
230 | ||
231 | me.callParent(); | |
232 | ||
233 | me.load({ | |
234 | success: function(response, options) { | |
235 | var data = response.result.data; | |
ec0bd652 | 236 | var value = data.cpu; |
59e85a54 DM |
237 | if (value) { |
238 | var cpu = PVE.Parser.parseQemuCpu(value); | |
239 | ipanel.cpu = cpu; | |
240 | data.cputype = cpu.cputype; | |
76f56b02 | 241 | if (cpu.flags) { |
06064872 | 242 | data.flags = cpu.flags; |
76f56b02 | 243 | } |
7376c56e SR |
244 | |
245 | let caps = Ext.state.Manager.get('GuiCap'); | |
246 | if (data.cputype.indexOf('custom-') === 0 && | |
8058410f | 247 | !caps.nodes['Sys.Audit']) { |
7376c56e SR |
248 | let vm = ipanel.getViewModel(); |
249 | vm.set("showCustomModelPermWarning", true); | |
250 | } | |
59e85a54 DM |
251 | } |
252 | me.setValues(data); | |
f6710aac | 253 | }, |
59e85a54 | 254 | }); |
f6710aac | 255 | }, |
59e85a54 | 256 | }); |