]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/Utils.js
ui: storage: zfs: set blocksize placeholder to 16k
[pve-manager.git] / www / manager6 / Utils.js
CommitLineData
b0a6d326
EK
1Ext.ns('PVE');
2
4d739f4a 3console.log("Starting Proxmox VE Manager");
b0a6d326
EK
4
5Ext.Ajax.defaultHeaders = {
f6710aac 6 'Accept': 'application/json',
b0a6d326
EK
7};
8
8058410f
TL
9Ext.define('PVE.Utils', {
10 utilities: {
b0a6d326 11
9fa2e36d 12 // this singleton contains miscellaneous utilities
b0a6d326 13
0be88ae1 14 toolkit: undefined, // (extjs|touch), set inside Toolkit.js
b0a6d326 15
3b5617cc 16 bus_match: /^(ide|sata|virtio|scsi)(\d+)$/,
98a01af2 17
b0a6d326
EK
18 log_severity_hash: {
19 0: "panic",
20 1: "alert",
21 2: "critical",
22 3: "error",
23 4: "warning",
24 5: "notice",
25 6: "info",
f6710aac 26 7: "debug",
b0a6d326
EK
27 },
28
29 support_level_hash: {
30 'c': gettext('Community'),
31 'b': gettext('Basic'),
32 's': gettext('Standard'),
f6710aac 33 'p': gettext('Premium'),
b0a6d326
EK
34 },
35
301f52b1 36 noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit '
347f88fe 37 +'<a target="_blank" href="https://www.proxmox.com/en/proxmox-virtual-environment/pricing">'
301f52b1 38 +'www.proxmox.com</a> to get a list of available options.',
b0a6d326 39
e6a1160f
TL
40 getClusterSubscriptionLevel: async function() {
41 let { result } = await Proxmox.Async.api2({ url: '/cluster/status' });
42 let levelMap = Object.fromEntries(
43 result.data.filter(v => v.type === 'node').map(v => [v.name, v.level]),
44 );
45 return levelMap;
46 },
47
b0a6d326 48 kvm_ostypes: {
45d6c71a 49 'Linux': [
a2ff227e 50 { desc: '6.x - 2.6 Kernel', val: 'l26' },
f6710aac 51 { desc: '2.4 Kernel', val: 'l24' },
45d6c71a
TL
52 ],
53 'Microsoft Windows': [
a9175b0b 54 { desc: '11/2022', val: 'win11' },
beb3c8a4 55 { desc: '10/2016/2019', val: 'win10' },
45d6c71a
TL
56 { desc: '8.x/2012/2012r2', val: 'win8' },
57 { desc: '7/2008r2', val: 'win7' },
58 { desc: 'Vista/2008', val: 'w2k8' },
59 { desc: 'XP/2003', val: 'wxp' },
f6710aac 60 { desc: '2000', val: 'w2k' },
45d6c71a
TL
61 ],
62 'Solaris Kernel': [
8058410f 63 { desc: '-', val: 'solaris' },
45d6c71a
TL
64 ],
65 'Other': [
8058410f 66 { desc: '-', val: 'other' },
f6710aac 67 ],
b0a6d326
EK
68 },
69
43798244
SR
70 is_windows: function(ostype) {
71 for (let entry of PVE.Utils.kvm_ostypes['Microsoft Windows']) {
72 if (entry.val === ostype) {
73 return true;
74 }
75 }
76 return false;
77 },
78
428bc4a2
DC
79 get_health_icon: function(state, circle) {
80 if (circle === undefined) {
81 circle = false;
82 }
83
84 if (state === undefined) {
85 state = 'uknown';
86 }
87
88 var icon = 'faded fa-question';
8058410f 89 switch (state) {
428bc4a2
DC
90 case 'good':
91 icon = 'good fa-check';
92 break;
23c83a3a
DC
93 case 'upgrade':
94 icon = 'warning fa-upload';
95 break;
aa240b29
DC
96 case 'old':
97 icon = 'warning fa-refresh';
98 break;
428bc4a2
DC
99 case 'warning':
100 icon = 'warning fa-exclamation';
101 break;
102 case 'critical':
103 icon = 'critical fa-times';
104 break;
105 default: break;
106 }
107
108 if (circle) {
109 icon += '-circle';
110 }
111
112 return icon;
113 },
114
95d0de89
DC
115 parse_ceph_version: function(service) {
116 if (service.ceph_version_short) {
117 return service.ceph_version_short;
118 }
119
120 if (service.ceph_version) {
35306f47 121 var match = service.ceph_version.match(/version (\d+(\.\d+)*)/);
95d0de89
DC
122 if (match) {
123 return match[1];
124 }
125 }
126
127 return undefined;
128 },
129
005e0a60 130 compare_ceph_versions: function(a, b) {
3a08795a
DC
131 let avers = [];
132 let bvers = [];
133
005e0a60
DC
134 if (a === b) {
135 return 0;
136 }
3a08795a
DC
137
138 if (Ext.isArray(a)) {
139 avers = a.slice(); // copy array
140 } else {
141 avers = a.toString().split('.');
142 }
143
144 if (Ext.isArray(b)) {
145 bvers = b.slice(); // copy array
146 } else {
147 bvers = b.toString().split('.');
148 }
35306f47 149
4d739f4a 150 for (;;) {
35306f47
TL
151 let av = avers.shift();
152 let bv = bvers.shift();
153
154 if (av === undefined && bv === undefined) {
155 return 0;
8058410f 156 } else if (av === undefined) {
35306f47
TL
157 return -1;
158 } else if (bv === undefined) {
159 return 1;
160 } else {
161 let diff = parseInt(av, 10) - parseInt(bv, 10);
4d739f4a 162 if (diff !== 0) return diff;
35306f47 163 // else we need to look at the next parts
005e0a60
DC
164 }
165 }
005e0a60
DC
166 },
167
2f5b82ae
DC
168 get_ceph_icon_html: function(health, fw) {
169 var state = PVE.Utils.map_ceph_health[health];
170 var cls = PVE.Utils.get_health_icon(state);
171 if (fw) {
172 cls += ' fa-fw';
173 }
174 return "<i class='fa " + cls + "'></i> ";
175 },
176
046e640c 177 map_ceph_health: {
8058410f
TL
178 'HEALTH_OK': 'good',
179 'HEALTH_UPGRADE': 'upgrade',
180 'HEALTH_OLD': 'old',
181 'HEALTH_WARN': 'warning',
182 'HEALTH_ERR': 'critical',
046e640c
DC
183 },
184
4d739f4a 185 render_sdn_pending: function(rec, value, key, index) {
1d9643f6
AD
186 if (rec.data.state === undefined || rec.data.state === null) {
187 return value;
188 }
189
190 if (rec.data.state === 'deleted') {
191 if (value === undefined) {
192 return ' ';
193 } else {
194 return '<div style="text-decoration: line-through;">'+ value +'</div>';
195 }
4d739f4a
TL
196 } else if (rec.data.pending[key] !== undefined && rec.data.pending[key] !== null) {
197 if (rec.data.pending[key] === 'deleted') {
198 return ' ';
1d9643f6 199 } else {
4d739f4a 200 return rec.data.pending[key];
1d9643f6
AD
201 }
202 }
203 return value;
204 },
205
4d739f4a 206 render_sdn_pending_state: function(rec, value) {
1d9643f6
AD
207 if (value === undefined || value === null) {
208 return ' ';
209 }
210
211 let icon = `<i class="fa fa-fw fa-refresh warning"></i>`;
212
213 if (value === 'deleted') {
214 return '<span>' + icon + value + '</span>';
215 }
216
4d739f4a 217 let tip = gettext('Pending Changes') + ': <br>';
1d9643f6
AD
218
219 for (const [key, keyvalue] of Object.entries(rec.data.pending)) {
4d739f4a
TL
220 if ((rec.data[key] !== undefined && rec.data.pending[key] !== rec.data[key]) ||
221 rec.data[key] === undefined
222 ) {
223 tip += `${key}: ${keyvalue} <br>`;
1d9643f6
AD
224 }
225 }
226 return '<span data-qtip="' + tip + '">'+ icon + value + '</span>';
227 },
228
dfe6d184 229 render_ceph_health: function(healthObj) {
046e640c
DC
230 var state = {
231 iconCls: PVE.Utils.get_health_icon(),
f6710aac 232 text: '',
046e640c
DC
233 };
234
dfe6d184 235 if (!healthObj || !healthObj.status) {
046e640c
DC
236 return state;
237 }
238
dfe6d184 239 var health = PVE.Utils.map_ceph_health[healthObj.status];
046e640c
DC
240
241 state.iconCls = PVE.Utils.get_health_icon(health, true);
dfe6d184 242 state.text = healthObj.status;
046e640c
DC
243
244 return state;
245 },
246
fee716d3 247 render_zfs_health: function(value) {
4d739f4a 248 if (typeof value === 'undefined') {
8c8604ba
TM
249 return "";
250 }
fee716d3
DC
251 var iconCls = 'question-circle';
252 switch (value) {
8c8604ba 253 case 'AVAIL':
fee716d3
DC
254 case 'ONLINE':
255 iconCls = 'check-circle good';
256 break;
257 case 'REMOVED':
258 case 'DEGRADED':
259 iconCls = 'exclamation-circle warning';
260 break;
261 case 'UNAVAIL':
262 case 'FAULTED':
263 case 'OFFLINE':
264 iconCls = 'times-circle critical';
265 break;
266 default: //unknown
267 }
268
269 return '<i class="fa fa-' + iconCls + '"></i> ' + value;
270 },
271
14ba33fb
TL
272 render_pbs_fingerprint: fp => fp.substring(0, 23),
273
3003a59d
TL
274 render_backup_encryption: function(v, meta, record) {
275 if (!v) {
276 return gettext('No');
277 }
278
279 let tip = '';
280 if (v.match(/^[a-fA-F0-9]{2}:/)) { // fingerprint
281 tip = `Key fingerprint ${PVE.Utils.render_pbs_fingerprint(v)}`;
282 }
283 let icon = `<i class="fa fa-fw fa-lock good"></i>`;
284 return `<span data-qtip="${tip}">${icon} ${gettext('Encrypted')}</span>`;
285 },
286
770d614f
TL
287 render_backup_verification: function(v, meta, record) {
288 let i = (cls, txt) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`;
289 if (v === undefined || v === null) {
290 return i('question-circle-o warning', gettext('None'));
291 }
8058410f 292 let tip = "";
770d614f
TL
293 let txt = gettext('Failed');
294 let iconCls = 'times critical';
295 if (v.state === 'ok') {
296 txt = gettext('OK');
297 iconCls = 'check good';
298 let now = Date.now() / 1000;
299 let task = Proxmox.Utils.parse_task_upid(v.upid);
300 let verify_time = Proxmox.Utils.render_timestamp(task.starttime);
301 tip = `Last verify task started on ${verify_time}`;
302 if (now - v.starttime > 30 * 24 * 60 * 60) {
303 tip = `Last verify task over 30 days ago: ${verify_time}`;
304 iconCls = 'check warning';
305 }
306 }
307 return `<span data-qtip="${tip}"> ${i(iconCls, txt)} </span>`;
308 },
309
01ad47af 310 render_backup_status: function(value, meta, record) {
4d739f4a 311 if (typeof value === 'undefined') {
01ad47af
AL
312 return "";
313 }
314
315 let iconCls = 'check-circle good';
316 let text = gettext('Yes');
317
318 if (!PVE.Parser.parseBoolean(value.toString())) {
319 iconCls = 'times-circle critical';
320
321 text = gettext('No');
322
323 let reason = record.get('reason');
324 if (typeof reason !== 'undefined') {
325 if (reason in PVE.Utils.backup_reasons_table) {
326 reason = PVE.Utils.backup_reasons_table[record.get('reason')];
327 }
328 text = `${text} - ${reason}`;
329 }
330 }
331
332 return `<i class="fa fa-${iconCls}"></i> ${text}`;
333 },
334
7f08d0d1
AL
335 render_backup_days_of_week: function(val) {
336 var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
337 var selected = [];
338 var cur = -1;
8058410f 339 val.split(',').forEach(function(day) {
7f08d0d1
AL
340 cur++;
341 var dow = (dows.indexOf(day)+6)%7;
342 if (cur === dow) {
343 if (selected.length === 0 || selected[selected.length-1] === 0) {
344 selected.push(1);
345 } else {
346 selected[selected.length-1]++;
347 }
348 } else {
349 while (cur < dow) {
350 cur++;
351 selected.push(0);
352 }
353 selected.push(1);
354 }
355 });
356
357 cur = -1;
358 var days = [];
359 selected.forEach(function(item) {
360 cur++;
361 if (item > 2) {
53e3ea84 362 days.push(Ext.Date.dayNames[cur+1] + '-' + Ext.Date.dayNames[(cur+item)%7]);
7f08d0d1 363 cur += item-1;
4d739f4a 364 } else if (item === 2) {
7f08d0d1
AL
365 days.push(Ext.Date.dayNames[cur+1]);
366 days.push(Ext.Date.dayNames[(cur+2)%7]);
367 cur++;
4d739f4a 368 } else if (item === 1) {
7f08d0d1
AL
369 days.push(Ext.Date.dayNames[(cur+1)%7]);
370 }
371 });
372 return days.join(', ');
373 },
374
375 render_backup_selection: function(value, metaData, record) {
376 let allExceptText = gettext('All except {0}');
377 let allText = '-- ' + gettext('All') + ' --';
378 if (record.data.all) {
379 if (record.data.exclude) {
380 return Ext.String.format(allExceptText, record.data.exclude);
381 }
382 return allText;
383 }
384 if (record.data.vmid) {
385 return record.data.vmid;
386 }
387
388 if (record.data.pool) {
389 return "Pool '"+ record.data.pool + "'";
390 }
391
392 return "-";
393 },
394
01ad47af
AL
395 backup_reasons_table: {
396 'backup=yes': gettext('Enabled'),
397 'backup=no': gettext('Disabled'),
398 'enabled': gettext('Enabled'),
399 'disabled': gettext('Disabled'),
400 'not a volume': gettext('Not a volume'),
401 'efidisk but no OMVF BIOS': gettext('EFI Disk without OMVF BIOS'),
402 },
403
04389e49
TL
404 renderNotFound: what => Ext.String.format(gettext("No {0} found"), what),
405
45d6c71a
TL
406 get_kvm_osinfo: function(value) {
407 var info = { base: 'Other' }; // default
408 if (value) {
409 Ext.each(Object.keys(PVE.Utils.kvm_ostypes), function(k) {
410 Ext.each(PVE.Utils.kvm_ostypes[k], function(e) {
411 if (e.val === value) {
412 info = { desc: e.desc, base: k };
413 }
414 });
415 });
b0a6d326 416 }
45d6c71a
TL
417 return info;
418 },
419
8058410f 420 render_kvm_ostype: function(value) {
45d6c71a
TL
421 var osinfo = PVE.Utils.get_kvm_osinfo(value);
422 if (osinfo.desc && osinfo.desc !== '-') {
423 return osinfo.base + ' ' + osinfo.desc;
424 } else {
425 return osinfo.base;
b0a6d326 426 }
b0a6d326
EK
427 },
428
8058410f 429 render_hotplug_features: function(value) {
23d3881a 430 var fa = [];
b0a6d326 431
53e3ea84 432 if (!value || value === '0') {
ec99b1c3 433 return gettext('Disabled');
b0a6d326
EK
434 }
435
4dcca8a4
DC
436 if (value === '1') {
437 value = 'disk,network,usb';
438 }
439
b0a6d326
EK
440 Ext.each(value.split(','), function(el) {
441 if (el === 'disk') {
442 fa.push(gettext('Disk'));
443 } else if (el === 'network') {
444 fa.push(gettext('Network'));
445 } else if (el === 'usb') {
b9628aa5 446 fa.push('USB');
b0a6d326
EK
447 } else if (el === 'memory') {
448 fa.push(gettext('Memory'));
449 } else if (el === 'cpu') {
450 fa.push(gettext('CPU'));
451 } else {
452 fa.push(el);
453 }
454 });
455
456 return fa.join(', ');
457 },
458
0beff18b
FE
459 render_localtime: function(value) {
460 if (value === '__default__') {
461 return Proxmox.Utils.defaultText + ' (' + gettext('Enabled for Windows') + ')';
462 }
463 return Proxmox.Utils.format_boolean(value);
464 },
465
4d739f4a
TL
466 render_qga_features: function(config) {
467 if (!config) {
8058410f 468 return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')';
1662ccdb 469 }
4d739f4a
TL
470 let qga = PVE.Parser.parsePropertyString(config, 'enabled');
471 if (!PVE.Parser.parseBoolean(qga.enabled)) {
1662ccdb
SI
472 return Proxmox.Utils.disabledText;
473 }
4d739f4a 474 delete qga.enabled;
1662ccdb 475
4d739f4a 476 let agentstring = Proxmox.Utils.enabledText;
1662ccdb 477
4d739f4a
TL
478 for (const [key, value] of Object.entries(qga)) {
479 let displayText = Proxmox.Utils.disabledText;
5a6c563c
MD
480 if (key === 'type') {
481 let map = {
482 isa: "ISA",
176a62d3 483 virtio: "VirtIO",
5a6c563c 484 };
4d739f4a 485 displayText = map[value] || Proxmox.Utils.unknownText;
8bb027f8
CH
486 } else if (key === 'freeze-fs-on-backup' && PVE.Parser.parseBoolean(value)) {
487 continue;
4d739f4a
TL
488 } else if (PVE.Parser.parseBoolean(value)) {
489 displayText = Proxmox.Utils.enabledText;
1662ccdb 490 }
4d739f4a
TL
491 agentstring += `, ${key}: ${displayText}`;
492 }
1662ccdb
SI
493
494 return agentstring;
495 },
496
a1ee14a2 497 render_qemu_machine: function(value) {
53e3ea84 498 return value || Proxmox.Utils.defaultText + ' (i440fx)';
a1ee14a2
DC
499 },
500
17c71f27
DC
501 render_qemu_bios: function(value) {
502 if (!value) {
e7ade592 503 return Proxmox.Utils.defaultText + ' (SeaBIOS)';
17c71f27
DC
504 } else if (value === 'seabios') {
505 return "SeaBIOS";
506 } else if (value === 'ovmf') {
507 return "OVMF (UEFI)";
508 } else {
509 return value;
510 }
511 },
512
8f17b496
TL
513 render_dc_ha_opts: function(value) {
514 if (!value) {
41ca3465 515 return Proxmox.Utils.defaultText;
8f17b496
TL
516 } else {
517 return PVE.Parser.printPropertyString(value);
518 }
519 },
afa725cd 520 render_as_property_string: v => !v ? Proxmox.Utils.defaultText : PVE.Parser.printPropertyString(v),
8f17b496 521
b0a6d326 522 render_scsihw: function(value) {
5ff69573 523 if (!value || value === '__default__') {
e7ade592 524 return Proxmox.Utils.defaultText + ' (LSI 53C895A)';
b0a6d326
EK
525 } else if (value === 'lsi') {
526 return 'LSI 53C895A';
527 } else if (value === 'lsi53c810') {
528 return 'LSI 53C810';
529 } else if (value === 'megasas') {
530 return 'MegaRAID SAS 8708EM2';
531 } else if (value === 'virtio-scsi-pci') {
49f5d1ab
EK
532 return 'VirtIO SCSI';
533 } else if (value === 'virtio-scsi-single') {
534 return 'VirtIO SCSI single';
b0a6d326
EK
535 } else if (value === 'pvscsi') {
536 return 'VMware PVSCSI';
537 } else {
538 return value;
539 }
540 },
541
9c22da32 542 render_spice_enhancements: function(values) {
9c22da32
AL
543 let props = PVE.Parser.parsePropertyString(values);
544 if (Ext.Object.isEmpty(props)) {
3b0facc9 545 return Proxmox.Utils.noneText;
9c22da32
AL
546 }
547
548 let output = [];
549 if (PVE.Parser.parseBoolean(props.foldersharing)) {
550 output.push('Folder Sharing: ' + gettext('Enabled'));
551 }
552 if (props.videostreaming === 'all' || props.videostreaming === 'filter') {
553 output.push('Video Streaming: ' + props.videostreaming);
554 }
555 return output.join(', ');
556 },
557
b0a6d326
EK
558 // fixme: auto-generate this
559 // for now, please keep in sync with PVE::Tools::kvmkeymaps
560 kvm_keymaps: {
b7004b46 561 '__default__': Proxmox.Utils.defaultText,
b0a6d326
EK
562 //ar: 'Arabic',
563 da: 'Danish',
0be88ae1
DC
564 de: 'German',
565 'de-ch': 'German (Swiss)',
566 'en-gb': 'English (UK)',
0a5b8747 567 'en-us': 'English (USA)',
b0a6d326
EK
568 es: 'Spanish',
569 //et: 'Estonia',
570 fi: 'Finnish',
0be88ae1
DC
571 //fo: 'Faroe Islands',
572 fr: 'French',
573 'fr-be': 'French (Belgium)',
b0a6d326
EK
574 'fr-ca': 'French (Canada)',
575 'fr-ch': 'French (Swiss)',
576 //hr: 'Croatia',
577 hu: 'Hungarian',
578 is: 'Icelandic',
0be88ae1 579 it: 'Italian',
b0a6d326
EK
580 ja: 'Japanese',
581 lt: 'Lithuanian',
582 //lv: 'Latvian',
0be88ae1 583 mk: 'Macedonian',
b0a6d326
EK
584 nl: 'Dutch',
585 //'nl-be': 'Dutch (Belgium)',
0be88ae1 586 no: 'Norwegian',
b0a6d326
EK
587 pl: 'Polish',
588 pt: 'Portuguese',
589 'pt-br': 'Portuguese (Brazil)',
590 //ru: 'Russian',
591 sl: 'Slovenian',
592 sv: 'Swedish',
593 //th: 'Thai',
f6710aac 594 tr: 'Turkish',
b0a6d326
EK
595 },
596
597 kvm_vga_drivers: {
b7004b46 598 '__default__': Proxmox.Utils.defaultText,
b0a6d326 599 std: gettext('Standard VGA'),
5ca366f2 600 vmware: gettext('VMware compatible'),
b0a6d326
EK
601 qxl: 'SPICE',
602 qxl2: 'SPICE dual monitor',
603 qxl3: 'SPICE three monitors',
604 qxl4: 'SPICE four monitors',
605 serial0: gettext('Serial terminal') + ' 0',
606 serial1: gettext('Serial terminal') + ' 1',
607 serial2: gettext('Serial terminal') + ' 2',
89ae1bb1
DC
608 serial3: gettext('Serial terminal') + ' 3',
609 virtio: 'VirtIO-GPU',
7d72d62f 610 'virtio-gl': 'VirGL GPU',
f6710aac 611 none: Proxmox.Utils.noneText,
b0a6d326
EK
612 },
613
8058410f 614 render_kvm_language: function(value) {
a8e22a83 615 if (!value || value === '__default__') {
e7ade592 616 return Proxmox.Utils.defaultText;
b0a6d326 617 }
b7004b46
TL
618 let text = PVE.Utils.kvm_keymaps[value];
619 return text ? `${text} (${value})` : value;
b0a6d326
EK
620 },
621
3438c27e 622 console_map: {
da9d14cd 623 '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
3438c27e
DC
624 'vv': 'SPICE (remote-viewer)',
625 'html5': 'HTML5 (noVNC)',
f6710aac 626 'xtermjs': 'xterm.js',
3438c27e
DC
627 },
628
b0a6d326 629 render_console_viewer: function(value) {
3438c27e 630 value = value || '__default__';
b7004b46 631 return PVE.Utils.console_map[value] || value;
755b9083
TL
632 },
633
8058410f 634 render_kvm_vga_driver: function(value) {
b0a6d326 635 if (!value) {
e7ade592 636 return Proxmox.Utils.defaultText;
b0a6d326 637 }
b7004b46
TL
638 let vga = PVE.Parser.parsePropertyString(value, 'type');
639 let text = PVE.Utils.kvm_vga_drivers[vga.type];
4f3e66d8
DC
640 if (!vga.type) {
641 text = Proxmox.Utils.defaultText;
642 }
b7004b46 643 return text ? `${text} (${value})` : value;
b0a6d326
EK
644 },
645
646 render_kvm_startup: function(value) {
647 var startup = PVE.Parser.parseStartup(value);
648
649 var res = 'order=';
650 if (startup.order === undefined) {
651 res += 'any';
652 } else {
653 res += startup.order;
654 }
655 if (startup.up !== undefined) {
656 res += ',up=' + startup.up;
657 }
658 if (startup.down !== undefined) {
659 res += ',down=' + startup.down;
660 }
661
662 return res;
663 },
664
b0a6d326
EK
665 extractFormActionError: function(action) {
666 var msg;
667 switch (action.failureType) {
668 case Ext.form.action.Action.CLIENT_INVALID:
669 msg = gettext('Form fields may not be submitted with invalid values');
670 break;
671 case Ext.form.action.Action.CONNECT_FAILURE:
672 msg = gettext('Connection error');
673 var resp = action.response;
674 if (resp.status && resp.statusText) {
675 msg += " " + resp.status + ": " + resp.statusText;
676 }
677 break;
678 case Ext.form.action.Action.LOAD_FAILURE:
679 case Ext.form.action.Action.SERVER_INVALID:
e7ade592 680 msg = Proxmox.Utils.extractRequestError(action.result, true);
b0a6d326
EK
681 break;
682 }
683 return msg;
684 },
685
0e244a29
DC
686 contentTypes: {
687 'images': gettext('Disk image'),
688 'backup': gettext('VZDump backup file'),
689 'vztmpl': gettext('Container template'),
690 'iso': gettext('ISO image'),
aef28e04 691 'rootdir': gettext('Container'),
f6710aac 692 'snippets': gettext('Snippets'),
0e244a29 693 },
b0a6d326 694
3b8f599b
DM
695 volume_is_qemu_backup: function(volid, format) {
696 return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-');
697 },
698
699 volume_is_lxc_backup: function(volid, format) {
700 return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
701 },
702
efff7eab
DC
703 authSchema: {
704 ad: {
705 name: gettext('Active Directory Server'),
706 ipanel: 'pveAuthADPanel',
822fb26d 707 syncipanel: 'pveAuthLDAPSyncPanel',
efff7eab 708 add: true,
550857eb 709 tfa: true,
60265958 710 pwchange: true,
efff7eab
DC
711 },
712 ldap: {
713 name: gettext('LDAP Server'),
714 ipanel: 'pveAuthLDAPPanel',
822fb26d 715 syncipanel: 'pveAuthLDAPSyncPanel',
efff7eab 716 add: true,
550857eb 717 tfa: true,
60265958 718 pwchange: true,
efff7eab 719 },
668951e2 720 openid: {
c42e3aa7 721 name: gettext('OpenID Connect Server'),
668951e2
DC
722 ipanel: 'pveAuthOpenIDPanel',
723 add: true,
724 tfa: false,
60265958 725 pwchange: false,
da25c5ac 726 iconCls: 'pmx-itype-icon-openid-logo',
668951e2 727 },
efff7eab
DC
728 pam: {
729 name: 'Linux PAM',
730 ipanel: 'pveAuthBasePanel',
731 add: false,
550857eb 732 tfa: true,
60265958 733 pwchange: true,
efff7eab
DC
734 },
735 pve: {
736 name: 'Proxmox VE authentication server',
737 ipanel: 'pveAuthBasePanel',
738 add: false,
f5ae7496 739 tfa: true,
60265958 740 pwchange: true,
efff7eab
DC
741 },
742 },
743
062a7f49
TL
744 storageSchema: {
745 dir: {
746 name: Proxmox.Utils.directoryText,
747 ipanel: 'DirInputPanel',
06c8315d
DC
748 faIcon: 'folder',
749 backups: true,
062a7f49
TL
750 },
751 lvm: {
752 name: 'LVM',
753 ipanel: 'LVMInputPanel',
06c8315d
DC
754 faIcon: 'folder',
755 backups: false,
062a7f49
TL
756 },
757 lvmthin: {
758 name: 'LVM-Thin',
759 ipanel: 'LvmThinInputPanel',
06c8315d
DC
760 faIcon: 'folder',
761 backups: false,
062a7f49 762 },
ffeb4f57
TL
763 btrfs: {
764 name: 'BTRFS',
765 ipanel: 'BTRFSInputPanel',
766 faIcon: 'folder',
767 backups: true,
768 },
062a7f49
TL
769 nfs: {
770 name: 'NFS',
771 ipanel: 'NFSInputPanel',
06c8315d
DC
772 faIcon: 'building',
773 backups: true,
062a7f49
TL
774 },
775 cifs: {
3266c03d 776 name: 'SMB/CIFS',
062a7f49 777 ipanel: 'CIFSInputPanel',
06c8315d
DC
778 faIcon: 'building',
779 backups: true,
062a7f49
TL
780 },
781 glusterfs: {
782 name: 'GlusterFS',
783 ipanel: 'GlusterFsInputPanel',
06c8315d
DC
784 faIcon: 'building',
785 backups: true,
062a7f49
TL
786 },
787 iscsi: {
788 name: 'iSCSI',
789 ipanel: 'IScsiInputPanel',
06c8315d
DC
790 faIcon: 'building',
791 backups: false,
062a7f49 792 },
4a4b2b6e
TL
793 cephfs: {
794 name: 'CephFS',
795 ipanel: 'CephFSInputPanel',
06c8315d
DC
796 faIcon: 'building',
797 backups: true,
4a4b2b6e
TL
798 },
799 pvecephfs: {
800 name: 'CephFS (PVE)',
801 ipanel: 'CephFSInputPanel',
802 hideAdd: true,
06c8315d
DC
803 faIcon: 'building',
804 backups: true,
4a4b2b6e 805 },
062a7f49
TL
806 rbd: {
807 name: 'RBD',
808 ipanel: 'RBDInputPanel',
06c8315d
DC
809 faIcon: 'building',
810 backups: false,
062a7f49
TL
811 },
812 pveceph: {
813 name: 'RBD (PVE)',
0d1ac958
TL
814 ipanel: 'RBDInputPanel',
815 hideAdd: true,
06c8315d
DC
816 faIcon: 'building',
817 backups: false,
062a7f49
TL
818 },
819 zfs: {
820 name: 'ZFS over iSCSI',
821 ipanel: 'ZFSInputPanel',
06c8315d
DC
822 faIcon: 'building',
823 backups: false,
062a7f49
TL
824 },
825 zfspool: {
826 name: 'ZFS',
827 ipanel: 'ZFSPoolInputPanel',
06c8315d
DC
828 faIcon: 'folder',
829 backups: false,
062a7f49 830 },
8b966034
TL
831 pbs: {
832 name: 'Proxmox Backup Server',
ee19d331
TL
833 ipanel: 'PBSInputPanel',
834 faIcon: 'floppy-o',
06c8315d 835 backups: true,
8b966034 836 },
062a7f49
TL
837 drbd: {
838 name: 'DRBD',
8b966034 839 hideAdd: true,
06c8315d 840 backups: false,
8b966034 841 },
062a7f49
TL
842 },
843
9233148b
AD
844 sdnvnetSchema: {
845 vnet: {
846 name: 'vnet',
f6710aac 847 faIcon: 'folder',
9233148b
AD
848 },
849 },
850
851 sdnzoneSchema: {
852 zone: {
853 name: 'zone',
f6710aac 854 hideAdd: true,
9233148b 855 },
1b4cce60
AD
856 simple: {
857 name: 'Simple',
858 ipanel: 'SimpleInputPanel',
f6710aac 859 faIcon: 'th',
1b4cce60 860 },
9233148b 861 vlan: {
f3c1eac7 862 name: 'VLAN',
9233148b 863 ipanel: 'VlanInputPanel',
f6710aac 864 faIcon: 'th',
9233148b
AD
865 },
866 qinq: {
f3c1eac7 867 name: 'QinQ',
9233148b 868 ipanel: 'QinQInputPanel',
f6710aac 869 faIcon: 'th',
9233148b
AD
870 },
871 vxlan: {
f3c1eac7 872 name: 'VXLAN',
9233148b 873 ipanel: 'VxlanInputPanel',
f6710aac 874 faIcon: 'th',
9233148b
AD
875 },
876 evpn: {
f3c1eac7 877 name: 'EVPN',
9233148b 878 ipanel: 'EvpnInputPanel',
f6710aac 879 faIcon: 'th',
9233148b
AD
880 },
881 },
882
883 sdncontrollerSchema: {
884 controller: {
885 name: 'controller',
f6710aac 886 hideAdd: true,
9233148b
AD
887 },
888 evpn: {
889 name: 'evpn',
890 ipanel: 'EvpnInputPanel',
f6710aac 891 faIcon: 'crosshairs',
9233148b 892 },
1d9643f6
AD
893 bgp: {
894 name: 'bgp',
895 ipanel: 'BgpInputPanel',
4d739f4a 896 faIcon: 'crosshairs',
1d9643f6 897 },
202e26d4
AD
898 isis: {
899 name: 'isis',
900 ipanel: 'IsisInputPanel',
901 faIcon: 'crosshairs',
902 },
1d9643f6
AD
903 },
904
905 sdnipamSchema: {
906 ipam: {
907 name: 'ipam',
4d739f4a 908 hideAdd: true,
1d9643f6
AD
909 },
910 pve: {
911 name: 'PVE',
912 ipanel: 'PVEIpamInputPanel',
913 faIcon: 'th',
4d739f4a 914 hideAdd: true,
1d9643f6
AD
915 },
916 netbox: {
917 name: 'Netbox',
918 ipanel: 'NetboxInputPanel',
4d739f4a 919 faIcon: 'th',
1d9643f6
AD
920 },
921 phpipam: {
922 name: 'PhpIpam',
923 ipanel: 'PhpIpamInputPanel',
4d739f4a 924 faIcon: 'th',
1d9643f6
AD
925 },
926 },
927
928 sdndnsSchema: {
929 dns: {
930 name: 'dns',
4d739f4a 931 hideAdd: true,
1d9643f6
AD
932 },
933 powerdns: {
934 name: 'powerdns',
935 ipanel: 'PowerdnsInputPanel',
4d739f4a 936 faIcon: 'th',
1d9643f6 937 },
9233148b
AD
938 },
939
940 format_sdnvnet_type: function(value, md, record) {
941 var schema = PVE.Utils.sdnvnetSchema[value];
942 if (schema) {
943 return schema.name;
944 }
945 return Proxmox.Utils.unknownText;
946 },
947
948 format_sdnzone_type: function(value, md, record) {
949 var schema = PVE.Utils.sdnzoneSchema[value];
950 if (schema) {
f3c1eac7 951 return schema.name;
9233148b
AD
952 }
953 return Proxmox.Utils.unknownText;
954 },
955
956 format_sdncontroller_type: function(value, md, record) {
957 var schema = PVE.Utils.sdncontrollerSchema[value];
958 if (schema) {
959 return schema.name;
960 }
961 return Proxmox.Utils.unknownText;
962 },
963
1d9643f6
AD
964 format_sdnipam_type: function(value, md, record) {
965 var schema = PVE.Utils.sdnipamSchema[value];
966 if (schema) {
967 return schema.name;
968 }
969 return Proxmox.Utils.unknownText;
970 },
971
972 format_sdndns_type: function(value, md, record) {
973 var schema = PVE.Utils.sdndnsSchema[value];
974 if (schema) {
975 return schema.name;
976 }
977 return Proxmox.Utils.unknownText;
978 },
979
3c23c025 980 format_storage_type: function(value, md, record) {
4a4b2b6e 981 if (value === 'rbd') {
53e3ea84 982 value = !record || record.get('monhost') ? 'rbd' : 'pveceph';
4a4b2b6e 983 } else if (value === 'cephfs') {
53e3ea84 984 value = !record || record.get('monhost') ? 'cephfs' : 'pvecephfs';
3c23c025 985 }
062a7f49 986
d0477f12
TL
987 let schema = PVE.Utils.storageSchema[value];
988 return schema?.name ?? value;
a3b8efb4
EK
989 },
990
ced1677b 991 format_ha: function(value) {
e7ade592 992 var text = Proxmox.Utils.noneText;
ced1677b
TL
993
994 if (value.managed) {
e7ade592 995 text = value.state || Proxmox.Utils.noneText;
ced1677b 996
8058410f 997 text += ', ' + Proxmox.Utils.groupText + ': ';
e7ade592 998 text += value.group || Proxmox.Utils.noneText;
ced1677b
TL
999 }
1000
1001 return text;
1002 },
1003
b0a6d326 1004 format_content_types: function(value) {
0e244a29
DC
1005 return value.split(',').sort().map(function(ct) {
1006 return PVE.Utils.contentTypes[ct] || ct;
1007 }).join(', ');
b0a6d326
EK
1008 },
1009
1010 render_storage_content: function(value, metaData, record) {
98cbec54
FW
1011 let data = record.data;
1012 let result;
b0a6d326
EK
1013 if (Ext.isNumber(data.channel) &&
1014 Ext.isNumber(data.id) &&
1015 Ext.isNumber(data.lun)) {
98cbec54 1016 result = "CH " +
f6710aac 1017 Ext.String.leftPad(data.channel, 2, '0') +
b0a6d326 1018 " ID " + data.id + " LUN " + data.lun;
98cbec54
FW
1019 } else {
1020 result = data.volid.replace(/^.*?:(.*?\/)?/, '');
b0a6d326 1021 }
98cbec54 1022 return Ext.String.htmlEncode(result);
b0a6d326
EK
1023 },
1024
8058410f 1025 render_serverity: function(value) {
b0a6d326
EK
1026 return PVE.Utils.log_severity_hash[value] || value;
1027 },
1028
a62ee730 1029 calculate_hostcpu: function(data) {
a62ee730
AD
1030 if (!(data.uptime && Ext.isNumeric(data.cpu))) {
1031 return -1;
1032 }
1033
1034 if (data.type !== 'qemu' && data.type !== 'lxc') {
1035 return -1;
1036 }
1037
1038 var index = PVE.data.ResourceStore.findExact('id', 'node/' + data.node);
1039 var node = PVE.data.ResourceStore.getAt(index);
1040 if (!Ext.isDefined(node) || node === null) {
1041 return -1;
1042 }
1043 var maxcpu = node.data.maxcpu || 1;
1044
1045 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
1046 return -1;
1047 }
1048
4d739f4a 1049 return (data.cpu/maxcpu) * data.maxcpu;
a62ee730
AD
1050 },
1051
1052 render_hostcpu: function(value, metaData, record, rowIndex, colIndex, store) {
a62ee730
AD
1053 if (!(record.data.uptime && Ext.isNumeric(record.data.cpu))) {
1054 return '';
1055 }
1056
1057 if (record.data.type !== 'qemu' && record.data.type !== 'lxc') {
1058 return '';
1059 }
1060
1061 var index = PVE.data.ResourceStore.findExact('id', 'node/' + record.data.node);
1062 var node = PVE.data.ResourceStore.getAt(index);
1063 if (!Ext.isDefined(node) || node === null) {
1064 return '';
1065 }
1066 var maxcpu = node.data.maxcpu || 1;
1067
1068 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
1069 return '';
1070 }
1071
1072 var per = (record.data.cpu/maxcpu) * record.data.maxcpu * 100;
1073
1074 return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
1075 },
1076
946730cd
DC
1077 render_bandwidth: function(value) {
1078 if (!Ext.isNumeric(value)) {
1079 return '';
1080 }
1081
e7ade592 1082 return Proxmox.Utils.format_size(value) + '/s';
b0a6d326
EK
1083 },
1084
3f633655
EK
1085 render_timestamp_human_readable: function(value) {
1086 return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
1087 },
1088
7ce62ab3
TL
1089 // render a timestamp or pending
1090 render_next_event: function(value) {
1091 if (!value) {
1092 return '-';
1093 }
1094 let now = new Date(), next = new Date(value * 1000);
1095 if (next < now) {
1096 return gettext('pending');
1097 }
1098 return Proxmox.Utils.render_timestamp(value);
1099 },
1100
0bfc799f
DC
1101 calculate_mem_usage: function(data) {
1102 if (!Ext.isNumeric(data.mem) ||
1103 data.maxmem === 0 ||
1104 data.uptime < 1) {
1105 return -1;
1106 }
1107
53e3ea84 1108 return data.mem / data.maxmem;
0bfc799f
DC
1109 },
1110
a62ee730 1111 calculate_hostmem_usage: function(data) {
a62ee730
AD
1112 if (data.type !== 'qemu' && data.type !== 'lxc') {
1113 return -1;
1114 }
1115
1116 var index = PVE.data.ResourceStore.findExact('id', 'node/' + data.node);
1117 var node = PVE.data.ResourceStore.getAt(index);
1118
1119 if (!Ext.isDefined(node) || node === null) {
1120 return -1;
1121 }
1122 var maxmem = node.data.maxmem || 0;
1123
1124 if (!Ext.isNumeric(data.mem) ||
1125 maxmem === 0 ||
1126 data.uptime < 1) {
1127 return -1;
1128 }
1129
4d739f4a 1130 return data.mem / maxmem;
a62ee730
AD
1131 },
1132
0bfc799f
DC
1133 render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
1134 if (!Ext.isNumeric(value) || value === -1) {
1135 return '';
1136 }
8058410f 1137 if (value > 1) {
0bfc799f
DC
1138 // we got no percentage but bytes
1139 var mem = value;
1140 var maxmem = record.data.maxmem;
1141 if (!record.data.uptime ||
1142 maxmem === 0 ||
1143 !Ext.isNumeric(mem)) {
1144 return '';
1145 }
1146
53e3ea84 1147 return (mem*100/maxmem).toFixed(1) + " %";
0bfc799f
DC
1148 }
1149 return (value*100).toFixed(1) + " %";
1150 },
1151
a62ee730 1152 render_hostmem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
a62ee730
AD
1153 if (!Ext.isNumeric(record.data.mem) || value === -1) {
1154 return '';
1155 }
1156
1157 if (record.data.type !== 'qemu' && record.data.type !== 'lxc') {
1158 return '';
1159 }
1160
1161 var index = PVE.data.ResourceStore.findExact('id', 'node/' + record.data.node);
1162 var node = PVE.data.ResourceStore.getAt(index);
1163 var maxmem = node.data.maxmem || 0;
1164
4d739f4a 1165 if (record.data.mem > 1) {
a62ee730
AD
1166 // we got no percentage but bytes
1167 var mem = record.data.mem;
1168 if (!record.data.uptime ||
1169 maxmem === 0 ||
1170 !Ext.isNumeric(mem)) {
1171 return '';
1172 }
1173
1174 return ((mem*100)/maxmem).toFixed(1) + " %";
1175 }
1176 return (value*100).toFixed(1) + " %";
1177 },
1178
b0a6d326 1179 render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
b0a6d326
EK
1180 var mem = value;
1181 var maxmem = record.data.maxmem;
0be88ae1 1182
b0a6d326
EK
1183 if (!record.data.uptime) {
1184 return '';
1185 }
1186
1187 if (!(Ext.isNumeric(mem) && maxmem)) {
1188 return '';
1189 }
1190
1bd7bcdb 1191 return Proxmox.Utils.render_size(value);
b0a6d326
EK
1192 },
1193
0bfc799f 1194 calculate_disk_usage: function(data) {
0bfc799f 1195 if (!Ext.isNumeric(data.disk) ||
4d739f4a
TL
1196 ((data.type === 'qemu' || data.type === 'lxc') && data.uptime === 0) ||
1197 data.maxdisk === 0
1198 ) {
0bfc799f
DC
1199 return -1;
1200 }
1201
53e3ea84 1202 return data.disk / data.maxdisk;
0bfc799f
DC
1203 },
1204
1205 render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
1206 if (!Ext.isNumeric(value) || value === -1) {
1207 return '';
1208 }
1209
1210 return (value * 100).toFixed(1) + " %";
1211 },
1212
b0a6d326 1213 render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
b0a6d326
EK
1214 var disk = value;
1215 var maxdisk = record.data.maxdisk;
728f1b97 1216 var type = record.data.type;
b0a6d326 1217
728f1b97 1218 if (!Ext.isNumeric(disk) ||
728f1b97 1219 maxdisk === 0 ||
4d739f4a
TL
1220 ((type === 'qemu' || type === 'lxc') && record.data.uptime === 0)
1221 ) {
b0a6d326
EK
1222 return '';
1223 }
1224
1bd7bcdb 1225 return Proxmox.Utils.render_size(value);
b0a6d326
EK
1226 },
1227
4dbc64a7
DC
1228 get_object_icon_class: function(type, record) {
1229 var status = '';
1230 var objType = type;
1231
1232 if (type === 'type') {
1233 // for folder view
1234 objType = record.groupbyid;
1235 } else if (record.template) {
1236 // templates
1237 objType = 'template';
1238 status = type;
1239 } else {
1240 // everything else
1241 status = record.status + ' ha-' + record.hastate;
b1d8e73d
DC
1242 }
1243
6284a48a
DC
1244 if (record.lock) {
1245 status += ' locked lock-' + record.lock;
1246 }
1247
4dbc64a7
DC
1248 var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
1249 if (defaults && defaults.iconCls) {
1250 var retVal = defaults.iconCls + ' ' + status;
1251 return retVal;
b0a6d326
EK
1252 }
1253
4dbc64a7
DC
1254 return '';
1255 },
1256
1257 render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
f6710aac 1258 var cls = PVE.Utils.get_object_icon_class(value, record.data);
2b2fe160 1259
8058410f 1260 var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
b1d8e73d 1261 return fa + value;
b0a6d326
EK
1262 },
1263
b0a6d326
EK
1264 render_support_level: function(value, metaData, record) {
1265 return PVE.Utils.support_level_hash[value] || '-';
1266 },
1267
0be88ae1 1268 render_upid: function(value, metaData, record) {
b0a6d326
EK
1269 var type = record.data.type;
1270 var id = record.data.id;
1271
e7ade592 1272 return Proxmox.Utils.format_task_description(type, id);
b0a6d326
EK
1273 },
1274
27809975 1275 render_optional_url: function(value) {
4d739f4a 1276 if (value && value.match(/^https?:\/\//)) {
cdd9b6c0 1277 return '<a target="_blank" href="' + value + '">' + value + '</a>';
27809975
DC
1278 }
1279 return value;
1280 },
1281
1282 render_san: function(value) {
1283 var names = [];
1284 if (Ext.isArray(value)) {
1285 value.forEach(function(val) {
1286 if (!Ext.isNumber(val)) {
1287 names.push(val);
1288 }
1289 });
1290 return names.join('<br>');
1291 }
1292 return value;
1293 },
1294
6ad4be69
DC
1295 render_full_name: function(firstname, metaData, record) {
1296 var first = firstname || '';
1297 var last = record.data.lastname || '';
1298 return Ext.htmlEncode(first + " " + last);
1299 },
1300
fe5c4f81
AL
1301 // expecting the following format:
1302 // [v2:10.10.10.1:6802/2008,v1:10.10.10.1:6803/2008]
1303 render_ceph_osd_addr: function(value) {
1304 value = value.trim();
1305 if (value.startsWith('[') && value.endsWith(']')) {
1306 value = value.slice(1, -1); // remove []
1307 }
1308 value = value.replaceAll(',', '\n'); // split IPs in lines
1309 let retVal = '';
1310 for (const i of value.matchAll(/^(v[0-9]):(.*):([0-9]*)\/([0-9]*)$/gm)) {
1311 retVal += `${i[1]}: ${i[2]}:${i[3]}<br>`;
1312 }
1313 return retVal.length < 1 ? value : retVal;
1314 },
1315
aa0819a8 1316 windowHostname: function() {
e7ade592 1317 return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
aa0819a8
WB
1318 function(m, addr, offset, original) { return addr; });
1319 },
0be88ae1 1320
953f6e9b 1321 openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) {
8aac63a5 1322 var dv = PVE.Utils.defaultViewer(consoles, consoleType);
953f6e9b 1323 PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd);
b0a6d326
EK
1324 },
1325
953f6e9b 1326 openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) {
4d739f4a 1327 if (vmid === undefined && (consoleType === 'kvm' || consoleType === 'lxc')) {
b0a6d326
EK
1328 throw "missing vmid";
1329 }
b0a6d326
EK
1330 if (!nodename) {
1331 throw "no nodename specified";
1332 }
1333
c7218ab3 1334 if (viewer === 'html5') {
953f6e9b 1335 PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd);
c6b2336c 1336 } else if (viewer === 'xtermjs') {
953f6e9b 1337 Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd);
b0a6d326 1338 } else if (viewer === 'vv') {
953f6e9b
TL
1339 let url = '/nodes/' + nodename + '/spiceshell';
1340 let params = {
1341 proxy: PVE.Utils.windowHostname(),
1342 };
1343 if (consoleType === 'kvm') {
b0a6d326 1344 url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
953f6e9b 1345 } else if (consoleType === 'lxc') {
9e361643 1346 url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
953f6e9b
TL
1347 } else if (consoleType === 'upgrade') {
1348 params.cmd = 'upgrade';
1349 } else if (consoleType === 'cmd') {
8eccc68f 1350 params.cmd = cmd;
953f6e9b
TL
1351 } else if (consoleType !== 'shell') {
1352 throw `unknown spice viewer type '${consoleType}'`;
b0a6d326 1353 }
953f6e9b 1354 PVE.Utils.openSpiceViewer(url, params);
b0a6d326 1355 } else {
953f6e9b 1356 throw `unknown viewer type '${viewer}'`;
b0a6d326
EK
1357 }
1358 },
1359
8aac63a5 1360 defaultViewer: function(consoles, type) {
3438c27e
DC
1361 var allowSpice, allowXtermjs;
1362
1363 if (consoles === true) {
1364 allowSpice = true;
1365 allowXtermjs = true;
1366 } else if (typeof consoles === 'object') {
1367 allowSpice = consoles.spice;
4ace5c6f 1368 allowXtermjs = !!consoles.xtermjs;
3438c27e 1369 }
731436ee 1370 let dv = PVE.UIOptions.options.console || (type === 'kvm' ? 'vv' : 'xtermjs');
f932cffa 1371 if (dv === 'vv' && !allowSpice) {
53e3ea84 1372 dv = allowXtermjs ? 'xtermjs' : 'html5';
f932cffa 1373 } else if (dv === 'xtermjs' && !allowXtermjs) {
53e3ea84 1374 dv = allowSpice ? 'vv' : 'html5';
b0a6d326
EK
1375 }
1376
1377 return dv;
1378 },
1379
8eccc68f 1380 openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
af89f682
TL
1381 let scaling = 'off';
1382 if (Proxmox.Utils.toolkit !== 'touch') {
1383 var sp = Ext.state.Manager.getProvider();
1384 scaling = sp.get('novnc-scaling', 'off');
1385 }
8eccc68f 1386 var url = Ext.Object.toQueryString({
9e361643 1387 console: vmtype, // kvm, lxc, upgrade or shell
c7218ab3 1388 novnc: 1,
b0a6d326
EK
1389 vmid: vmid,
1390 vmname: vmname,
16e64c97 1391 node: nodename,
af89f682 1392 resize: scaling,
f6710aac 1393 cmd: cmd,
b0a6d326
EK
1394 });
1395 var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
7af1ab47
DC
1396 if (nw) {
1397 nw.focus();
1398 }
b0a6d326
EK
1399 },
1400
8058410f 1401 openSpiceViewer: function(url, params) {
b0a6d326
EK
1402 var downloadWithName = function(uri, name) {
1403 var link = Ext.DomHelper.append(document.body, {
1404 tag: 'a',
1405 href: uri,
8058410f 1406 css: 'display:none;visibility:hidden;height:0px;',
b0a6d326
EK
1407 });
1408
e8ed907b
MF
1409 // Note: we need to tell Android, AppleWebKit and Chrome
1410 // the correct file name extension
b0a6d326
EK
1411 // but we do not set 'download' tag for other environments, because
1412 // It can have strange side effects (additional user prompt on firefox)
e8ed907b 1413 if (navigator.userAgent.match(/Android|AppleWebKit|Chrome/i)) {
b0a6d326
EK
1414 link.download = name;
1415 }
1416
1417 if (link.fireEvent) {
1418 link.fireEvent('onclick');
1419 } else {
953f6e9b
TL
1420 let evt = document.createEvent("MouseEvents");
1421 evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
b0a6d326
EK
1422 link.dispatchEvent(evt);
1423 }
1424 };
1425
e7ade592 1426 Proxmox.Utils.API2Request({
b0a6d326
EK
1427 url: url,
1428 params: params,
1429 method: 'POST',
8058410f 1430 failure: function(response, opts) {
b0a6d326
EK
1431 Ext.Msg.alert('Error', response.htmlStatus);
1432 },
8058410f 1433 success: function(response, opts) {
4d739f4a
TL
1434 let cfg = response.result.data;
1435 let raw = Object.entries(cfg).reduce((acc, [k, v]) => acc + `${k}=${v}\n`, "[virt-viewer]\n");
1436 let spiceDownload = 'data:application/x-virt-viewer;charset=UTF-8,' + encodeURIComponent(raw);
1437 downloadWithName(spiceDownload, "pve-spice.vv");
f6710aac 1438 },
b0a6d326
EK
1439 });
1440 },
1441
e3129443
DC
1442 openTreeConsole: function(tree, record, item, index, e) {
1443 e.stopEvent();
4d739f4a
TL
1444 let nodename = record.data.node;
1445 let vmid = record.data.vmid;
1446 let vmname = record.data.name;
e3129443 1447 if (record.data.type === 'qemu' && !record.data.template) {
e7ade592 1448 Proxmox.Utils.API2Request({
4d739f4a
TL
1449 url: `/nodes/${nodename}/qemu/${vmid}/status/current`,
1450 failure: response => Ext.Msg.alert('Error', response.htmlStatus),
e3129443 1451 success: function(response, opts) {
bd9537d7 1452 let conf = response.result.data;
4d739f4a 1453 let consoles = {
bd9537d7
TL
1454 spice: !!conf.spice,
1455 xtermjs: !!conf.serial,
54453c38
DC
1456 };
1457 PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
f6710aac 1458 },
e3129443
DC
1459 });
1460 } else if (record.data.type === 'lxc' && !record.data.template) {
1461 PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
1462 }
1463 },
1464
fbd60cfd
DM
1465 // test automation helper
1466 call_menu_handler: function(menu, text) {
4d739f4a
TL
1467 let item = menu.query('menuitem').find(el => el.text === text);
1468 if (item && item.handler) {
1469 item.handler();
1470 }
fbd60cfd
DM
1471 },
1472
685b7aa4
DC
1473 createCmdMenu: function(v, record, item, index, event) {
1474 event.stopEvent();
cc1a91be
DC
1475 if (!(v instanceof Ext.tree.View)) {
1476 v.select(record);
1477 }
4d739f4a
TL
1478 let menu;
1479 let type = record.data.type;
685b7aa4 1480
4d739f4a
TL
1481 if (record.data.template) {
1482 if (type === 'qemu' || type === 'lxc') {
9bad05bd 1483 menu = Ext.create('PVE.menu.TemplateMenu', {
f6710aac 1484 pveSelNode: record,
9bad05bd
DC
1485 });
1486 }
4d739f4a 1487 } else if (type === 'qemu' || type === 'lxc' || type === 'node') {
9bad05bd
DC
1488 menu = Ext.create('PVE.' + type + '.CmdMenu', {
1489 pveSelNode: record,
f6710aac 1490 nodename: record.data.node,
c11ab8cb 1491 });
685b7aa4 1492 } else {
4d739f4a 1493 return undefined;
685b7aa4
DC
1494 }
1495
1496 menu.showAt(event.getXY());
9f0b4e04 1497 return menu;
e7ade592 1498 },
9fa2e36d 1499
fe4f00ad
TL
1500 // helper for deleting field which are set to there default values
1501 delete_if_default: function(values, fieldname, default_val, create) {
1502 if (values[fieldname] === '' || values[fieldname] === default_val) {
1503 if (!create) {
399ffa76
TL
1504 if (values.delete) {
1505 if (Ext.isArray(values.delete)) {
1506 values.delete.push(fieldname);
2db8e90d 1507 } else {
399ffa76 1508 values.delete += ',' + fieldname;
2db8e90d 1509 }
fe4f00ad 1510 } else {
399ffa76 1511 values.delete = fieldname;
fe4f00ad
TL
1512 }
1513 }
1514
1515 delete values[fieldname];
1516 }
857b97a7
TL
1517 },
1518
1519 loadSSHKeyFromFile: function(file, callback) {
37f2e82c
TL
1520 // ssh-keygen produces ~ 740 bytes for a 4096 bit RSA key, current max is 16 kbit, so assume:
1521 // 740 * 8 for max. 32kbit (5920 bytes), round upwards to 8192 bytes, leaves lots of comment space
1522 PVE.Utils.loadFile(file, callback, 8192);
1523 },
1524
1525 loadFile: function(file, callback, maxSize) {
1526 maxSize = maxSize || 32 * 1024;
1527 if (file.size > maxSize) {
1528 Ext.Msg.alert(gettext('Error'), `${gettext("Invalid file size")}: ${file.size} > ${maxSize}`);
857b97a7
TL
1529 return;
1530 }
4d739f4a 1531 let reader = new FileReader();
37f2e82c 1532 reader.onload = evt => callback(evt.target.result);
857b97a7 1533 reader.readAsText(file);
abe824aa
DC
1534 },
1535
7dda153c
TL
1536 loadTextFromFile: function(file, callback, maxBytes) {
1537 let maxSize = maxBytes || 8192;
1538 if (file.size > maxSize) {
1539 Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
1540 return;
1541 }
7dda153c
TL
1542 let reader = new FileReader();
1543 reader.onload = evt => callback(evt.target.result);
1544 reader.readAsText(file);
1545 },
1546
8c4ec8c7
TL
1547 diskControllerMaxIDs: {
1548 ide: 4,
1549 sata: 6,
cf0d139e 1550 scsi: 31,
8c4ec8c7 1551 virtio: 16,
7b14d77a 1552 unused: 256,
8c4ec8c7 1553 },
abe824aa
DC
1554
1555 // types is either undefined (all busses), an array of busses, or a single bus
1556 forEachBus: function(types, func) {
4d739f4a 1557 let busses = Object.keys(PVE.Utils.diskControllerMaxIDs);
abe824aa
DC
1558
1559 if (Ext.isArray(types)) {
1560 busses = types;
1561 } else if (Ext.isDefined(types)) {
8058410f 1562 busses = [types];
abe824aa
DC
1563 }
1564
1565 // check if we only have valid busses
4d739f4a 1566 for (let i = 0; i < busses.length; i++) {
8c4ec8c7 1567 if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) {
abe824aa
DC
1568 throw "invalid bus: '" + busses[i] + "'";
1569 }
1570 }
1571
4d739f4a
TL
1572 for (let i = 0; i < busses.length; i++) {
1573 let count = PVE.Utils.diskControllerMaxIDs[busses[i]];
1574 for (let j = 0; j < count; j++) {
1575 let cont = func(busses[i], j);
abe824aa
DC
1576 if (!cont && cont !== undefined) {
1577 return;
1578 }
1579 }
1580 }
14a845bc
DC
1581 },
1582
4d739f4a 1583 mp_counts: {
5747fef3 1584 mp: 256,
4d739f4a
TL
1585 unused: 256,
1586 },
14a845bc
DC
1587
1588 forEachMP: function(func, includeUnused) {
5747fef3 1589 for (let i = 0; i < PVE.Utils.mp_counts.mp; i++) {
4d739f4a 1590 let cont = func('mp', i);
14a845bc
DC
1591 if (!cont && cont !== undefined) {
1592 return;
1593 }
1594 }
1595
1596 if (!includeUnused) {
1597 return;
1598 }
1599
4d739f4a
TL
1600 for (let i = 0; i < PVE.Utils.mp_counts.unused; i++) {
1601 let cont = func('unused', i);
14a845bc
DC
1602 if (!cont && cont !== undefined) {
1603 return;
1604 }
1605 }
b945c7c1
TM
1606 },
1607
17dcba38
DC
1608 hardware_counts: {
1609 net: 32,
1610 usb: 14,
1611 usb_old: 5,
1612 hostpci: 16,
1613 audio: 1,
1614 efidisk: 1,
1615 serial: 4,
1616 rng: 1,
1617 tpmstate: 1,
1618 },
1619
1620 // we can have usb6 and up only for specific machine/ostypes
1621 get_max_usb_count: function(ostype, machine) {
1622 if (!ostype) {
1623 return PVE.Utils.hardware_counts.usb_old;
1624 }
1625
1626 let match = /-(\d+).(\d+)/.exec(machine ?? '');
1627 if (!match || PVE.Utils.qemu_min_version([match[1], match[2]], [7, 1])) {
1628 if (ostype === 'l26') {
1629 return PVE.Utils.hardware_counts.usb;
1630 }
1631 let os_match = /^win(\d+)$/.exec(ostype);
1632 if (os_match && os_match[1] > 7) {
1633 return PVE.Utils.hardware_counts.usb;
1634 }
1635 }
1636
1637 return PVE.Utils.hardware_counts.usb_old;
1638 },
1639
1640 // parameters are expected to be arrays, e.g. [7,1], [4,0,1]
1641 // returns true if toCheck is equal or greater than minVersion
1642 qemu_min_version: function(toCheck, minVersion) {
1643 let i;
1644 for (i = 0; i < toCheck.length && i < minVersion.length; i++) {
1645 if (toCheck[i] < minVersion[i]) {
1646 return false;
1647 }
1648 }
1649
1650 if (minVersion.length > toCheck.length) {
1651 for (; i < minVersion.length; i++) {
1652 if (minVersion[i] !== 0) {
1653 return false;
1654 }
1655 }
1656 }
1657
1658 return true;
1659 },
9d855398 1660
8058410f 1661 cleanEmptyObjectKeys: function(obj) {
4d739f4a
TL
1662 for (const propName of Object.keys(obj)) {
1663 if (obj[propName] === null || obj[propName] === undefined) {
1664 delete obj[propName];
b945c7c1
TM
1665 }
1666 }
4616a55b
TM
1667 },
1668
eadbbb4a
DC
1669 acmedomain_count: 5,
1670
1671 add_domain_to_acme: function(acme, domain) {
1672 if (acme.domains === undefined) {
1673 acme.domains = [domain];
1674 } else {
1675 acme.domains.push(domain);
8058410f 1676 acme.domains = acme.domains.filter((value, index, self) => self.indexOf(value) === index);
eadbbb4a
DC
1677 }
1678 return acme;
1679 },
1680
1681 remove_domain_from_acme: function(acme, domain) {
1682 if (acme.domains !== undefined) {
4d739f4a
TL
1683 acme.domains = acme
1684 .domains
1685 .filter((value, index, self) => self.indexOf(value) === index && value !== domain);
eadbbb4a
DC
1686 }
1687 return acme;
1688 },
1689
4d739f4a
TL
1690 handleStoreErrorOrMask: function(view, store, regex, callback) {
1691 view.mon(store, 'load', function(proxy, response, success, operation) {
4616a55b 1692 if (success) {
4d739f4a 1693 Proxmox.Utils.setErrorMask(view, false);
4616a55b
TM
1694 return;
1695 }
4d739f4a 1696 let msg;
4616a55b
TM
1697 if (operation.error.statusText) {
1698 if (operation.error.statusText.match(regex)) {
4d739f4a 1699 callback(view, operation.error);
4616a55b
TM
1700 return;
1701 } else {
1702 msg = operation.error.statusText + ' (' + operation.error.status + ')';
1703 }
1704 } else {
1705 msg = gettext('Connection error');
1706 }
4d739f4a 1707 Proxmox.Utils.setErrorMask(view, msg);
4616a55b
TM
1708 });
1709 },
1710
8058410f 1711 showCephInstallOrMask: function(container, msg, nodename, callback) {
13786fb0 1712 if (msg.match(/not (installed|initialized)/i)) {
4616a55b
TM
1713 if (Proxmox.UserName === 'root@pam') {
1714 container.el.mask();
8058410f 1715 if (!container.down('pveCephInstallWindow')) {
ef725143 1716 var isInstalled = !!msg.match(/not initialized/i);
4616a55b 1717 var win = Ext.create('PVE.ceph.Install', {
f6710aac 1718 nodename: nodename,
4616a55b 1719 });
f992ef80 1720 win.getViewModel().set('isInstalled', isInstalled);
4616a55b 1721 container.add(win);
19f703e2
DC
1722 win.on('close', () => {
1723 container.el.unmask();
1724 });
4616a55b
TM
1725 win.show();
1726 callback(win);
1727 }
1728 } else {
a7e8b87b
TL
1729 container.mask(Ext.String.format(gettext('{0} not installed.') +
1730 ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
4616a55b
TM
1731 }
1732 return true;
1733 } else {
1734 return false;
1735 }
49dfba72
DC
1736 },
1737
13786fb0
TL
1738 monitor_ceph_installed: function(view, rstore, nodename, maskOwnerCt) {
1739 PVE.Utils.handleStoreErrorOrMask(
1740 view,
1741 rstore,
1742 /not (installed|initialized)/i,
1743 (_, error) => {
c2175df2 1744 nodename = nodename || Proxmox.NodeName;
13786fb0
TL
1745 let maskTarget = maskOwnerCt ? view.ownerCt : view;
1746 rstore.stopUpdate();
1747 PVE.Utils.showCephInstallOrMask(maskTarget, error.statusText, nodename, win => {
1748 view.mon(win, 'cephInstallWindowClosed', () => rstore.startUpdate());
1749 });
1750 },
1751 );
1752 },
1753
1754
49dfba72
DC
1755 propertyStringSet: function(target, source, name, value) {
1756 if (source) {
1757 if (value === undefined) {
1758 target[name] = source;
1759 } else {
1760 target[name] = value;
1761 }
1762 } else {
1763 delete target[name];
1764 }
bbc83309
DC
1765 },
1766
e65817a1
SR
1767 forEachCorosyncLink: function(nodeinfo, cb) {
1768 let re = /(?:ring|link)(\d+)_addr/;
1769 Ext.iterate(nodeinfo, (prop, val) => {
1770 let match = re.exec(prop);
1771 if (match) {
1772 cb(Number(match[1]), val);
1773 }
1774 });
1775 },
4546808c
SR
1776
1777 cpu_vendor_map: {
1778 'default': 'QEMU',
1779 'AuthenticAMD': 'AMD',
f6710aac 1780 'GenuineIntel': 'Intel',
4546808c
SR
1781 },
1782
1783 cpu_vendor_order: {
1784 "AMD": 1,
1785 "Intel": 2,
1786 "QEMU": 3,
1787 "Host": 4,
1788 "_default_": 5, // includes custom models
1789 },
5865b597
WB
1790
1791 verify_ip64_address_list: function(value, with_suffix) {
1792 for (let addr of value.split(/[ ,;]+/)) {
1793 if (addr === '') {
1794 continue;
1795 }
1796
1797 if (with_suffix) {
1798 let parts = addr.split('%');
1799 addr = parts[0];
1800
1801 if (parts.length > 2) {
1802 return false;
1803 }
1804
1805 if (parts.length > 1 && !addr.startsWith('fe80:')) {
1806 return false;
1807 }
1808 }
1809
1810 if (!Proxmox.Utils.IP64_match.test(addr)) {
1811 return false;
1812 }
1813 }
1814
1815 return true;
1816 },
2aa645da
DC
1817
1818 sortByPreviousUsage: function(vmconfig, controllerList) {
1819 if (!controllerList) {
1820 controllerList = ['ide', 'virtio', 'scsi', 'sata'];
1821 }
1822 let usedControllers = {};
1823 for (const type of Object.keys(PVE.Utils.diskControllerMaxIDs)) {
1824 usedControllers[type] = 0;
1825 }
1826
1827 for (const property of Object.keys(vmconfig)) {
1828 if (property.match(PVE.Utils.bus_match) && !vmconfig[property].match(/media=cdrom/)) {
1829 const foundController = property.match(PVE.Utils.bus_match)[1];
1830 usedControllers[foundController]++;
1831 }
1832 }
1833
1834 let sortPriority = PVE.qemu.OSDefaults.getDefaults(vmconfig.ostype).busPriority;
1835
1836 let sortedList = Ext.clone(controllerList);
1837 sortedList.sort(function(a, b) {
1838 if (usedControllers[b] === usedControllers[a]) {
1839 return sortPriority[b] - sortPriority[a];
1840 }
1841 return usedControllers[b] - usedControllers[a];
1842 });
1843
1844 return sortedList;
1845 },
1846
1847 nextFreeDisk: function(controllers, config) {
1848 for (const controller of controllers) {
1849 for (let i = 0; i < PVE.Utils.diskControllerMaxIDs[controller]; i++) {
1850 let confid = controller + i.toString();
1851 if (!Ext.isDefined(config[confid])) {
1852 return {
1853 controller,
1854 id: i,
1855 confid,
1856 };
1857 }
1858 }
1859 }
1860
1861 return undefined;
1862 },
000b5537
AL
1863
1864 nextFreeMP: function(type, config) {
1865 for (let i = 0; i < PVE.Utils.mp_counts[type]; i++) {
1866 let confid = `${type}${i}`;
1867 if (!Ext.isDefined(config[confid])) {
1868 return {
1869 type,
1870 id: i,
1871 confid,
1872 };
1873 }
1874 }
1875
1876 return undefined;
1877 },
7c8ff459
FE
1878
1879 escapeNotesTemplate: function(value) {
1880 let replace = {
1881 '\\': '\\\\',
1882 '\n': '\\n',
1883 };
1884 return value.replace(/(\\|[\n])/g, match => replace[match]);
1885 },
1886
1887 unEscapeNotesTemplate: function(value) {
1888 let replace = {
1889 '\\\\': '\\',
1890 '\\n': '\n',
1891 };
1892 return value.replace(/(\\\\|\\n)/g, match => replace[match]);
1893 },
03875d7a
FE
1894
1895 notesTemplateVars: ['cluster', 'guestname', 'node', 'vmid'],
b7f4cb7c 1896
0a627d94
DC
1897 renderTags: function(tagstext, overrides) {
1898 let text = '';
1899 if (tagstext) {
1900 let tags = (tagstext.split(/[,; ]/) || []).filter(t => !!t);
731436ee 1901 if (PVE.UIOptions.shouldSortTags()) {
13a0c8bf 1902 tags = tags.sort((a, b) => {
871953db
DC
1903 let alc = a.toLowerCase();
1904 let blc = b.toLowerCase();
1905 return alc < blc ? -1 : blc < alc ? 1 : a.localeCompare(b);
1906 });
8d8ba23d 1907 }
0a627d94
DC
1908 text += ' ';
1909 tags.forEach((tag) => {
1910 text += Proxmox.Utils.getTagElement(tag, overrides);
1911 });
1912 }
1913 return text;
1914 },
1915
59e71a08 1916 tagCharRegex: /^[a-z0-9+_.-]+$/i,
fdde857a
SH
1917
1918 verificationStateOrder: {
1919 'failed': 0,
1920 'none': 1,
1921 'ok': 2,
1922 '__default__': 3,
1923 },
01740cb2
DC
1924
1925 isStandaloneNode: function() {
1926 return PVE.data.ResourceStore.getNodes().length < 2;
1927 },
e7ade592 1928},
fe4f00ad 1929
9fa2e36d
EK
1930 singleton: true,
1931 constructor: function() {
1932 var me = this;
1933 Ext.apply(me, me.utilities);
d18e15dd
DC
1934
1935 Proxmox.Utils.override_task_descriptions({
1936 acmedeactivate: ['ACME Account', gettext('Deactivate')],
1937 acmenewcert: ['SRV', gettext('Order Certificate')],
1938 acmerefresh: ['ACME Account', gettext('Refresh')],
1939 acmeregister: ['ACME Account', gettext('Register')],
1940 acmerenew: ['SRV', gettext('Renew Certificate')],
1941 acmerevoke: ['SRV', gettext('Revoke Certificate')],
1942 acmeupdate: ['ACME Account', gettext('Update')],
1943 'auth-realm-sync': [gettext('Realm'), gettext('Sync')],
1944 'auth-realm-sync-test': [gettext('Realm'), gettext('Sync Preview')],
1945 cephcreatemds: ['Ceph Metadata Server', gettext('Create')],
1946 cephcreatemgr: ['Ceph Manager', gettext('Create')],
1947 cephcreatemon: ['Ceph Monitor', gettext('Create')],
1948 cephcreateosd: ['Ceph OSD', gettext('Create')],
1949 cephcreatepool: ['Ceph Pool', gettext('Create')],
1950 cephdestroymds: ['Ceph Metadata Server', gettext('Destroy')],
1951 cephdestroymgr: ['Ceph Manager', gettext('Destroy')],
1952 cephdestroymon: ['Ceph Monitor', gettext('Destroy')],
1953 cephdestroyosd: ['Ceph OSD', gettext('Destroy')],
1954 cephdestroypool: ['Ceph Pool', gettext('Destroy')],
02c1e98e 1955 cephdestroyfs: ['CephFS', gettext('Destroy')],
d18e15dd 1956 cephfscreate: ['CephFS', gettext('Create')],
f9f81a01
TL
1957 cephsetpool: ['Ceph Pool', gettext('Edit')],
1958 cephsetflags: ['', gettext('Change global Ceph flags')],
d18e15dd
DC
1959 clustercreate: ['', gettext('Create Cluster')],
1960 clusterjoin: ['', gettext('Join Cluster')],
1961 dircreate: [gettext('Directory Storage'), gettext('Create')],
1962 dirremove: [gettext('Directory'), gettext('Remove')],
79035e5a 1963 download: [gettext('File'), gettext('Download')],
d18e15dd
DC
1964 hamigrate: ['HA', gettext('Migrate')],
1965 hashutdown: ['HA', gettext('Shutdown')],
1966 hastart: ['HA', gettext('Start')],
1967 hastop: ['HA', gettext('Stop')],
1968 imgcopy: ['', gettext('Copy data')],
1969 imgdel: ['', gettext('Erase data')],
1970 lvmcreate: [gettext('LVM Storage'), gettext('Create')],
03c4aed8 1971 lvmremove: ['Volume Group', gettext('Remove')],
d18e15dd 1972 lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
03c4aed8 1973 lvmthinremove: ['Thinpool', gettext('Remove')],
2dac2140 1974 migrateall: ['', gettext('Bulk migrate VMs and Containers')],
d18e15dd 1975 'move_volume': ['CT', gettext('Move Volume')],
fe66076f 1976 'pbs-download': ['VM/CT', gettext('File Restore Download')],
d18e15dd
DC
1977 pull_file: ['CT', gettext('Pull file')],
1978 push_file: ['CT', gettext('Push file')],
1979 qmclone: ['VM', gettext('Clone')],
1980 qmconfig: ['VM', gettext('Configure')],
1981 qmcreate: ['VM', gettext('Create')],
1982 qmdelsnapshot: ['VM', gettext('Delete Snapshot')],
1983 qmdestroy: ['VM', gettext('Destroy')],
1984 qmigrate: ['VM', gettext('Migrate')],
1985 qmmove: ['VM', gettext('Move disk')],
1986 qmpause: ['VM', gettext('Pause')],
1987 qmreboot: ['VM', gettext('Reboot')],
1988 qmreset: ['VM', gettext('Reset')],
1989 qmrestore: ['VM', gettext('Restore')],
1990 qmresume: ['VM', gettext('Resume')],
1991 qmrollback: ['VM', gettext('Rollback')],
1992 qmshutdown: ['VM', gettext('Shutdown')],
1993 qmsnapshot: ['VM', gettext('Snapshot')],
1994 qmstart: ['VM', gettext('Start')],
1995 qmstop: ['VM', gettext('Stop')],
1996 qmsuspend: ['VM', gettext('Hibernate')],
1997 qmtemplate: ['VM', gettext('Convert to template')],
cce4b3d7 1998 resize: ['VM/CT', gettext('Resize')],
d18e15dd
DC
1999 spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
2000 spiceshell: ['', gettext('Shell') + ' (Spice)'],
2dac2140
FG
2001 startall: ['', gettext('Bulk start VMs and Containers')],
2002 stopall: ['', gettext('Bulk shutdown VMs and Containers')],
9ed1408b 2003 suspendall: ['', gettext('Suspend all VMs')],
d18e15dd 2004 unknownimgdel: ['', gettext('Destroy image from unknown guest')],
4d60651f 2005 wipedisk: ['Device', gettext('Wipe Disk')],
d18e15dd
DC
2006 vncproxy: ['VM/CT', gettext('Console')],
2007 vncshell: ['', gettext('Shell')],
2008 vzclone: ['CT', gettext('Clone')],
2009 vzcreate: ['CT', gettext('Create')],
2010 vzdelsnapshot: ['CT', gettext('Delete Snapshot')],
2011 vzdestroy: ['CT', gettext('Destroy')],
2012 vzdump: (type, id) => id ? `VM/CT ${id} - ${gettext('Backup')}` : gettext('Backup Job'),
2013 vzmigrate: ['CT', gettext('Migrate')],
2014 vzmount: ['CT', gettext('Mount')],
2015 vzreboot: ['CT', gettext('Reboot')],
2016 vzrestore: ['CT', gettext('Restore')],
2017 vzresume: ['CT', gettext('Resume')],
2018 vzrollback: ['CT', gettext('Rollback')],
2019 vzshutdown: ['CT', gettext('Shutdown')],
2020 vzsnapshot: ['CT', gettext('Snapshot')],
2021 vzstart: ['CT', gettext('Start')],
2022 vzstop: ['CT', gettext('Stop')],
2023 vzsuspend: ['CT', gettext('Suspend')],
2024 vztemplate: ['CT', gettext('Convert to template')],
2025 vzumount: ['CT', gettext('Unmount')],
2026 zfscreate: [gettext('ZFS Storage'), gettext('Create')],
03c4aed8 2027 zfsremove: ['ZFS Pool', gettext('Remove')],
d18e15dd 2028 });
f6710aac 2029 },
e7ade592 2030
9fa2e36d 2031});