]>
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 | ||
5034f339 DC |
8 | controller: { |
9 | xclass: 'Ext.app.ViewController', | |
10 | ||
11 | updateCores: function() { | |
12 | var me = this.getView(); | |
13 | var sockets = me.down('field[name=sockets]').getValue(); | |
14 | var cores = me.down('field[name=cores]').getValue(); | |
15 | me.down('field[name=totalcores]').setValue(sockets*cores); | |
16 | var vcpus = me.down('field[name=vcpus]'); | |
17 | vcpus.setMaxValue(sockets*cores); | |
18 | vcpus.setEmptyText(sockets*cores); | |
19 | vcpus.validate(); | |
20 | }, | |
21 | ||
22 | control: { | |
23 | 'field[name=sockets]': { | |
24 | change: 'updateCores' | |
25 | }, | |
26 | 'field[name=cores]': { | |
27 | change: 'updateCores' | |
28 | } | |
29 | } | |
30 | }, | |
76f56b02 | 31 | |
59e85a54 DM |
32 | onGetValues: function(values) { |
33 | var me = this; | |
34 | ||
5034f339 DC |
35 | if (Array.isArray(values['delete'])) { |
36 | values['delete'] = values['delete'].join(','); | |
37 | } | |
38 | ||
39 | PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0); | |
40 | PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0); | |
41 | ||
59e85a54 | 42 | // build the cpu options: |
ec0bd652 | 43 | me.cpu.cputype = values.cputype; |
1eeb6f17 | 44 | |
76f56b02 DC |
45 | var flags = []; |
46 | ||
5034f339 | 47 | ['pcid', 'spec-ctrl'].forEach(function(flag) { |
76f56b02 DC |
48 | if (values[flag]) { |
49 | flags.push('+' + flag.toString()); | |
50 | } | |
51 | delete values[flag]; | |
52 | }); | |
53 | ||
54 | me.cpu.flags = flags.length ? flags.join(';') : undefined; | |
55 | ||
ec0bd652 | 56 | delete values.cputype; |
1eeb6f17 | 57 | delete values.flags; |
59e85a54 DM |
58 | var cpustring = PVE.Parser.printQemuCpu(me.cpu); |
59 | ||
60 | // remove cputype delete request: | |
61 | var del = values['delete']; | |
62 | delete values['delete']; | |
63 | if (del) { | |
64 | del = del.split(','); | |
65 | Ext.Array.remove(del, 'cputype'); | |
66 | } else { | |
67 | del = []; | |
68 | } | |
69 | ||
70 | if (cpustring) { | |
ec0bd652 | 71 | values.cpu = cpustring; |
59e85a54 DM |
72 | } else { |
73 | del.push('cpu'); | |
74 | } | |
75 | ||
ec0bd652 DC |
76 | var delarr = del.join(','); |
77 | if (delarr) { | |
78 | values['delete'] = delarr; | |
59e85a54 DM |
79 | } |
80 | ||
81 | return values; | |
82 | }, | |
83 | ||
5034f339 DC |
84 | cpu: {}, |
85 | ||
86 | column1: [ | |
87 | { | |
88 | xtype: 'proxmoxintegerfield', | |
89 | name: 'sockets', | |
90 | minValue: 1, | |
91 | maxValue: 4, | |
92 | value: '1', | |
93 | fieldLabel: gettext('Sockets'), | |
94 | allowBlank: false | |
95 | }, | |
96 | { | |
97 | xtype: 'proxmoxintegerfield', | |
98 | name: 'cores', | |
99 | minValue: 1, | |
100 | maxValue: 128, | |
101 | value: '1', | |
102 | fieldLabel: gettext('Cores'), | |
103 | allowBlank: false | |
104 | } | |
105 | ], | |
106 | ||
107 | column2: [ | |
108 | { | |
109 | xtype: 'CPUModelSelector', | |
110 | name: 'cputype', | |
111 | value: '__default__', | |
112 | fieldLabel: gettext('Type') | |
113 | }, | |
114 | { | |
115 | xtype: 'displayfield', | |
116 | fieldLabel: gettext('Total cores'), | |
117 | name: 'totalcores', | |
118 | value: '1' | |
119 | } | |
120 | ], | |
121 | ||
122 | advancedColumn1: [ | |
123 | { | |
124 | xtype: 'proxmoxintegerfield', | |
125 | name: 'vcpus', | |
126 | minValue: 1, | |
127 | value: '', | |
128 | fieldLabel: gettext('VCPUs'), | |
129 | deleteEmpty: true, | |
130 | allowBlank: true, | |
131 | emptyText: '1' | |
132 | }, | |
133 | { | |
134 | xtype: 'numberfield', | |
135 | name: 'cpulimit', | |
136 | minValue: 0, | |
137 | maxValue: 128, // api maximum | |
138 | value: '', | |
139 | step: 1, | |
140 | fieldLabel: gettext('CPU limit'), | |
141 | allowBlank: true, | |
142 | emptyText: gettext('unlimited') | |
143 | }, | |
144 | { | |
145 | xtype: 'proxmoxintegerfield', | |
146 | name: 'cpuunits', | |
147 | fieldLabel: gettext('CPU units'), | |
148 | minValue: 8, | |
149 | maxValue: 500000, | |
150 | value: '1024', | |
151 | deleteEmpty: true, | |
152 | allowBlank: true | |
153 | } | |
154 | ], | |
155 | ||
156 | advancedColumn2: [ | |
157 | { | |
158 | xtype: 'proxmoxcheckbox', | |
159 | fieldLabel: gettext('Enable NUMA'), | |
160 | name: 'numa', | |
161 | uncheckedValue: 0 | |
162 | }, | |
163 | { | |
164 | xtype: 'proxmoxcheckbox', | |
165 | fieldLabel: 'PCID', | |
166 | name: 'pcid', | |
167 | uncheckedValue: 0 | |
168 | }, | |
169 | { | |
170 | xtype: 'proxmoxcheckbox', | |
171 | fieldLabel: 'SPEC-CTRL', | |
172 | name: 'spec-ctrl', | |
173 | uncheckedValue: 0 | |
174 | } | |
175 | ] | |
59e85a54 DM |
176 | }); |
177 | ||
178 | Ext.define('PVE.qemu.ProcessorEdit', { | |
9fccc702 | 179 | extend: 'Proxmox.window.Edit', |
59e85a54 DM |
180 | |
181 | initComponent : function() { | |
182 | var me = this; | |
5034f339 | 183 | |
a764c5f7 | 184 | var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel'); |
59e85a54 DM |
185 | |
186 | Ext.apply(me, { | |
187 | subject: gettext('Processors'), | |
188 | items: ipanel | |
189 | }); | |
190 | ||
191 | me.callParent(); | |
192 | ||
193 | me.load({ | |
194 | success: function(response, options) { | |
195 | var data = response.result.data; | |
ec0bd652 | 196 | var value = data.cpu; |
59e85a54 DM |
197 | if (value) { |
198 | var cpu = PVE.Parser.parseQemuCpu(value); | |
199 | ipanel.cpu = cpu; | |
200 | data.cputype = cpu.cputype; | |
76f56b02 DC |
201 | if (cpu.flags) { |
202 | var flags = cpu.flags.split(';'); | |
203 | flags.forEach(function(flag) { | |
204 | var sign = flag.substr(0,1); | |
205 | flag = flag.substr(1); | |
206 | data[flag] = (sign === '+'); | |
207 | }); | |
208 | } | |
59e85a54 DM |
209 | } |
210 | me.setValues(data); | |
211 | } | |
212 | }); | |
213 | } | |
214 | }); |