]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/Utils.js
fix #3428: cloud-init: add toggle for automatic upgrades
[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
TL
36 noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit '
37 +'<a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">'
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
TL
485 displayText = map[value] || Proxmox.Utils.unknownText;
486 } else if (PVE.Parser.parseBoolean(value)) {
487 displayText = Proxmox.Utils.enabledText;
1662ccdb 488 }
4d739f4a
TL
489 agentstring += `, ${key}: ${displayText}`;
490 }
1662ccdb
SI
491
492 return agentstring;
493 },
494
a1ee14a2 495 render_qemu_machine: function(value) {
53e3ea84 496 return value || Proxmox.Utils.defaultText + ' (i440fx)';
a1ee14a2
DC
497 },
498
17c71f27
DC
499 render_qemu_bios: function(value) {
500 if (!value) {
e7ade592 501 return Proxmox.Utils.defaultText + ' (SeaBIOS)';
17c71f27
DC
502 } else if (value === 'seabios') {
503 return "SeaBIOS";
504 } else if (value === 'ovmf') {
505 return "OVMF (UEFI)";
506 } else {
507 return value;
508 }
509 },
510
8f17b496
TL
511 render_dc_ha_opts: function(value) {
512 if (!value) {
41ca3465 513 return Proxmox.Utils.defaultText;
8f17b496
TL
514 } else {
515 return PVE.Parser.printPropertyString(value);
516 }
517 },
afa725cd 518 render_as_property_string: v => !v ? Proxmox.Utils.defaultText : PVE.Parser.printPropertyString(v),
8f17b496 519
b0a6d326 520 render_scsihw: function(value) {
5ff69573 521 if (!value || value === '__default__') {
e7ade592 522 return Proxmox.Utils.defaultText + ' (LSI 53C895A)';
b0a6d326
EK
523 } else if (value === 'lsi') {
524 return 'LSI 53C895A';
525 } else if (value === 'lsi53c810') {
526 return 'LSI 53C810';
527 } else if (value === 'megasas') {
528 return 'MegaRAID SAS 8708EM2';
529 } else if (value === 'virtio-scsi-pci') {
49f5d1ab
EK
530 return 'VirtIO SCSI';
531 } else if (value === 'virtio-scsi-single') {
532 return 'VirtIO SCSI single';
b0a6d326
EK
533 } else if (value === 'pvscsi') {
534 return 'VMware PVSCSI';
535 } else {
536 return value;
537 }
538 },
539
9c22da32 540 render_spice_enhancements: function(values) {
9c22da32
AL
541 let props = PVE.Parser.parsePropertyString(values);
542 if (Ext.Object.isEmpty(props)) {
3b0facc9 543 return Proxmox.Utils.noneText;
9c22da32
AL
544 }
545
546 let output = [];
547 if (PVE.Parser.parseBoolean(props.foldersharing)) {
548 output.push('Folder Sharing: ' + gettext('Enabled'));
549 }
550 if (props.videostreaming === 'all' || props.videostreaming === 'filter') {
551 output.push('Video Streaming: ' + props.videostreaming);
552 }
553 return output.join(', ');
554 },
555
b0a6d326
EK
556 // fixme: auto-generate this
557 // for now, please keep in sync with PVE::Tools::kvmkeymaps
558 kvm_keymaps: {
b7004b46 559 '__default__': Proxmox.Utils.defaultText,
b0a6d326
EK
560 //ar: 'Arabic',
561 da: 'Danish',
0be88ae1
DC
562 de: 'German',
563 'de-ch': 'German (Swiss)',
564 'en-gb': 'English (UK)',
0a5b8747 565 'en-us': 'English (USA)',
b0a6d326
EK
566 es: 'Spanish',
567 //et: 'Estonia',
568 fi: 'Finnish',
0be88ae1
DC
569 //fo: 'Faroe Islands',
570 fr: 'French',
571 'fr-be': 'French (Belgium)',
b0a6d326
EK
572 'fr-ca': 'French (Canada)',
573 'fr-ch': 'French (Swiss)',
574 //hr: 'Croatia',
575 hu: 'Hungarian',
576 is: 'Icelandic',
0be88ae1 577 it: 'Italian',
b0a6d326
EK
578 ja: 'Japanese',
579 lt: 'Lithuanian',
580 //lv: 'Latvian',
0be88ae1 581 mk: 'Macedonian',
b0a6d326
EK
582 nl: 'Dutch',
583 //'nl-be': 'Dutch (Belgium)',
0be88ae1 584 no: 'Norwegian',
b0a6d326
EK
585 pl: 'Polish',
586 pt: 'Portuguese',
587 'pt-br': 'Portuguese (Brazil)',
588 //ru: 'Russian',
589 sl: 'Slovenian',
590 sv: 'Swedish',
591 //th: 'Thai',
f6710aac 592 tr: 'Turkish',
b0a6d326
EK
593 },
594
595 kvm_vga_drivers: {
b7004b46 596 '__default__': Proxmox.Utils.defaultText,
b0a6d326 597 std: gettext('Standard VGA'),
5ca366f2 598 vmware: gettext('VMware compatible'),
b0a6d326
EK
599 qxl: 'SPICE',
600 qxl2: 'SPICE dual monitor',
601 qxl3: 'SPICE three monitors',
602 qxl4: 'SPICE four monitors',
603 serial0: gettext('Serial terminal') + ' 0',
604 serial1: gettext('Serial terminal') + ' 1',
605 serial2: gettext('Serial terminal') + ' 2',
89ae1bb1
DC
606 serial3: gettext('Serial terminal') + ' 3',
607 virtio: 'VirtIO-GPU',
7d72d62f 608 'virtio-gl': 'VirGL GPU',
f6710aac 609 none: Proxmox.Utils.noneText,
b0a6d326
EK
610 },
611
8058410f 612 render_kvm_language: function(value) {
a8e22a83 613 if (!value || value === '__default__') {
e7ade592 614 return Proxmox.Utils.defaultText;
b0a6d326 615 }
b7004b46
TL
616 let text = PVE.Utils.kvm_keymaps[value];
617 return text ? `${text} (${value})` : value;
b0a6d326
EK
618 },
619
3438c27e 620 console_map: {
da9d14cd 621 '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
3438c27e
DC
622 'vv': 'SPICE (remote-viewer)',
623 'html5': 'HTML5 (noVNC)',
f6710aac 624 'xtermjs': 'xterm.js',
3438c27e
DC
625 },
626
b0a6d326 627 render_console_viewer: function(value) {
3438c27e 628 value = value || '__default__';
b7004b46 629 return PVE.Utils.console_map[value] || value;
755b9083
TL
630 },
631
8058410f 632 render_kvm_vga_driver: function(value) {
b0a6d326 633 if (!value) {
e7ade592 634 return Proxmox.Utils.defaultText;
b0a6d326 635 }
b7004b46
TL
636 let vga = PVE.Parser.parsePropertyString(value, 'type');
637 let text = PVE.Utils.kvm_vga_drivers[vga.type];
4f3e66d8
DC
638 if (!vga.type) {
639 text = Proxmox.Utils.defaultText;
640 }
b7004b46 641 return text ? `${text} (${value})` : value;
b0a6d326
EK
642 },
643
644 render_kvm_startup: function(value) {
645 var startup = PVE.Parser.parseStartup(value);
646
647 var res = 'order=';
648 if (startup.order === undefined) {
649 res += 'any';
650 } else {
651 res += startup.order;
652 }
653 if (startup.up !== undefined) {
654 res += ',up=' + startup.up;
655 }
656 if (startup.down !== undefined) {
657 res += ',down=' + startup.down;
658 }
659
660 return res;
661 },
662
b0a6d326
EK
663 extractFormActionError: function(action) {
664 var msg;
665 switch (action.failureType) {
666 case Ext.form.action.Action.CLIENT_INVALID:
667 msg = gettext('Form fields may not be submitted with invalid values');
668 break;
669 case Ext.form.action.Action.CONNECT_FAILURE:
670 msg = gettext('Connection error');
671 var resp = action.response;
672 if (resp.status && resp.statusText) {
673 msg += " " + resp.status + ": " + resp.statusText;
674 }
675 break;
676 case Ext.form.action.Action.LOAD_FAILURE:
677 case Ext.form.action.Action.SERVER_INVALID:
e7ade592 678 msg = Proxmox.Utils.extractRequestError(action.result, true);
b0a6d326
EK
679 break;
680 }
681 return msg;
682 },
683
0e244a29
DC
684 contentTypes: {
685 'images': gettext('Disk image'),
686 'backup': gettext('VZDump backup file'),
687 'vztmpl': gettext('Container template'),
688 'iso': gettext('ISO image'),
aef28e04 689 'rootdir': gettext('Container'),
f6710aac 690 'snippets': gettext('Snippets'),
0e244a29 691 },
b0a6d326 692
3b8f599b
DM
693 volume_is_qemu_backup: function(volid, format) {
694 return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-');
695 },
696
697 volume_is_lxc_backup: function(volid, format) {
698 return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
699 },
700
efff7eab
DC
701 authSchema: {
702 ad: {
703 name: gettext('Active Directory Server'),
704 ipanel: 'pveAuthADPanel',
822fb26d 705 syncipanel: 'pveAuthLDAPSyncPanel',
efff7eab 706 add: true,
550857eb 707 tfa: true,
60265958 708 pwchange: true,
efff7eab
DC
709 },
710 ldap: {
711 name: gettext('LDAP Server'),
712 ipanel: 'pveAuthLDAPPanel',
822fb26d 713 syncipanel: 'pveAuthLDAPSyncPanel',
efff7eab 714 add: true,
550857eb 715 tfa: true,
60265958 716 pwchange: true,
efff7eab 717 },
668951e2 718 openid: {
c42e3aa7 719 name: gettext('OpenID Connect Server'),
668951e2
DC
720 ipanel: 'pveAuthOpenIDPanel',
721 add: true,
722 tfa: false,
60265958 723 pwchange: false,
da25c5ac 724 iconCls: 'pmx-itype-icon-openid-logo',
668951e2 725 },
efff7eab
DC
726 pam: {
727 name: 'Linux PAM',
728 ipanel: 'pveAuthBasePanel',
729 add: false,
550857eb 730 tfa: true,
60265958 731 pwchange: true,
efff7eab
DC
732 },
733 pve: {
734 name: 'Proxmox VE authentication server',
735 ipanel: 'pveAuthBasePanel',
736 add: false,
f5ae7496 737 tfa: true,
60265958 738 pwchange: true,
efff7eab
DC
739 },
740 },
741
062a7f49
TL
742 storageSchema: {
743 dir: {
744 name: Proxmox.Utils.directoryText,
745 ipanel: 'DirInputPanel',
06c8315d
DC
746 faIcon: 'folder',
747 backups: true,
062a7f49
TL
748 },
749 lvm: {
750 name: 'LVM',
751 ipanel: 'LVMInputPanel',
06c8315d
DC
752 faIcon: 'folder',
753 backups: false,
062a7f49
TL
754 },
755 lvmthin: {
756 name: 'LVM-Thin',
757 ipanel: 'LvmThinInputPanel',
06c8315d
DC
758 faIcon: 'folder',
759 backups: false,
062a7f49 760 },
ffeb4f57
TL
761 btrfs: {
762 name: 'BTRFS',
763 ipanel: 'BTRFSInputPanel',
764 faIcon: 'folder',
765 backups: true,
766 },
062a7f49
TL
767 nfs: {
768 name: 'NFS',
769 ipanel: 'NFSInputPanel',
06c8315d
DC
770 faIcon: 'building',
771 backups: true,
062a7f49
TL
772 },
773 cifs: {
3266c03d 774 name: 'SMB/CIFS',
062a7f49 775 ipanel: 'CIFSInputPanel',
06c8315d
DC
776 faIcon: 'building',
777 backups: true,
062a7f49
TL
778 },
779 glusterfs: {
780 name: 'GlusterFS',
781 ipanel: 'GlusterFsInputPanel',
06c8315d
DC
782 faIcon: 'building',
783 backups: true,
062a7f49
TL
784 },
785 iscsi: {
786 name: 'iSCSI',
787 ipanel: 'IScsiInputPanel',
06c8315d
DC
788 faIcon: 'building',
789 backups: false,
062a7f49 790 },
4a4b2b6e
TL
791 cephfs: {
792 name: 'CephFS',
793 ipanel: 'CephFSInputPanel',
06c8315d
DC
794 faIcon: 'building',
795 backups: true,
4a4b2b6e
TL
796 },
797 pvecephfs: {
798 name: 'CephFS (PVE)',
799 ipanel: 'CephFSInputPanel',
800 hideAdd: true,
06c8315d
DC
801 faIcon: 'building',
802 backups: true,
4a4b2b6e 803 },
062a7f49
TL
804 rbd: {
805 name: 'RBD',
806 ipanel: 'RBDInputPanel',
06c8315d
DC
807 faIcon: 'building',
808 backups: false,
062a7f49
TL
809 },
810 pveceph: {
811 name: 'RBD (PVE)',
0d1ac958
TL
812 ipanel: 'RBDInputPanel',
813 hideAdd: true,
06c8315d
DC
814 faIcon: 'building',
815 backups: false,
062a7f49
TL
816 },
817 zfs: {
818 name: 'ZFS over iSCSI',
819 ipanel: 'ZFSInputPanel',
06c8315d
DC
820 faIcon: 'building',
821 backups: false,
062a7f49
TL
822 },
823 zfspool: {
824 name: 'ZFS',
825 ipanel: 'ZFSPoolInputPanel',
06c8315d
DC
826 faIcon: 'folder',
827 backups: false,
062a7f49 828 },
8b966034
TL
829 pbs: {
830 name: 'Proxmox Backup Server',
ee19d331
TL
831 ipanel: 'PBSInputPanel',
832 faIcon: 'floppy-o',
06c8315d 833 backups: true,
8b966034 834 },
062a7f49
TL
835 drbd: {
836 name: 'DRBD',
8b966034 837 hideAdd: true,
06c8315d 838 backups: false,
8b966034 839 },
062a7f49
TL
840 },
841
9233148b
AD
842 sdnvnetSchema: {
843 vnet: {
844 name: 'vnet',
f6710aac 845 faIcon: 'folder',
9233148b
AD
846 },
847 },
848
849 sdnzoneSchema: {
850 zone: {
851 name: 'zone',
f6710aac 852 hideAdd: true,
9233148b 853 },
1b4cce60
AD
854 simple: {
855 name: 'Simple',
856 ipanel: 'SimpleInputPanel',
f6710aac 857 faIcon: 'th',
1b4cce60 858 },
9233148b 859 vlan: {
f3c1eac7 860 name: 'VLAN',
9233148b 861 ipanel: 'VlanInputPanel',
f6710aac 862 faIcon: 'th',
9233148b
AD
863 },
864 qinq: {
f3c1eac7 865 name: 'QinQ',
9233148b 866 ipanel: 'QinQInputPanel',
f6710aac 867 faIcon: 'th',
9233148b
AD
868 },
869 vxlan: {
f3c1eac7 870 name: 'VXLAN',
9233148b 871 ipanel: 'VxlanInputPanel',
f6710aac 872 faIcon: 'th',
9233148b
AD
873 },
874 evpn: {
f3c1eac7 875 name: 'EVPN',
9233148b 876 ipanel: 'EvpnInputPanel',
f6710aac 877 faIcon: 'th',
9233148b
AD
878 },
879 },
880
881 sdncontrollerSchema: {
882 controller: {
883 name: 'controller',
f6710aac 884 hideAdd: true,
9233148b
AD
885 },
886 evpn: {
887 name: 'evpn',
888 ipanel: 'EvpnInputPanel',
f6710aac 889 faIcon: 'crosshairs',
9233148b 890 },
1d9643f6
AD
891 bgp: {
892 name: 'bgp',
893 ipanel: 'BgpInputPanel',
4d739f4a 894 faIcon: 'crosshairs',
1d9643f6
AD
895 },
896 },
897
898 sdnipamSchema: {
899 ipam: {
900 name: 'ipam',
4d739f4a 901 hideAdd: true,
1d9643f6
AD
902 },
903 pve: {
904 name: 'PVE',
905 ipanel: 'PVEIpamInputPanel',
906 faIcon: 'th',
4d739f4a 907 hideAdd: true,
1d9643f6
AD
908 },
909 netbox: {
910 name: 'Netbox',
911 ipanel: 'NetboxInputPanel',
4d739f4a 912 faIcon: 'th',
1d9643f6
AD
913 },
914 phpipam: {
915 name: 'PhpIpam',
916 ipanel: 'PhpIpamInputPanel',
4d739f4a 917 faIcon: 'th',
1d9643f6
AD
918 },
919 },
920
921 sdndnsSchema: {
922 dns: {
923 name: 'dns',
4d739f4a 924 hideAdd: true,
1d9643f6
AD
925 },
926 powerdns: {
927 name: 'powerdns',
928 ipanel: 'PowerdnsInputPanel',
4d739f4a 929 faIcon: 'th',
1d9643f6 930 },
9233148b
AD
931 },
932
933 format_sdnvnet_type: function(value, md, record) {
934 var schema = PVE.Utils.sdnvnetSchema[value];
935 if (schema) {
936 return schema.name;
937 }
938 return Proxmox.Utils.unknownText;
939 },
940
941 format_sdnzone_type: function(value, md, record) {
942 var schema = PVE.Utils.sdnzoneSchema[value];
943 if (schema) {
f3c1eac7 944 return schema.name;
9233148b
AD
945 }
946 return Proxmox.Utils.unknownText;
947 },
948
949 format_sdncontroller_type: function(value, md, record) {
950 var schema = PVE.Utils.sdncontrollerSchema[value];
951 if (schema) {
952 return schema.name;
953 }
954 return Proxmox.Utils.unknownText;
955 },
956
1d9643f6
AD
957 format_sdnipam_type: function(value, md, record) {
958 var schema = PVE.Utils.sdnipamSchema[value];
959 if (schema) {
960 return schema.name;
961 }
962 return Proxmox.Utils.unknownText;
963 },
964
965 format_sdndns_type: function(value, md, record) {
966 var schema = PVE.Utils.sdndnsSchema[value];
967 if (schema) {
968 return schema.name;
969 }
970 return Proxmox.Utils.unknownText;
971 },
972
3c23c025 973 format_storage_type: function(value, md, record) {
4a4b2b6e 974 if (value === 'rbd') {
53e3ea84 975 value = !record || record.get('monhost') ? 'rbd' : 'pveceph';
4a4b2b6e 976 } else if (value === 'cephfs') {
53e3ea84 977 value = !record || record.get('monhost') ? 'cephfs' : 'pvecephfs';
3c23c025 978 }
062a7f49 979
d0477f12
TL
980 let schema = PVE.Utils.storageSchema[value];
981 return schema?.name ?? value;
a3b8efb4
EK
982 },
983
ced1677b 984 format_ha: function(value) {
e7ade592 985 var text = Proxmox.Utils.noneText;
ced1677b
TL
986
987 if (value.managed) {
e7ade592 988 text = value.state || Proxmox.Utils.noneText;
ced1677b 989
8058410f 990 text += ', ' + Proxmox.Utils.groupText + ': ';
e7ade592 991 text += value.group || Proxmox.Utils.noneText;
ced1677b
TL
992 }
993
994 return text;
995 },
996
b0a6d326 997 format_content_types: function(value) {
0e244a29
DC
998 return value.split(',').sort().map(function(ct) {
999 return PVE.Utils.contentTypes[ct] || ct;
1000 }).join(', ');
b0a6d326
EK
1001 },
1002
1003 render_storage_content: function(value, metaData, record) {
1004 var data = record.data;
1005 if (Ext.isNumber(data.channel) &&
1006 Ext.isNumber(data.id) &&
1007 Ext.isNumber(data.lun)) {
0be88ae1 1008 return "CH " +
f6710aac 1009 Ext.String.leftPad(data.channel, 2, '0') +
b0a6d326
EK
1010 " ID " + data.id + " LUN " + data.lun;
1011 }
f6710aac 1012 return data.volid.replace(/^.*?:(.*?\/)?/, '');
b0a6d326
EK
1013 },
1014
8058410f 1015 render_serverity: function(value) {
b0a6d326
EK
1016 return PVE.Utils.log_severity_hash[value] || value;
1017 },
1018
a62ee730 1019 calculate_hostcpu: function(data) {
a62ee730
AD
1020 if (!(data.uptime && Ext.isNumeric(data.cpu))) {
1021 return -1;
1022 }
1023
1024 if (data.type !== 'qemu' && data.type !== 'lxc') {
1025 return -1;
1026 }
1027
1028 var index = PVE.data.ResourceStore.findExact('id', 'node/' + data.node);
1029 var node = PVE.data.ResourceStore.getAt(index);
1030 if (!Ext.isDefined(node) || node === null) {
1031 return -1;
1032 }
1033 var maxcpu = node.data.maxcpu || 1;
1034
1035 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
1036 return -1;
1037 }
1038
4d739f4a 1039 return (data.cpu/maxcpu) * data.maxcpu;
a62ee730
AD
1040 },
1041
1042 render_hostcpu: function(value, metaData, record, rowIndex, colIndex, store) {
a62ee730
AD
1043 if (!(record.data.uptime && Ext.isNumeric(record.data.cpu))) {
1044 return '';
1045 }
1046
1047 if (record.data.type !== 'qemu' && record.data.type !== 'lxc') {
1048 return '';
1049 }
1050
1051 var index = PVE.data.ResourceStore.findExact('id', 'node/' + record.data.node);
1052 var node = PVE.data.ResourceStore.getAt(index);
1053 if (!Ext.isDefined(node) || node === null) {
1054 return '';
1055 }
1056 var maxcpu = node.data.maxcpu || 1;
1057
1058 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
1059 return '';
1060 }
1061
1062 var per = (record.data.cpu/maxcpu) * record.data.maxcpu * 100;
1063
1064 return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
1065 },
1066
946730cd
DC
1067 render_bandwidth: function(value) {
1068 if (!Ext.isNumeric(value)) {
1069 return '';
1070 }
1071
e7ade592 1072 return Proxmox.Utils.format_size(value) + '/s';
b0a6d326
EK
1073 },
1074
3f633655
EK
1075 render_timestamp_human_readable: function(value) {
1076 return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
1077 },
1078
7ce62ab3
TL
1079 // render a timestamp or pending
1080 render_next_event: function(value) {
1081 if (!value) {
1082 return '-';
1083 }
1084 let now = new Date(), next = new Date(value * 1000);
1085 if (next < now) {
1086 return gettext('pending');
1087 }
1088 return Proxmox.Utils.render_timestamp(value);
1089 },
1090
0bfc799f
DC
1091 calculate_mem_usage: function(data) {
1092 if (!Ext.isNumeric(data.mem) ||
1093 data.maxmem === 0 ||
1094 data.uptime < 1) {
1095 return -1;
1096 }
1097
53e3ea84 1098 return data.mem / data.maxmem;
0bfc799f
DC
1099 },
1100
a62ee730 1101 calculate_hostmem_usage: function(data) {
a62ee730
AD
1102 if (data.type !== 'qemu' && data.type !== 'lxc') {
1103 return -1;
1104 }
1105
1106 var index = PVE.data.ResourceStore.findExact('id', 'node/' + data.node);
1107 var node = PVE.data.ResourceStore.getAt(index);
1108
1109 if (!Ext.isDefined(node) || node === null) {
1110 return -1;
1111 }
1112 var maxmem = node.data.maxmem || 0;
1113
1114 if (!Ext.isNumeric(data.mem) ||
1115 maxmem === 0 ||
1116 data.uptime < 1) {
1117 return -1;
1118 }
1119
4d739f4a 1120 return data.mem / maxmem;
a62ee730
AD
1121 },
1122
0bfc799f
DC
1123 render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
1124 if (!Ext.isNumeric(value) || value === -1) {
1125 return '';
1126 }
8058410f 1127 if (value > 1) {
0bfc799f
DC
1128 // we got no percentage but bytes
1129 var mem = value;
1130 var maxmem = record.data.maxmem;
1131 if (!record.data.uptime ||
1132 maxmem === 0 ||
1133 !Ext.isNumeric(mem)) {
1134 return '';
1135 }
1136
53e3ea84 1137 return (mem*100/maxmem).toFixed(1) + " %";
0bfc799f
DC
1138 }
1139 return (value*100).toFixed(1) + " %";
1140 },
1141
a62ee730 1142 render_hostmem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
a62ee730
AD
1143 if (!Ext.isNumeric(record.data.mem) || value === -1) {
1144 return '';
1145 }
1146
1147 if (record.data.type !== 'qemu' && record.data.type !== 'lxc') {
1148 return '';
1149 }
1150
1151 var index = PVE.data.ResourceStore.findExact('id', 'node/' + record.data.node);
1152 var node = PVE.data.ResourceStore.getAt(index);
1153 var maxmem = node.data.maxmem || 0;
1154
4d739f4a 1155 if (record.data.mem > 1) {
a62ee730
AD
1156 // we got no percentage but bytes
1157 var mem = record.data.mem;
1158 if (!record.data.uptime ||
1159 maxmem === 0 ||
1160 !Ext.isNumeric(mem)) {
1161 return '';
1162 }
1163
1164 return ((mem*100)/maxmem).toFixed(1) + " %";
1165 }
1166 return (value*100).toFixed(1) + " %";
1167 },
1168
b0a6d326 1169 render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
b0a6d326
EK
1170 var mem = value;
1171 var maxmem = record.data.maxmem;
0be88ae1 1172
b0a6d326
EK
1173 if (!record.data.uptime) {
1174 return '';
1175 }
1176
1177 if (!(Ext.isNumeric(mem) && maxmem)) {
1178 return '';
1179 }
1180
1bd7bcdb 1181 return Proxmox.Utils.render_size(value);
b0a6d326
EK
1182 },
1183
0bfc799f 1184 calculate_disk_usage: function(data) {
0bfc799f 1185 if (!Ext.isNumeric(data.disk) ||
4d739f4a
TL
1186 ((data.type === 'qemu' || data.type === 'lxc') && data.uptime === 0) ||
1187 data.maxdisk === 0
1188 ) {
0bfc799f
DC
1189 return -1;
1190 }
1191
53e3ea84 1192 return data.disk / data.maxdisk;
0bfc799f
DC
1193 },
1194
1195 render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
1196 if (!Ext.isNumeric(value) || value === -1) {
1197 return '';
1198 }
1199
1200 return (value * 100).toFixed(1) + " %";
1201 },
1202
b0a6d326 1203 render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
b0a6d326
EK
1204 var disk = value;
1205 var maxdisk = record.data.maxdisk;
728f1b97 1206 var type = record.data.type;
b0a6d326 1207
728f1b97 1208 if (!Ext.isNumeric(disk) ||
728f1b97 1209 maxdisk === 0 ||
4d739f4a
TL
1210 ((type === 'qemu' || type === 'lxc') && record.data.uptime === 0)
1211 ) {
b0a6d326
EK
1212 return '';
1213 }
1214
1bd7bcdb 1215 return Proxmox.Utils.render_size(value);
b0a6d326
EK
1216 },
1217
4dbc64a7
DC
1218 get_object_icon_class: function(type, record) {
1219 var status = '';
1220 var objType = type;
1221
1222 if (type === 'type') {
1223 // for folder view
1224 objType = record.groupbyid;
1225 } else if (record.template) {
1226 // templates
1227 objType = 'template';
1228 status = type;
1229 } else {
1230 // everything else
1231 status = record.status + ' ha-' + record.hastate;
b1d8e73d
DC
1232 }
1233
6284a48a
DC
1234 if (record.lock) {
1235 status += ' locked lock-' + record.lock;
1236 }
1237
4dbc64a7
DC
1238 var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
1239 if (defaults && defaults.iconCls) {
1240 var retVal = defaults.iconCls + ' ' + status;
1241 return retVal;
b0a6d326
EK
1242 }
1243
4dbc64a7
DC
1244 return '';
1245 },
1246
1247 render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
f6710aac 1248 var cls = PVE.Utils.get_object_icon_class(value, record.data);
2b2fe160 1249
8058410f 1250 var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
b1d8e73d 1251 return fa + value;
b0a6d326
EK
1252 },
1253
b0a6d326
EK
1254 render_support_level: function(value, metaData, record) {
1255 return PVE.Utils.support_level_hash[value] || '-';
1256 },
1257
0be88ae1 1258 render_upid: function(value, metaData, record) {
b0a6d326
EK
1259 var type = record.data.type;
1260 var id = record.data.id;
1261
e7ade592 1262 return Proxmox.Utils.format_task_description(type, id);
b0a6d326
EK
1263 },
1264
27809975 1265 render_optional_url: function(value) {
4d739f4a 1266 if (value && value.match(/^https?:\/\//)) {
cdd9b6c0 1267 return '<a target="_blank" href="' + value + '">' + value + '</a>';
27809975
DC
1268 }
1269 return value;
1270 },
1271
1272 render_san: function(value) {
1273 var names = [];
1274 if (Ext.isArray(value)) {
1275 value.forEach(function(val) {
1276 if (!Ext.isNumber(val)) {
1277 names.push(val);
1278 }
1279 });
1280 return names.join('<br>');
1281 }
1282 return value;
1283 },
1284
6ad4be69
DC
1285 render_full_name: function(firstname, metaData, record) {
1286 var first = firstname || '';
1287 var last = record.data.lastname || '';
1288 return Ext.htmlEncode(first + " " + last);
1289 },
1290
fe5c4f81
AL
1291 // expecting the following format:
1292 // [v2:10.10.10.1:6802/2008,v1:10.10.10.1:6803/2008]
1293 render_ceph_osd_addr: function(value) {
1294 value = value.trim();
1295 if (value.startsWith('[') && value.endsWith(']')) {
1296 value = value.slice(1, -1); // remove []
1297 }
1298 value = value.replaceAll(',', '\n'); // split IPs in lines
1299 let retVal = '';
1300 for (const i of value.matchAll(/^(v[0-9]):(.*):([0-9]*)\/([0-9]*)$/gm)) {
1301 retVal += `${i[1]}: ${i[2]}:${i[3]}<br>`;
1302 }
1303 return retVal.length < 1 ? value : retVal;
1304 },
1305
aa0819a8 1306 windowHostname: function() {
e7ade592 1307 return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
aa0819a8
WB
1308 function(m, addr, offset, original) { return addr; });
1309 },
0be88ae1 1310
953f6e9b 1311 openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) {
8aac63a5 1312 var dv = PVE.Utils.defaultViewer(consoles, consoleType);
953f6e9b 1313 PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd);
b0a6d326
EK
1314 },
1315
953f6e9b 1316 openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) {
4d739f4a 1317 if (vmid === undefined && (consoleType === 'kvm' || consoleType === 'lxc')) {
b0a6d326
EK
1318 throw "missing vmid";
1319 }
b0a6d326
EK
1320 if (!nodename) {
1321 throw "no nodename specified";
1322 }
1323
c7218ab3 1324 if (viewer === 'html5') {
953f6e9b 1325 PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd);
c6b2336c 1326 } else if (viewer === 'xtermjs') {
953f6e9b 1327 Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd);
b0a6d326 1328 } else if (viewer === 'vv') {
953f6e9b
TL
1329 let url = '/nodes/' + nodename + '/spiceshell';
1330 let params = {
1331 proxy: PVE.Utils.windowHostname(),
1332 };
1333 if (consoleType === 'kvm') {
b0a6d326 1334 url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
953f6e9b 1335 } else if (consoleType === 'lxc') {
9e361643 1336 url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
953f6e9b
TL
1337 } else if (consoleType === 'upgrade') {
1338 params.cmd = 'upgrade';
1339 } else if (consoleType === 'cmd') {
8eccc68f 1340 params.cmd = cmd;
953f6e9b
TL
1341 } else if (consoleType !== 'shell') {
1342 throw `unknown spice viewer type '${consoleType}'`;
b0a6d326 1343 }
953f6e9b 1344 PVE.Utils.openSpiceViewer(url, params);
b0a6d326 1345 } else {
953f6e9b 1346 throw `unknown viewer type '${viewer}'`;
b0a6d326
EK
1347 }
1348 },
1349
8aac63a5 1350 defaultViewer: function(consoles, type) {
3438c27e
DC
1351 var allowSpice, allowXtermjs;
1352
1353 if (consoles === true) {
1354 allowSpice = true;
1355 allowXtermjs = true;
1356 } else if (typeof consoles === 'object') {
1357 allowSpice = consoles.spice;
4ace5c6f 1358 allowXtermjs = !!consoles.xtermjs;
3438c27e 1359 }
731436ee 1360 let dv = PVE.UIOptions.options.console || (type === 'kvm' ? 'vv' : 'xtermjs');
f932cffa 1361 if (dv === 'vv' && !allowSpice) {
53e3ea84 1362 dv = allowXtermjs ? 'xtermjs' : 'html5';
f932cffa 1363 } else if (dv === 'xtermjs' && !allowXtermjs) {
53e3ea84 1364 dv = allowSpice ? 'vv' : 'html5';
b0a6d326
EK
1365 }
1366
1367 return dv;
1368 },
1369
8eccc68f 1370 openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
af89f682
TL
1371 let scaling = 'off';
1372 if (Proxmox.Utils.toolkit !== 'touch') {
1373 var sp = Ext.state.Manager.getProvider();
1374 scaling = sp.get('novnc-scaling', 'off');
1375 }
8eccc68f 1376 var url = Ext.Object.toQueryString({
9e361643 1377 console: vmtype, // kvm, lxc, upgrade or shell
c7218ab3 1378 novnc: 1,
b0a6d326
EK
1379 vmid: vmid,
1380 vmname: vmname,
16e64c97 1381 node: nodename,
af89f682 1382 resize: scaling,
f6710aac 1383 cmd: cmd,
b0a6d326
EK
1384 });
1385 var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
7af1ab47
DC
1386 if (nw) {
1387 nw.focus();
1388 }
b0a6d326
EK
1389 },
1390
8058410f 1391 openSpiceViewer: function(url, params) {
b0a6d326
EK
1392 var downloadWithName = function(uri, name) {
1393 var link = Ext.DomHelper.append(document.body, {
1394 tag: 'a',
1395 href: uri,
8058410f 1396 css: 'display:none;visibility:hidden;height:0px;',
b0a6d326
EK
1397 });
1398
63c22966 1399 // Note: we need to tell Android and Chrome the correct file name extension
b0a6d326
EK
1400 // but we do not set 'download' tag for other environments, because
1401 // It can have strange side effects (additional user prompt on firefox)
63c22966 1402 if (navigator.userAgent.match(/Android|Chrome/i)) {
b0a6d326
EK
1403 link.download = name;
1404 }
1405
1406 if (link.fireEvent) {
1407 link.fireEvent('onclick');
1408 } else {
953f6e9b
TL
1409 let evt = document.createEvent("MouseEvents");
1410 evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
b0a6d326
EK
1411 link.dispatchEvent(evt);
1412 }
1413 };
1414
e7ade592 1415 Proxmox.Utils.API2Request({
b0a6d326
EK
1416 url: url,
1417 params: params,
1418 method: 'POST',
8058410f 1419 failure: function(response, opts) {
b0a6d326
EK
1420 Ext.Msg.alert('Error', response.htmlStatus);
1421 },
8058410f 1422 success: function(response, opts) {
4d739f4a
TL
1423 let cfg = response.result.data;
1424 let raw = Object.entries(cfg).reduce((acc, [k, v]) => acc + `${k}=${v}\n`, "[virt-viewer]\n");
1425 let spiceDownload = 'data:application/x-virt-viewer;charset=UTF-8,' + encodeURIComponent(raw);
1426 downloadWithName(spiceDownload, "pve-spice.vv");
f6710aac 1427 },
b0a6d326
EK
1428 });
1429 },
1430
e3129443
DC
1431 openTreeConsole: function(tree, record, item, index, e) {
1432 e.stopEvent();
4d739f4a
TL
1433 let nodename = record.data.node;
1434 let vmid = record.data.vmid;
1435 let vmname = record.data.name;
e3129443 1436 if (record.data.type === 'qemu' && !record.data.template) {
e7ade592 1437 Proxmox.Utils.API2Request({
4d739f4a
TL
1438 url: `/nodes/${nodename}/qemu/${vmid}/status/current`,
1439 failure: response => Ext.Msg.alert('Error', response.htmlStatus),
e3129443 1440 success: function(response, opts) {
bd9537d7 1441 let conf = response.result.data;
4d739f4a 1442 let consoles = {
bd9537d7
TL
1443 spice: !!conf.spice,
1444 xtermjs: !!conf.serial,
54453c38
DC
1445 };
1446 PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
f6710aac 1447 },
e3129443
DC
1448 });
1449 } else if (record.data.type === 'lxc' && !record.data.template) {
1450 PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
1451 }
1452 },
1453
fbd60cfd
DM
1454 // test automation helper
1455 call_menu_handler: function(menu, text) {
4d739f4a
TL
1456 let item = menu.query('menuitem').find(el => el.text === text);
1457 if (item && item.handler) {
1458 item.handler();
1459 }
fbd60cfd
DM
1460 },
1461
685b7aa4
DC
1462 createCmdMenu: function(v, record, item, index, event) {
1463 event.stopEvent();
cc1a91be
DC
1464 if (!(v instanceof Ext.tree.View)) {
1465 v.select(record);
1466 }
4d739f4a
TL
1467 let menu;
1468 let type = record.data.type;
685b7aa4 1469
4d739f4a
TL
1470 if (record.data.template) {
1471 if (type === 'qemu' || type === 'lxc') {
9bad05bd 1472 menu = Ext.create('PVE.menu.TemplateMenu', {
f6710aac 1473 pveSelNode: record,
9bad05bd
DC
1474 });
1475 }
4d739f4a 1476 } else if (type === 'qemu' || type === 'lxc' || type === 'node') {
9bad05bd
DC
1477 menu = Ext.create('PVE.' + type + '.CmdMenu', {
1478 pveSelNode: record,
f6710aac 1479 nodename: record.data.node,
c11ab8cb 1480 });
685b7aa4 1481 } else {
4d739f4a 1482 return undefined;
685b7aa4
DC
1483 }
1484
1485 menu.showAt(event.getXY());
9f0b4e04 1486 return menu;
e7ade592 1487 },
9fa2e36d 1488
fe4f00ad
TL
1489 // helper for deleting field which are set to there default values
1490 delete_if_default: function(values, fieldname, default_val, create) {
1491 if (values[fieldname] === '' || values[fieldname] === default_val) {
1492 if (!create) {
399ffa76
TL
1493 if (values.delete) {
1494 if (Ext.isArray(values.delete)) {
1495 values.delete.push(fieldname);
2db8e90d 1496 } else {
399ffa76 1497 values.delete += ',' + fieldname;
2db8e90d 1498 }
fe4f00ad 1499 } else {
399ffa76 1500 values.delete = fieldname;
fe4f00ad
TL
1501 }
1502 }
1503
1504 delete values[fieldname];
1505 }
857b97a7
TL
1506 },
1507
1508 loadSSHKeyFromFile: function(file, callback) {
37f2e82c
TL
1509 // ssh-keygen produces ~ 740 bytes for a 4096 bit RSA key, current max is 16 kbit, so assume:
1510 // 740 * 8 for max. 32kbit (5920 bytes), round upwards to 8192 bytes, leaves lots of comment space
1511 PVE.Utils.loadFile(file, callback, 8192);
1512 },
1513
1514 loadFile: function(file, callback, maxSize) {
1515 maxSize = maxSize || 32 * 1024;
1516 if (file.size > maxSize) {
1517 Ext.Msg.alert(gettext('Error'), `${gettext("Invalid file size")}: ${file.size} > ${maxSize}`);
857b97a7
TL
1518 return;
1519 }
4d739f4a 1520 let reader = new FileReader();
37f2e82c 1521 reader.onload = evt => callback(evt.target.result);
857b97a7 1522 reader.readAsText(file);
abe824aa
DC
1523 },
1524
7dda153c
TL
1525 loadTextFromFile: function(file, callback, maxBytes) {
1526 let maxSize = maxBytes || 8192;
1527 if (file.size > maxSize) {
1528 Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
1529 return;
1530 }
7dda153c
TL
1531 let reader = new FileReader();
1532 reader.onload = evt => callback(evt.target.result);
1533 reader.readAsText(file);
1534 },
1535
8c4ec8c7
TL
1536 diskControllerMaxIDs: {
1537 ide: 4,
1538 sata: 6,
cf0d139e 1539 scsi: 31,
8c4ec8c7 1540 virtio: 16,
7b14d77a 1541 unused: 256,
8c4ec8c7 1542 },
abe824aa
DC
1543
1544 // types is either undefined (all busses), an array of busses, or a single bus
1545 forEachBus: function(types, func) {
4d739f4a 1546 let busses = Object.keys(PVE.Utils.diskControllerMaxIDs);
abe824aa
DC
1547
1548 if (Ext.isArray(types)) {
1549 busses = types;
1550 } else if (Ext.isDefined(types)) {
8058410f 1551 busses = [types];
abe824aa
DC
1552 }
1553
1554 // check if we only have valid busses
4d739f4a 1555 for (let i = 0; i < busses.length; i++) {
8c4ec8c7 1556 if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) {
abe824aa
DC
1557 throw "invalid bus: '" + busses[i] + "'";
1558 }
1559 }
1560
4d739f4a
TL
1561 for (let i = 0; i < busses.length; i++) {
1562 let count = PVE.Utils.diskControllerMaxIDs[busses[i]];
1563 for (let j = 0; j < count; j++) {
1564 let cont = func(busses[i], j);
abe824aa
DC
1565 if (!cont && cont !== undefined) {
1566 return;
1567 }
1568 }
1569 }
14a845bc
DC
1570 },
1571
4d739f4a 1572 mp_counts: {
5747fef3 1573 mp: 256,
4d739f4a
TL
1574 unused: 256,
1575 },
14a845bc
DC
1576
1577 forEachMP: function(func, includeUnused) {
5747fef3 1578 for (let i = 0; i < PVE.Utils.mp_counts.mp; i++) {
4d739f4a 1579 let cont = func('mp', i);
14a845bc
DC
1580 if (!cont && cont !== undefined) {
1581 return;
1582 }
1583 }
1584
1585 if (!includeUnused) {
1586 return;
1587 }
1588
4d739f4a
TL
1589 for (let i = 0; i < PVE.Utils.mp_counts.unused; i++) {
1590 let cont = func('unused', i);
14a845bc
DC
1591 if (!cont && cont !== undefined) {
1592 return;
1593 }
1594 }
b945c7c1
TM
1595 },
1596
17dcba38
DC
1597 hardware_counts: {
1598 net: 32,
1599 usb: 14,
1600 usb_old: 5,
1601 hostpci: 16,
1602 audio: 1,
1603 efidisk: 1,
1604 serial: 4,
1605 rng: 1,
1606 tpmstate: 1,
1607 },
1608
1609 // we can have usb6 and up only for specific machine/ostypes
1610 get_max_usb_count: function(ostype, machine) {
1611 if (!ostype) {
1612 return PVE.Utils.hardware_counts.usb_old;
1613 }
1614
1615 let match = /-(\d+).(\d+)/.exec(machine ?? '');
1616 if (!match || PVE.Utils.qemu_min_version([match[1], match[2]], [7, 1])) {
1617 if (ostype === 'l26') {
1618 return PVE.Utils.hardware_counts.usb;
1619 }
1620 let os_match = /^win(\d+)$/.exec(ostype);
1621 if (os_match && os_match[1] > 7) {
1622 return PVE.Utils.hardware_counts.usb;
1623 }
1624 }
1625
1626 return PVE.Utils.hardware_counts.usb_old;
1627 },
1628
1629 // parameters are expected to be arrays, e.g. [7,1], [4,0,1]
1630 // returns true if toCheck is equal or greater than minVersion
1631 qemu_min_version: function(toCheck, minVersion) {
1632 let i;
1633 for (i = 0; i < toCheck.length && i < minVersion.length; i++) {
1634 if (toCheck[i] < minVersion[i]) {
1635 return false;
1636 }
1637 }
1638
1639 if (minVersion.length > toCheck.length) {
1640 for (; i < minVersion.length; i++) {
1641 if (minVersion[i] !== 0) {
1642 return false;
1643 }
1644 }
1645 }
1646
1647 return true;
1648 },
9d855398 1649
8058410f 1650 cleanEmptyObjectKeys: function(obj) {
4d739f4a
TL
1651 for (const propName of Object.keys(obj)) {
1652 if (obj[propName] === null || obj[propName] === undefined) {
1653 delete obj[propName];
b945c7c1
TM
1654 }
1655 }
4616a55b
TM
1656 },
1657
eadbbb4a
DC
1658 acmedomain_count: 5,
1659
1660 add_domain_to_acme: function(acme, domain) {
1661 if (acme.domains === undefined) {
1662 acme.domains = [domain];
1663 } else {
1664 acme.domains.push(domain);
8058410f 1665 acme.domains = acme.domains.filter((value, index, self) => self.indexOf(value) === index);
eadbbb4a
DC
1666 }
1667 return acme;
1668 },
1669
1670 remove_domain_from_acme: function(acme, domain) {
1671 if (acme.domains !== undefined) {
4d739f4a
TL
1672 acme.domains = acme
1673 .domains
1674 .filter((value, index, self) => self.indexOf(value) === index && value !== domain);
eadbbb4a
DC
1675 }
1676 return acme;
1677 },
1678
4d739f4a
TL
1679 handleStoreErrorOrMask: function(view, store, regex, callback) {
1680 view.mon(store, 'load', function(proxy, response, success, operation) {
4616a55b 1681 if (success) {
4d739f4a 1682 Proxmox.Utils.setErrorMask(view, false);
4616a55b
TM
1683 return;
1684 }
4d739f4a 1685 let msg;
4616a55b
TM
1686 if (operation.error.statusText) {
1687 if (operation.error.statusText.match(regex)) {
4d739f4a 1688 callback(view, operation.error);
4616a55b
TM
1689 return;
1690 } else {
1691 msg = operation.error.statusText + ' (' + operation.error.status + ')';
1692 }
1693 } else {
1694 msg = gettext('Connection error');
1695 }
4d739f4a 1696 Proxmox.Utils.setErrorMask(view, msg);
4616a55b
TM
1697 });
1698 },
1699
8058410f 1700 showCephInstallOrMask: function(container, msg, nodename, callback) {
13786fb0 1701 if (msg.match(/not (installed|initialized)/i)) {
4616a55b
TM
1702 if (Proxmox.UserName === 'root@pam') {
1703 container.el.mask();
8058410f 1704 if (!container.down('pveCephInstallWindow')) {
ef725143 1705 var isInstalled = !!msg.match(/not initialized/i);
4616a55b 1706 var win = Ext.create('PVE.ceph.Install', {
f6710aac 1707 nodename: nodename,
4616a55b 1708 });
f992ef80 1709 win.getViewModel().set('isInstalled', isInstalled);
4616a55b 1710 container.add(win);
19f703e2
DC
1711 win.on('close', () => {
1712 container.el.unmask();
1713 });
4616a55b
TM
1714 win.show();
1715 callback(win);
1716 }
1717 } else {
a7e8b87b
TL
1718 container.mask(Ext.String.format(gettext('{0} not installed.') +
1719 ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
4616a55b
TM
1720 }
1721 return true;
1722 } else {
1723 return false;
1724 }
49dfba72
DC
1725 },
1726
13786fb0
TL
1727 monitor_ceph_installed: function(view, rstore, nodename, maskOwnerCt) {
1728 PVE.Utils.handleStoreErrorOrMask(
1729 view,
1730 rstore,
1731 /not (installed|initialized)/i,
1732 (_, error) => {
c2175df2 1733 nodename = nodename || Proxmox.NodeName;
13786fb0
TL
1734 let maskTarget = maskOwnerCt ? view.ownerCt : view;
1735 rstore.stopUpdate();
1736 PVE.Utils.showCephInstallOrMask(maskTarget, error.statusText, nodename, win => {
1737 view.mon(win, 'cephInstallWindowClosed', () => rstore.startUpdate());
1738 });
1739 },
1740 );
1741 },
1742
1743
49dfba72
DC
1744 propertyStringSet: function(target, source, name, value) {
1745 if (source) {
1746 if (value === undefined) {
1747 target[name] = source;
1748 } else {
1749 target[name] = value;
1750 }
1751 } else {
1752 delete target[name];
1753 }
bbc83309
DC
1754 },
1755
e65817a1
SR
1756 forEachCorosyncLink: function(nodeinfo, cb) {
1757 let re = /(?:ring|link)(\d+)_addr/;
1758 Ext.iterate(nodeinfo, (prop, val) => {
1759 let match = re.exec(prop);
1760 if (match) {
1761 cb(Number(match[1]), val);
1762 }
1763 });
1764 },
4546808c
SR
1765
1766 cpu_vendor_map: {
1767 'default': 'QEMU',
1768 'AuthenticAMD': 'AMD',
f6710aac 1769 'GenuineIntel': 'Intel',
4546808c
SR
1770 },
1771
1772 cpu_vendor_order: {
1773 "AMD": 1,
1774 "Intel": 2,
1775 "QEMU": 3,
1776 "Host": 4,
1777 "_default_": 5, // includes custom models
1778 },
5865b597
WB
1779
1780 verify_ip64_address_list: function(value, with_suffix) {
1781 for (let addr of value.split(/[ ,;]+/)) {
1782 if (addr === '') {
1783 continue;
1784 }
1785
1786 if (with_suffix) {
1787 let parts = addr.split('%');
1788 addr = parts[0];
1789
1790 if (parts.length > 2) {
1791 return false;
1792 }
1793
1794 if (parts.length > 1 && !addr.startsWith('fe80:')) {
1795 return false;
1796 }
1797 }
1798
1799 if (!Proxmox.Utils.IP64_match.test(addr)) {
1800 return false;
1801 }
1802 }
1803
1804 return true;
1805 },
2aa645da
DC
1806
1807 sortByPreviousUsage: function(vmconfig, controllerList) {
1808 if (!controllerList) {
1809 controllerList = ['ide', 'virtio', 'scsi', 'sata'];
1810 }
1811 let usedControllers = {};
1812 for (const type of Object.keys(PVE.Utils.diskControllerMaxIDs)) {
1813 usedControllers[type] = 0;
1814 }
1815
1816 for (const property of Object.keys(vmconfig)) {
1817 if (property.match(PVE.Utils.bus_match) && !vmconfig[property].match(/media=cdrom/)) {
1818 const foundController = property.match(PVE.Utils.bus_match)[1];
1819 usedControllers[foundController]++;
1820 }
1821 }
1822
1823 let sortPriority = PVE.qemu.OSDefaults.getDefaults(vmconfig.ostype).busPriority;
1824
1825 let sortedList = Ext.clone(controllerList);
1826 sortedList.sort(function(a, b) {
1827 if (usedControllers[b] === usedControllers[a]) {
1828 return sortPriority[b] - sortPriority[a];
1829 }
1830 return usedControllers[b] - usedControllers[a];
1831 });
1832
1833 return sortedList;
1834 },
1835
1836 nextFreeDisk: function(controllers, config) {
1837 for (const controller of controllers) {
1838 for (let i = 0; i < PVE.Utils.diskControllerMaxIDs[controller]; i++) {
1839 let confid = controller + i.toString();
1840 if (!Ext.isDefined(config[confid])) {
1841 return {
1842 controller,
1843 id: i,
1844 confid,
1845 };
1846 }
1847 }
1848 }
1849
1850 return undefined;
1851 },
000b5537
AL
1852
1853 nextFreeMP: function(type, config) {
1854 for (let i = 0; i < PVE.Utils.mp_counts[type]; i++) {
1855 let confid = `${type}${i}`;
1856 if (!Ext.isDefined(config[confid])) {
1857 return {
1858 type,
1859 id: i,
1860 confid,
1861 };
1862 }
1863 }
1864
1865 return undefined;
1866 },
7c8ff459
FE
1867
1868 escapeNotesTemplate: function(value) {
1869 let replace = {
1870 '\\': '\\\\',
1871 '\n': '\\n',
1872 };
1873 return value.replace(/(\\|[\n])/g, match => replace[match]);
1874 },
1875
1876 unEscapeNotesTemplate: function(value) {
1877 let replace = {
1878 '\\\\': '\\',
1879 '\\n': '\n',
1880 };
1881 return value.replace(/(\\\\|\\n)/g, match => replace[match]);
1882 },
03875d7a
FE
1883
1884 notesTemplateVars: ['cluster', 'guestname', 'node', 'vmid'],
b7f4cb7c 1885
0a627d94
DC
1886 renderTags: function(tagstext, overrides) {
1887 let text = '';
1888 if (tagstext) {
1889 let tags = (tagstext.split(/[,; ]/) || []).filter(t => !!t);
731436ee 1890 if (PVE.UIOptions.shouldSortTags()) {
13a0c8bf 1891 tags = tags.sort((a, b) => {
871953db
DC
1892 let alc = a.toLowerCase();
1893 let blc = b.toLowerCase();
1894 return alc < blc ? -1 : blc < alc ? 1 : a.localeCompare(b);
1895 });
8d8ba23d 1896 }
0a627d94
DC
1897 text += ' ';
1898 tags.forEach((tag) => {
1899 text += Proxmox.Utils.getTagElement(tag, overrides);
1900 });
1901 }
1902 return text;
1903 },
1904
59e71a08 1905 tagCharRegex: /^[a-z0-9+_.-]+$/i,
fdde857a
SH
1906
1907 verificationStateOrder: {
1908 'failed': 0,
1909 'none': 1,
1910 'ok': 2,
1911 '__default__': 3,
1912 },
e7ade592 1913},
fe4f00ad 1914
9fa2e36d
EK
1915 singleton: true,
1916 constructor: function() {
1917 var me = this;
1918 Ext.apply(me, me.utilities);
d18e15dd
DC
1919
1920 Proxmox.Utils.override_task_descriptions({
1921 acmedeactivate: ['ACME Account', gettext('Deactivate')],
1922 acmenewcert: ['SRV', gettext('Order Certificate')],
1923 acmerefresh: ['ACME Account', gettext('Refresh')],
1924 acmeregister: ['ACME Account', gettext('Register')],
1925 acmerenew: ['SRV', gettext('Renew Certificate')],
1926 acmerevoke: ['SRV', gettext('Revoke Certificate')],
1927 acmeupdate: ['ACME Account', gettext('Update')],
1928 'auth-realm-sync': [gettext('Realm'), gettext('Sync')],
1929 'auth-realm-sync-test': [gettext('Realm'), gettext('Sync Preview')],
1930 cephcreatemds: ['Ceph Metadata Server', gettext('Create')],
1931 cephcreatemgr: ['Ceph Manager', gettext('Create')],
1932 cephcreatemon: ['Ceph Monitor', gettext('Create')],
1933 cephcreateosd: ['Ceph OSD', gettext('Create')],
1934 cephcreatepool: ['Ceph Pool', gettext('Create')],
1935 cephdestroymds: ['Ceph Metadata Server', gettext('Destroy')],
1936 cephdestroymgr: ['Ceph Manager', gettext('Destroy')],
1937 cephdestroymon: ['Ceph Monitor', gettext('Destroy')],
1938 cephdestroyosd: ['Ceph OSD', gettext('Destroy')],
1939 cephdestroypool: ['Ceph Pool', gettext('Destroy')],
02c1e98e 1940 cephdestroyfs: ['CephFS', gettext('Destroy')],
d18e15dd 1941 cephfscreate: ['CephFS', gettext('Create')],
f9f81a01
TL
1942 cephsetpool: ['Ceph Pool', gettext('Edit')],
1943 cephsetflags: ['', gettext('Change global Ceph flags')],
d18e15dd
DC
1944 clustercreate: ['', gettext('Create Cluster')],
1945 clusterjoin: ['', gettext('Join Cluster')],
1946 dircreate: [gettext('Directory Storage'), gettext('Create')],
1947 dirremove: [gettext('Directory'), gettext('Remove')],
79035e5a 1948 download: [gettext('File'), gettext('Download')],
d18e15dd
DC
1949 hamigrate: ['HA', gettext('Migrate')],
1950 hashutdown: ['HA', gettext('Shutdown')],
1951 hastart: ['HA', gettext('Start')],
1952 hastop: ['HA', gettext('Stop')],
1953 imgcopy: ['', gettext('Copy data')],
1954 imgdel: ['', gettext('Erase data')],
1955 lvmcreate: [gettext('LVM Storage'), gettext('Create')],
03c4aed8 1956 lvmremove: ['Volume Group', gettext('Remove')],
d18e15dd 1957 lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
03c4aed8 1958 lvmthinremove: ['Thinpool', gettext('Remove')],
d18e15dd
DC
1959 migrateall: ['', gettext('Migrate all VMs and Containers')],
1960 'move_volume': ['CT', gettext('Move Volume')],
fe66076f 1961 'pbs-download': ['VM/CT', gettext('File Restore Download')],
d18e15dd
DC
1962 pull_file: ['CT', gettext('Pull file')],
1963 push_file: ['CT', gettext('Push file')],
1964 qmclone: ['VM', gettext('Clone')],
1965 qmconfig: ['VM', gettext('Configure')],
1966 qmcreate: ['VM', gettext('Create')],
1967 qmdelsnapshot: ['VM', gettext('Delete Snapshot')],
1968 qmdestroy: ['VM', gettext('Destroy')],
1969 qmigrate: ['VM', gettext('Migrate')],
1970 qmmove: ['VM', gettext('Move disk')],
1971 qmpause: ['VM', gettext('Pause')],
1972 qmreboot: ['VM', gettext('Reboot')],
1973 qmreset: ['VM', gettext('Reset')],
1974 qmrestore: ['VM', gettext('Restore')],
1975 qmresume: ['VM', gettext('Resume')],
1976 qmrollback: ['VM', gettext('Rollback')],
1977 qmshutdown: ['VM', gettext('Shutdown')],
1978 qmsnapshot: ['VM', gettext('Snapshot')],
1979 qmstart: ['VM', gettext('Start')],
1980 qmstop: ['VM', gettext('Stop')],
1981 qmsuspend: ['VM', gettext('Hibernate')],
1982 qmtemplate: ['VM', gettext('Convert to template')],
1983 spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
1984 spiceshell: ['', gettext('Shell') + ' (Spice)'],
1985 startall: ['', gettext('Start all VMs and Containers')],
1986 stopall: ['', gettext('Stop all VMs and Containers')],
1987 unknownimgdel: ['', gettext('Destroy image from unknown guest')],
4d60651f 1988 wipedisk: ['Device', gettext('Wipe Disk')],
d18e15dd
DC
1989 vncproxy: ['VM/CT', gettext('Console')],
1990 vncshell: ['', gettext('Shell')],
1991 vzclone: ['CT', gettext('Clone')],
1992 vzcreate: ['CT', gettext('Create')],
1993 vzdelsnapshot: ['CT', gettext('Delete Snapshot')],
1994 vzdestroy: ['CT', gettext('Destroy')],
1995 vzdump: (type, id) => id ? `VM/CT ${id} - ${gettext('Backup')}` : gettext('Backup Job'),
1996 vzmigrate: ['CT', gettext('Migrate')],
1997 vzmount: ['CT', gettext('Mount')],
1998 vzreboot: ['CT', gettext('Reboot')],
1999 vzrestore: ['CT', gettext('Restore')],
2000 vzresume: ['CT', gettext('Resume')],
2001 vzrollback: ['CT', gettext('Rollback')],
2002 vzshutdown: ['CT', gettext('Shutdown')],
2003 vzsnapshot: ['CT', gettext('Snapshot')],
2004 vzstart: ['CT', gettext('Start')],
2005 vzstop: ['CT', gettext('Stop')],
2006 vzsuspend: ['CT', gettext('Suspend')],
2007 vztemplate: ['CT', gettext('Convert to template')],
2008 vzumount: ['CT', gettext('Unmount')],
2009 zfscreate: [gettext('ZFS Storage'), gettext('Create')],
03c4aed8 2010 zfsremove: ['ZFS Pool', gettext('Remove')],
d18e15dd 2011 });
f6710aac 2012 },
e7ade592 2013
9fa2e36d 2014});