]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/Utils.js
ui: guest backup view: add encrypted column for PBS storages
[pve-manager.git] / www / manager6 / Utils.js
1 Ext.ns('PVE');
2
3 // avoid errors related to Accessible Rich Internet Applications
4 // (access for people with disabilities)
5 // TODO reenable after all components are upgraded
6 Ext.enableAria = false;
7 Ext.enableAriaButtons = false;
8 Ext.enableAriaPanels = false;
9
10 // avoid errors when running without development tools
11 if (!Ext.isDefined(Ext.global.console)) {
12 var console = {
13 log: function() {}
14 };
15 }
16 console.log("Starting PVE Manager");
17
18 Ext.Ajax.defaultHeaders = {
19 'Accept': 'application/json'
20 };
21
22 Ext.define('PVE.Utils', { utilities: {
23
24 // this singleton contains miscellaneous utilities
25
26 toolkit: undefined, // (extjs|touch), set inside Toolkit.js
27
28 bus_match: /^(ide|sata|virtio|scsi)\d+$/,
29
30 log_severity_hash: {
31 0: "panic",
32 1: "alert",
33 2: "critical",
34 3: "error",
35 4: "warning",
36 5: "notice",
37 6: "info",
38 7: "debug"
39 },
40
41 support_level_hash: {
42 'c': gettext('Community'),
43 'b': gettext('Basic'),
44 's': gettext('Standard'),
45 'p': gettext('Premium')
46 },
47
48 noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.',
49
50 kvm_ostypes: {
51 'Linux': [
52 { desc: '5.x - 2.6 Kernel', val: 'l26' },
53 { desc: '2.4 Kernel', val: 'l24' }
54 ],
55 'Microsoft Windows': [
56 { desc: '10/2016/2019', val: 'win10' },
57 { desc: '8.x/2012/2012r2', val: 'win8' },
58 { desc: '7/2008r2', val: 'win7' },
59 { desc: 'Vista/2008', val: 'w2k8' },
60 { desc: 'XP/2003', val: 'wxp' },
61 { desc: '2000', val: 'w2k' }
62 ],
63 'Solaris Kernel': [
64 { desc: '-', val: 'solaris'}
65 ],
66 'Other': [
67 { desc: '-', val: 'other'}
68 ]
69 },
70
71 get_health_icon: function(state, circle) {
72 if (circle === undefined) {
73 circle = false;
74 }
75
76 if (state === undefined) {
77 state = 'uknown';
78 }
79
80 var icon = 'faded fa-question';
81 switch(state) {
82 case 'good':
83 icon = 'good fa-check';
84 break;
85 case 'upgrade':
86 icon = 'warning fa-upload';
87 break;
88 case 'old':
89 icon = 'warning fa-refresh';
90 break;
91 case 'warning':
92 icon = 'warning fa-exclamation';
93 break;
94 case 'critical':
95 icon = 'critical fa-times';
96 break;
97 default: break;
98 }
99
100 if (circle) {
101 icon += '-circle';
102 }
103
104 return icon;
105 },
106
107 parse_ceph_version: function(service) {
108 if (service.ceph_version_short) {
109 return service.ceph_version_short;
110 }
111
112 if (service.ceph_version) {
113 var match = service.ceph_version.match(/version (\d+(\.\d+)*)/);
114 if (match) {
115 return match[1];
116 }
117 }
118
119 return undefined;
120 },
121
122 compare_ceph_versions: function(a, b) {
123 let avers = [];
124 let bvers = [];
125
126 if (a === b) {
127 return 0;
128 }
129
130 if (Ext.isArray(a)) {
131 avers = a.slice(); // copy array
132 } else {
133 avers = a.toString().split('.');
134 }
135
136 if (Ext.isArray(b)) {
137 bvers = b.slice(); // copy array
138 } else {
139 bvers = b.toString().split('.');
140 }
141
142 while (true) {
143 let av = avers.shift();
144 let bv = bvers.shift();
145
146 if (av === undefined && bv === undefined) {
147 return 0;
148 } else if (av === undefined) {
149 return -1;
150 } else if (bv === undefined) {
151 return 1;
152 } else {
153 let diff = parseInt(av, 10) - parseInt(bv, 10);
154 if (diff != 0) return diff;
155 // else we need to look at the next parts
156 }
157 }
158
159 },
160
161 get_ceph_icon_html: function(health, fw) {
162 var state = PVE.Utils.map_ceph_health[health];
163 var cls = PVE.Utils.get_health_icon(state);
164 if (fw) {
165 cls += ' fa-fw';
166 }
167 return "<i class='fa " + cls + "'></i> ";
168 },
169
170 map_ceph_health: {
171 'HEALTH_OK':'good',
172 'HEALTH_UPGRADE':'upgrade',
173 'HEALTH_OLD':'old',
174 'HEALTH_WARN':'warning',
175 'HEALTH_ERR':'critical'
176 },
177
178 render_ceph_health: function(healthObj) {
179 var state = {
180 iconCls: PVE.Utils.get_health_icon(),
181 text: ''
182 };
183
184 if (!healthObj || !healthObj.status) {
185 return state;
186 }
187
188 var health = PVE.Utils.map_ceph_health[healthObj.status];
189
190 state.iconCls = PVE.Utils.get_health_icon(health, true);
191 state.text = healthObj.status;
192
193 return state;
194 },
195
196 render_zfs_health: function(value) {
197 if (typeof value == 'undefined'){
198 return "";
199 }
200 var iconCls = 'question-circle';
201 switch (value) {
202 case 'AVAIL':
203 case 'ONLINE':
204 iconCls = 'check-circle good';
205 break;
206 case 'REMOVED':
207 case 'DEGRADED':
208 iconCls = 'exclamation-circle warning';
209 break;
210 case 'UNAVAIL':
211 case 'FAULTED':
212 case 'OFFLINE':
213 iconCls = 'times-circle critical';
214 break;
215 default: //unknown
216 }
217
218 return '<i class="fa fa-' + iconCls + '"></i> ' + value;
219
220 },
221
222 render_pbs_fingerprint: fp => fp.substring(0, 23),
223
224 render_backup_encryption: function(v, meta, record) {
225 if (!v) {
226 return gettext('No');
227 }
228
229 let tip = '';
230 if (v.match(/^[a-fA-F0-9]{2}:/)) { // fingerprint
231 tip = `Key fingerprint ${PVE.Utils.render_pbs_fingerprint(v)}`;
232 }
233 let icon = `<i class="fa fa-fw fa-lock good"></i>`;
234 return `<span data-qtip="${tip}">${icon} ${gettext('Encrypted')}</span>`;
235 },
236
237 render_backup_status: function(value, meta, record) {
238 if (typeof value == 'undefined') {
239 return "";
240 }
241
242 let iconCls = 'check-circle good';
243 let text = gettext('Yes');
244
245 if (!PVE.Parser.parseBoolean(value.toString())) {
246 iconCls = 'times-circle critical';
247
248 text = gettext('No');
249
250 let reason = record.get('reason');
251 if (typeof reason !== 'undefined') {
252 if (reason in PVE.Utils.backup_reasons_table) {
253 reason = PVE.Utils.backup_reasons_table[record.get('reason')];
254 }
255 text = `${text} - ${reason}`;
256 }
257 }
258
259 return `<i class="fa fa-${iconCls}"></i> ${text}`;
260 },
261
262 render_backup_days_of_week: function(val) {
263 var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
264 var selected = [];
265 var cur = -1;
266 val.split(',').forEach(function(day){
267 cur++;
268 var dow = (dows.indexOf(day)+6)%7;
269 if (cur === dow) {
270 if (selected.length === 0 || selected[selected.length-1] === 0) {
271 selected.push(1);
272 } else {
273 selected[selected.length-1]++;
274 }
275 } else {
276 while (cur < dow) {
277 cur++;
278 selected.push(0);
279 }
280 selected.push(1);
281 }
282 });
283
284 cur = -1;
285 var days = [];
286 selected.forEach(function(item) {
287 cur++;
288 if (item > 2) {
289 days.push(Ext.Date.dayNames[(cur+1)] + '-' + Ext.Date.dayNames[(cur+item)%7]);
290 cur += item-1;
291 } else if (item == 2) {
292 days.push(Ext.Date.dayNames[cur+1]);
293 days.push(Ext.Date.dayNames[(cur+2)%7]);
294 cur++;
295 } else if (item == 1) {
296 days.push(Ext.Date.dayNames[(cur+1)%7]);
297 }
298 });
299 return days.join(', ');
300 },
301
302 render_backup_selection: function(value, metaData, record) {
303 let allExceptText = gettext('All except {0}');
304 let allText = '-- ' + gettext('All') + ' --';
305 if (record.data.all) {
306 if (record.data.exclude) {
307 return Ext.String.format(allExceptText, record.data.exclude);
308 }
309 return allText;
310 }
311 if (record.data.vmid) {
312 return record.data.vmid;
313 }
314
315 if (record.data.pool) {
316 return "Pool '"+ record.data.pool + "'";
317 }
318
319 return "-";
320 },
321
322 backup_reasons_table: {
323 'backup=yes': gettext('Enabled'),
324 'backup=no': gettext('Disabled'),
325 'enabled': gettext('Enabled'),
326 'disabled': gettext('Disabled'),
327 'not a volume': gettext('Not a volume'),
328 'efidisk but no OMVF BIOS': gettext('EFI Disk without OMVF BIOS'),
329 },
330
331 get_kvm_osinfo: function(value) {
332 var info = { base: 'Other' }; // default
333 if (value) {
334 Ext.each(Object.keys(PVE.Utils.kvm_ostypes), function(k) {
335 Ext.each(PVE.Utils.kvm_ostypes[k], function(e) {
336 if (e.val === value) {
337 info = { desc: e.desc, base: k };
338 }
339 });
340 });
341 }
342 return info;
343 },
344
345 render_kvm_ostype: function (value) {
346 var osinfo = PVE.Utils.get_kvm_osinfo(value);
347 if (osinfo.desc && osinfo.desc !== '-') {
348 return osinfo.base + ' ' + osinfo.desc;
349 } else {
350 return osinfo.base;
351 }
352 },
353
354 render_hotplug_features: function (value) {
355 var fa = [];
356
357 if (!value || (value === '0')) {
358 return gettext('Disabled');
359 }
360
361 if (value === '1') {
362 value = 'disk,network,usb';
363 }
364
365 Ext.each(value.split(','), function(el) {
366 if (el === 'disk') {
367 fa.push(gettext('Disk'));
368 } else if (el === 'network') {
369 fa.push(gettext('Network'));
370 } else if (el === 'usb') {
371 fa.push('USB');
372 } else if (el === 'memory') {
373 fa.push(gettext('Memory'));
374 } else if (el === 'cpu') {
375 fa.push(gettext('CPU'));
376 } else {
377 fa.push(el);
378 }
379 });
380
381 return fa.join(', ');
382 },
383
384 render_localtime: function(value) {
385 if (value === '__default__') {
386 return Proxmox.Utils.defaultText + ' (' + gettext('Enabled for Windows') + ')';
387 }
388 return Proxmox.Utils.format_boolean(value);
389 },
390
391 render_qga_features: function(value) {
392 if (!value) {
393 return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')';
394 }
395 var props = PVE.Parser.parsePropertyString(value, 'enabled');
396 if (!PVE.Parser.parseBoolean(props.enabled)) {
397 return Proxmox.Utils.disabledText;
398 }
399
400 delete props.enabled;
401 var agentstring = Proxmox.Utils.enabledText;
402
403 Ext.Object.each(props, function(key, value) {
404 var keystring = '' ;
405 agentstring += ', ' + key + ': ';
406
407 if (key === 'type') {
408 let map = {
409 isa: "ISA",
410 virtio: "VirtIO",
411 };
412 agentstring += map[value] || Proxmox.Utils.unknownText;
413 } else {
414 if (PVE.Parser.parseBoolean(value)) {
415 agentstring += Proxmox.Utils.enabledText;
416 } else {
417 agentstring += Proxmox.Utils.disabledText;
418 }
419 }
420 });
421
422 return agentstring;
423 },
424
425 render_qemu_machine: function(value) {
426 return value || (Proxmox.Utils.defaultText + ' (i440fx)');
427 },
428
429 render_qemu_bios: function(value) {
430 if (!value) {
431 return Proxmox.Utils.defaultText + ' (SeaBIOS)';
432 } else if (value === 'seabios') {
433 return "SeaBIOS";
434 } else if (value === 'ovmf') {
435 return "OVMF (UEFI)";
436 } else {
437 return value;
438 }
439 },
440
441 render_dc_ha_opts: function(value) {
442 if (!value) {
443 return Proxmox.Utils.defaultText;
444 } else {
445 return PVE.Parser.printPropertyString(value);
446 }
447 },
448 render_as_property_string: function(value) {
449 return (!value) ? Proxmox.Utils.defaultText
450 : PVE.Parser.printPropertyString(value);
451 },
452
453 render_scsihw: function(value) {
454 if (!value) {
455 return Proxmox.Utils.defaultText + ' (LSI 53C895A)';
456 } else if (value === 'lsi') {
457 return 'LSI 53C895A';
458 } else if (value === 'lsi53c810') {
459 return 'LSI 53C810';
460 } else if (value === 'megasas') {
461 return 'MegaRAID SAS 8708EM2';
462 } else if (value === 'virtio-scsi-pci') {
463 return 'VirtIO SCSI';
464 } else if (value === 'virtio-scsi-single') {
465 return 'VirtIO SCSI single';
466 } else if (value === 'pvscsi') {
467 return 'VMware PVSCSI';
468 } else {
469 return value;
470 }
471 },
472
473 render_spice_enhancements: function(values) {
474 let props = PVE.Parser.parsePropertyString(values);
475 if (Ext.Object.isEmpty(props)) {
476 return Proxmox.Utils.noneText;
477 }
478
479 let output = [];
480 if (PVE.Parser.parseBoolean(props.foldersharing)) {
481 output.push('Folder Sharing: ' + gettext('Enabled'));
482 }
483 if (props.videostreaming === 'all' || props.videostreaming === 'filter') {
484 output.push('Video Streaming: ' + props.videostreaming);
485 }
486 return output.join(', ');
487 },
488
489 // fixme: auto-generate this
490 // for now, please keep in sync with PVE::Tools::kvmkeymaps
491 kvm_keymaps: {
492 //ar: 'Arabic',
493 da: 'Danish',
494 de: 'German',
495 'de-ch': 'German (Swiss)',
496 'en-gb': 'English (UK)',
497 'en-us': 'English (USA)',
498 es: 'Spanish',
499 //et: 'Estonia',
500 fi: 'Finnish',
501 //fo: 'Faroe Islands',
502 fr: 'French',
503 'fr-be': 'French (Belgium)',
504 'fr-ca': 'French (Canada)',
505 'fr-ch': 'French (Swiss)',
506 //hr: 'Croatia',
507 hu: 'Hungarian',
508 is: 'Icelandic',
509 it: 'Italian',
510 ja: 'Japanese',
511 lt: 'Lithuanian',
512 //lv: 'Latvian',
513 mk: 'Macedonian',
514 nl: 'Dutch',
515 //'nl-be': 'Dutch (Belgium)',
516 no: 'Norwegian',
517 pl: 'Polish',
518 pt: 'Portuguese',
519 'pt-br': 'Portuguese (Brazil)',
520 //ru: 'Russian',
521 sl: 'Slovenian',
522 sv: 'Swedish',
523 //th: 'Thai',
524 tr: 'Turkish'
525 },
526
527 kvm_vga_drivers: {
528 std: gettext('Standard VGA'),
529 vmware: gettext('VMware compatible'),
530 qxl: 'SPICE',
531 qxl2: 'SPICE dual monitor',
532 qxl3: 'SPICE three monitors',
533 qxl4: 'SPICE four monitors',
534 serial0: gettext('Serial terminal') + ' 0',
535 serial1: gettext('Serial terminal') + ' 1',
536 serial2: gettext('Serial terminal') + ' 2',
537 serial3: gettext('Serial terminal') + ' 3',
538 virtio: 'VirtIO-GPU',
539 none: Proxmox.Utils.noneText
540 },
541
542 render_kvm_language: function (value) {
543 if (!value || value === '__default__') {
544 return Proxmox.Utils.defaultText;
545 }
546 var text = PVE.Utils.kvm_keymaps[value];
547 if (text) {
548 return text + ' (' + value + ')';
549 }
550 return value;
551 },
552
553 kvm_keymap_array: function() {
554 var data = [['__default__', PVE.Utils.render_kvm_language('')]];
555 Ext.Object.each(PVE.Utils.kvm_keymaps, function(key, value) {
556 data.push([key, PVE.Utils.render_kvm_language(value)]);
557 });
558
559 return data;
560 },
561
562 console_map: {
563 '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
564 'vv': 'SPICE (remote-viewer)',
565 'html5': 'HTML5 (noVNC)',
566 'xtermjs': 'xterm.js'
567 },
568
569 render_console_viewer: function(value) {
570 value = value || '__default__';
571 if (PVE.Utils.console_map[value]) {
572 return PVE.Utils.console_map[value];
573 }
574 return value;
575 },
576
577 console_viewer_array: function() {
578 return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) {
579 return [v, PVE.Utils.render_console_viewer(v)];
580 });
581 },
582
583 render_kvm_vga_driver: function (value) {
584 if (!value) {
585 return Proxmox.Utils.defaultText;
586 }
587 var vga = PVE.Parser.parsePropertyString(value, 'type');
588 var text = PVE.Utils.kvm_vga_drivers[vga.type];
589 if (!vga.type) {
590 text = Proxmox.Utils.defaultText;
591 }
592 if (text) {
593 return text + ' (' + value + ')';
594 }
595 return value;
596 },
597
598 kvm_vga_driver_array: function() {
599 var data = [['__default__', PVE.Utils.render_kvm_vga_driver('')]];
600 Ext.Object.each(PVE.Utils.kvm_vga_drivers, function(key, value) {
601 data.push([key, PVE.Utils.render_kvm_vga_driver(value)]);
602 });
603
604 return data;
605 },
606
607 render_kvm_startup: function(value) {
608 var startup = PVE.Parser.parseStartup(value);
609
610 var res = 'order=';
611 if (startup.order === undefined) {
612 res += 'any';
613 } else {
614 res += startup.order;
615 }
616 if (startup.up !== undefined) {
617 res += ',up=' + startup.up;
618 }
619 if (startup.down !== undefined) {
620 res += ',down=' + startup.down;
621 }
622
623 return res;
624 },
625
626 extractFormActionError: function(action) {
627 var msg;
628 switch (action.failureType) {
629 case Ext.form.action.Action.CLIENT_INVALID:
630 msg = gettext('Form fields may not be submitted with invalid values');
631 break;
632 case Ext.form.action.Action.CONNECT_FAILURE:
633 msg = gettext('Connection error');
634 var resp = action.response;
635 if (resp.status && resp.statusText) {
636 msg += " " + resp.status + ": " + resp.statusText;
637 }
638 break;
639 case Ext.form.action.Action.LOAD_FAILURE:
640 case Ext.form.action.Action.SERVER_INVALID:
641 msg = Proxmox.Utils.extractRequestError(action.result, true);
642 break;
643 }
644 return msg;
645 },
646
647 contentTypes: {
648 'images': gettext('Disk image'),
649 'backup': gettext('VZDump backup file'),
650 'vztmpl': gettext('Container template'),
651 'iso': gettext('ISO image'),
652 'rootdir': gettext('Container'),
653 'snippets': gettext('Snippets')
654 },
655
656 volume_is_qemu_backup: function(volid, format) {
657 return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-');
658 },
659
660 volume_is_lxc_backup: function(volid, format) {
661 return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
662 },
663
664 authSchema: {
665 ad: {
666 name: gettext('Active Directory Server'),
667 ipanel: 'pveAuthADPanel',
668 syncipanel: 'pveAuthLDAPSyncPanel',
669 add: true,
670 },
671 ldap: {
672 name: gettext('LDAP Server'),
673 ipanel: 'pveAuthLDAPPanel',
674 syncipanel: 'pveAuthLDAPSyncPanel',
675 add: true,
676 },
677 pam: {
678 name: 'Linux PAM',
679 ipanel: 'pveAuthBasePanel',
680 add: false,
681 },
682 pve: {
683 name: 'Proxmox VE authentication server',
684 ipanel: 'pveAuthBasePanel',
685 add: false,
686 },
687 },
688
689 storageSchema: {
690 dir: {
691 name: Proxmox.Utils.directoryText,
692 ipanel: 'DirInputPanel',
693 faIcon: 'folder'
694 },
695 lvm: {
696 name: 'LVM',
697 ipanel: 'LVMInputPanel',
698 faIcon: 'folder'
699 },
700 lvmthin: {
701 name: 'LVM-Thin',
702 ipanel: 'LvmThinInputPanel',
703 faIcon: 'folder'
704 },
705 nfs: {
706 name: 'NFS',
707 ipanel: 'NFSInputPanel',
708 faIcon: 'building'
709 },
710 cifs: {
711 name: 'CIFS',
712 ipanel: 'CIFSInputPanel',
713 faIcon: 'building'
714 },
715 glusterfs: {
716 name: 'GlusterFS',
717 ipanel: 'GlusterFsInputPanel',
718 faIcon: 'building'
719 },
720 iscsi: {
721 name: 'iSCSI',
722 ipanel: 'IScsiInputPanel',
723 faIcon: 'building'
724 },
725 cephfs: {
726 name: 'CephFS',
727 ipanel: 'CephFSInputPanel',
728 faIcon: 'building'
729 },
730 pvecephfs: {
731 name: 'CephFS (PVE)',
732 ipanel: 'CephFSInputPanel',
733 hideAdd: true,
734 faIcon: 'building'
735 },
736 rbd: {
737 name: 'RBD',
738 ipanel: 'RBDInputPanel',
739 faIcon: 'building'
740 },
741 pveceph: {
742 name: 'RBD (PVE)',
743 ipanel: 'RBDInputPanel',
744 hideAdd: true,
745 faIcon: 'building'
746 },
747 zfs: {
748 name: 'ZFS over iSCSI',
749 ipanel: 'ZFSInputPanel',
750 faIcon: 'building'
751 },
752 zfspool: {
753 name: 'ZFS',
754 ipanel: 'ZFSPoolInputPanel',
755 faIcon: 'folder'
756 },
757 pbs: {
758 name: 'Proxmox Backup Server',
759 ipanel: 'PBSInputPanel',
760 faIcon: 'floppy-o',
761 },
762 drbd: {
763 name: 'DRBD',
764 hideAdd: true,
765 },
766 },
767
768 sdnvnetSchema: {
769 vnet: {
770 name: 'vnet',
771 faIcon: 'folder'
772 },
773 },
774
775 sdnzoneSchema: {
776 zone: {
777 name: 'zone',
778 hideAdd: true
779 },
780 simple: {
781 name: 'Simple',
782 ipanel: 'SimpleInputPanel',
783 faIcon: 'th'
784 },
785 vlan: {
786 name: 'VLAN',
787 ipanel: 'VlanInputPanel',
788 faIcon: 'th'
789 },
790 qinq: {
791 name: 'QinQ',
792 ipanel: 'QinQInputPanel',
793 faIcon: 'th'
794 },
795 vxlan: {
796 name: 'VXLAN',
797 ipanel: 'VxlanInputPanel',
798 faIcon: 'th'
799 },
800 evpn: {
801 name: 'EVPN',
802 ipanel: 'EvpnInputPanel',
803 faIcon: 'th'
804 },
805 },
806
807 sdncontrollerSchema: {
808 controller: {
809 name: 'controller',
810 hideAdd: true
811 },
812 evpn: {
813 name: 'evpn',
814 ipanel: 'EvpnInputPanel',
815 faIcon: 'crosshairs'
816 },
817 },
818
819 format_sdnvnet_type: function(value, md, record) {
820 var schema = PVE.Utils.sdnvnetSchema[value];
821 if (schema) {
822 return schema.name;
823 }
824 return Proxmox.Utils.unknownText;
825 },
826
827 format_sdnzone_type: function(value, md, record) {
828 var schema = PVE.Utils.sdnzoneSchema[value];
829 if (schema) {
830 return schema.name;
831 }
832 return Proxmox.Utils.unknownText;
833 },
834
835 format_sdncontroller_type: function(value, md, record) {
836 var schema = PVE.Utils.sdncontrollerSchema[value];
837 if (schema) {
838 return schema.name;
839 }
840 return Proxmox.Utils.unknownText;
841 },
842
843 format_storage_type: function(value, md, record) {
844 if (value === 'rbd') {
845 value = (!record || record.get('monhost') ? 'rbd' : 'pveceph');
846 } else if (value === 'cephfs') {
847 value = (!record || record.get('monhost') ? 'cephfs' : 'pvecephfs');
848 }
849
850 var schema = PVE.Utils.storageSchema[value];
851 if (schema) {
852 return schema.name;
853 }
854 return Proxmox.Utils.unknownText;
855 },
856
857 format_ha: function(value) {
858 var text = Proxmox.Utils.noneText;
859
860 if (value.managed) {
861 text = value.state || Proxmox.Utils.noneText;
862
863 text += ', ' + Proxmox.Utils.groupText + ': ';
864 text += value.group || Proxmox.Utils.noneText;
865 }
866
867 return text;
868 },
869
870 format_content_types: function(value) {
871 return value.split(',').sort().map(function(ct) {
872 return PVE.Utils.contentTypes[ct] || ct;
873 }).join(', ');
874 },
875
876 render_storage_content: function(value, metaData, record) {
877 var data = record.data;
878 if (Ext.isNumber(data.channel) &&
879 Ext.isNumber(data.id) &&
880 Ext.isNumber(data.lun)) {
881 return "CH " +
882 Ext.String.leftPad(data.channel,2, '0') +
883 " ID " + data.id + " LUN " + data.lun;
884 }
885 return data.volid.replace(/^.*?:(.*?\/)?/,'');
886 },
887
888 render_serverity: function (value) {
889 return PVE.Utils.log_severity_hash[value] || value;
890 },
891
892 render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {
893
894 if (!(record.data.uptime && Ext.isNumeric(value))) {
895 return '';
896 }
897
898 var maxcpu = record.data.maxcpu || 1;
899
900 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
901 return '';
902 }
903
904 var per = value * 100;
905
906 return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
907 },
908
909 render_size: function(value, metaData, record, rowIndex, colIndex, store) {
910
911 if (!Ext.isNumeric(value)) {
912 return '';
913 }
914
915 return Proxmox.Utils.format_size(value);
916 },
917
918 render_bandwidth: function(value) {
919 if (!Ext.isNumeric(value)) {
920 return '';
921 }
922
923 return Proxmox.Utils.format_size(value) + '/s';
924 },
925
926 render_timestamp_human_readable: function(value) {
927 return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
928 },
929
930 calculate_mem_usage: function(data) {
931 if (!Ext.isNumeric(data.mem) ||
932 data.maxmem === 0 ||
933 data.uptime < 1) {
934 return -1;
935 }
936
937 return (data.mem / data.maxmem);
938 },
939
940 render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
941 if (!Ext.isNumeric(value) || value === -1) {
942 return '';
943 }
944 if (value > 1 ) {
945 // we got no percentage but bytes
946 var mem = value;
947 var maxmem = record.data.maxmem;
948 if (!record.data.uptime ||
949 maxmem === 0 ||
950 !Ext.isNumeric(mem)) {
951 return '';
952 }
953
954 return ((mem*100)/maxmem).toFixed(1) + " %";
955 }
956 return (value*100).toFixed(1) + " %";
957 },
958
959 render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
960
961 var mem = value;
962 var maxmem = record.data.maxmem;
963
964 if (!record.data.uptime) {
965 return '';
966 }
967
968 if (!(Ext.isNumeric(mem) && maxmem)) {
969 return '';
970 }
971
972 return PVE.Utils.render_size(value);
973 },
974
975 calculate_disk_usage: function(data) {
976
977 if (!Ext.isNumeric(data.disk) ||
978 data.type === 'qemu' ||
979 (data.type === 'lxc' && data.uptime === 0) ||
980 data.maxdisk === 0) {
981 return -1;
982 }
983
984 return (data.disk / data.maxdisk);
985 },
986
987 render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
988 if (!Ext.isNumeric(value) || value === -1) {
989 return '';
990 }
991
992 return (value * 100).toFixed(1) + " %";
993 },
994
995 render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
996
997 var disk = value;
998 var maxdisk = record.data.maxdisk;
999 var type = record.data.type;
1000
1001 if (!Ext.isNumeric(disk) ||
1002 type === 'qemu' ||
1003 maxdisk === 0 ||
1004 (type === 'lxc' && record.data.uptime === 0)) {
1005 return '';
1006 }
1007
1008 return PVE.Utils.render_size(value);
1009 },
1010
1011 get_object_icon_class: function(type, record) {
1012 var status = '';
1013 var objType = type;
1014
1015 if (type === 'type') {
1016 // for folder view
1017 objType = record.groupbyid;
1018 } else if (record.template) {
1019 // templates
1020 objType = 'template';
1021 status = type;
1022 } else {
1023 // everything else
1024 status = record.status + ' ha-' + record.hastate;
1025 }
1026
1027 if (record.lock) {
1028 status += ' locked lock-' + record.lock;
1029 }
1030
1031 var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
1032 if (defaults && defaults.iconCls) {
1033 var retVal = defaults.iconCls + ' ' + status;
1034 return retVal;
1035 }
1036
1037 return '';
1038 },
1039
1040 render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
1041
1042 var cls = PVE.Utils.get_object_icon_class(value,record.data);
1043
1044 var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
1045 return fa + value;
1046 },
1047
1048 render_support_level: function(value, metaData, record) {
1049 return PVE.Utils.support_level_hash[value] || '-';
1050 },
1051
1052 render_upid: function(value, metaData, record) {
1053 var type = record.data.type;
1054 var id = record.data.id;
1055
1056 return Proxmox.Utils.format_task_description(type, id);
1057 },
1058
1059 /* render functions for new status panel */
1060
1061 render_usage: function(val) {
1062 return (val*100).toFixed(2) + '%';
1063 },
1064
1065 render_cpu_usage: function(val, max) {
1066 return Ext.String.format(gettext('{0}% of {1}') +
1067 ' ' + gettext('CPU(s)'), (val*100).toFixed(2), max);
1068 },
1069
1070 render_size_usage: function(val, max) {
1071 if (max === 0) {
1072 return gettext('N/A');
1073 }
1074 return (val*100/max).toFixed(2) + '% '+ '(' +
1075 Ext.String.format(gettext('{0} of {1}'),
1076 PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')';
1077 },
1078
1079 /* this is different for nodes */
1080 render_node_cpu_usage: function(value, record) {
1081 return PVE.Utils.render_cpu_usage(value, record.cpus);
1082 },
1083
1084 /* this is different for nodes */
1085 render_node_size_usage: function(record) {
1086 return PVE.Utils.render_size_usage(record.used, record.total);
1087 },
1088
1089 render_optional_url: function(value) {
1090 var match;
1091 if (value && (match = value.match(/^https?:\/\//)) !== null) {
1092 return '<a target="_blank" href="' + value + '">' + value + '</a>';
1093 }
1094 return value;
1095 },
1096
1097 render_san: function(value) {
1098 var names = [];
1099 if (Ext.isArray(value)) {
1100 value.forEach(function(val) {
1101 if (!Ext.isNumber(val)) {
1102 names.push(val);
1103 }
1104 });
1105 return names.join('<br>');
1106 }
1107 return value;
1108 },
1109
1110 render_full_name: function(firstname, metaData, record) {
1111 var first = firstname || '';
1112 var last = record.data.lastname || '';
1113 return Ext.htmlEncode(first + " " + last);
1114 },
1115
1116 render_u2f_error: function(error) {
1117 var ErrorNames = {
1118 '1': gettext('Other Error'),
1119 '2': gettext('Bad Request'),
1120 '3': gettext('Configuration Unsupported'),
1121 '4': gettext('Device Ineligible'),
1122 '5': gettext('Timeout')
1123 };
1124 return "U2F Error: " + ErrorNames[error] || Proxmox.Utils.unknownText;
1125 },
1126
1127 windowHostname: function() {
1128 return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
1129 function(m, addr, offset, original) { return addr; });
1130 },
1131
1132 openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) {
1133 var dv = PVE.Utils.defaultViewer(consoles);
1134 PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd);
1135 },
1136
1137 openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) {
1138 if (vmid == undefined && (consoleType === 'kvm' || consoleType === 'lxc')) {
1139 throw "missing vmid";
1140 }
1141 if (!nodename) {
1142 throw "no nodename specified";
1143 }
1144
1145 if (viewer === 'html5') {
1146 PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd);
1147 } else if (viewer === 'xtermjs') {
1148 Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd);
1149 } else if (viewer === 'vv') {
1150 let url = '/nodes/' + nodename + '/spiceshell';
1151 let params = {
1152 proxy: PVE.Utils.windowHostname(),
1153 };
1154 if (consoleType === 'kvm') {
1155 url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
1156 } else if (consoleType === 'lxc') {
1157 url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
1158 } else if (consoleType === 'upgrade') {
1159 params.cmd = 'upgrade';
1160 } else if (consoleType === 'cmd') {
1161 params.cmd = cmd;
1162 } else if (consoleType !== 'shell') {
1163 throw `unknown spice viewer type '${consoleType}'`;
1164 }
1165 PVE.Utils.openSpiceViewer(url, params);
1166 } else {
1167 throw `unknown viewer type '${viewer}'`;
1168 }
1169 },
1170
1171 defaultViewer: function(consoles) {
1172
1173 var allowSpice, allowXtermjs;
1174
1175 if (consoles === true) {
1176 allowSpice = true;
1177 allowXtermjs = true;
1178 } else if (typeof consoles === 'object') {
1179 allowSpice = consoles.spice;
1180 allowXtermjs = !!consoles.xtermjs;
1181 }
1182 var dv = PVE.VersionInfo.console || 'xtermjs';
1183 if (dv === 'vv' && !allowSpice) {
1184 dv = (allowXtermjs) ? 'xtermjs' : 'html5';
1185 } else if (dv === 'xtermjs' && !allowXtermjs) {
1186 dv = (allowSpice) ? 'vv' : 'html5';
1187 }
1188
1189 return dv;
1190 },
1191
1192 openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
1193 let scaling = 'off';
1194 if (Proxmox.Utils.toolkit !== 'touch') {
1195 var sp = Ext.state.Manager.getProvider();
1196 scaling = sp.get('novnc-scaling', 'off');
1197 }
1198 var url = Ext.Object.toQueryString({
1199 console: vmtype, // kvm, lxc, upgrade or shell
1200 novnc: 1,
1201 vmid: vmid,
1202 vmname: vmname,
1203 node: nodename,
1204 resize: scaling,
1205 cmd: cmd
1206 });
1207 var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
1208 if (nw) {
1209 nw.focus();
1210 }
1211 },
1212
1213 openSpiceViewer: function(url, params){
1214
1215 var downloadWithName = function(uri, name) {
1216 var link = Ext.DomHelper.append(document.body, {
1217 tag: 'a',
1218 href: uri,
1219 css : 'display:none;visibility:hidden;height:0px;'
1220 });
1221
1222 // Note: we need to tell android the correct file name extension
1223 // but we do not set 'download' tag for other environments, because
1224 // It can have strange side effects (additional user prompt on firefox)
1225 var andriod = navigator.userAgent.match(/Android/i) ? true : false;
1226 if (andriod) {
1227 link.download = name;
1228 }
1229
1230 if (link.fireEvent) {
1231 link.fireEvent('onclick');
1232 } else {
1233 let evt = document.createEvent("MouseEvents");
1234 evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
1235 link.dispatchEvent(evt);
1236 }
1237 };
1238
1239 Proxmox.Utils.API2Request({
1240 url: url,
1241 params: params,
1242 method: 'POST',
1243 failure: function(response, opts){
1244 Ext.Msg.alert('Error', response.htmlStatus);
1245 },
1246 success: function(response, opts){
1247 var raw = "[virt-viewer]\n";
1248 Ext.Object.each(response.result.data, function(k, v) {
1249 raw += k + "=" + v + "\n";
1250 });
1251 var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
1252 encodeURIComponent(raw);
1253
1254 downloadWithName(url, "pve-spice.vv");
1255 }
1256 });
1257 },
1258
1259 openTreeConsole: function(tree, record, item, index, e) {
1260 e.stopEvent();
1261 var nodename = record.data.node;
1262 var vmid = record.data.vmid;
1263 var vmname = record.data.name;
1264 if (record.data.type === 'qemu' && !record.data.template) {
1265 Proxmox.Utils.API2Request({
1266 url: '/nodes/' + nodename + '/qemu/' + vmid + '/status/current',
1267 failure: function(response, opts) {
1268 Ext.Msg.alert('Error', response.htmlStatus);
1269 },
1270 success: function(response, opts) {
1271 let conf = response.result.data;
1272 var consoles = {
1273 spice: !!conf.spice,
1274 xtermjs: !!conf.serial,
1275 };
1276 PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
1277 }
1278 });
1279 } else if (record.data.type === 'lxc' && !record.data.template) {
1280 PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
1281 }
1282 },
1283
1284 // test automation helper
1285 call_menu_handler: function(menu, text) {
1286
1287 var list = menu.query('menuitem');
1288
1289 Ext.Array.each(list, function(item) {
1290 if (item.text === text) {
1291 if (item.handler) {
1292 item.handler();
1293 return 1;
1294 } else {
1295 return undefined;
1296 }
1297 }
1298 });
1299 },
1300
1301 createCmdMenu: function(v, record, item, index, event) {
1302 event.stopEvent();
1303 if (!(v instanceof Ext.tree.View)) {
1304 v.select(record);
1305 }
1306 var menu;
1307 var template = !!record.data.template;
1308 var type = record.data.type;
1309
1310 if (template) {
1311 if (type === 'qemu' || type == 'lxc') {
1312 menu = Ext.create('PVE.menu.TemplateMenu', {
1313 pveSelNode: record
1314 });
1315 }
1316 } else if (type === 'qemu' ||
1317 type === 'lxc' ||
1318 type === 'node') {
1319 menu = Ext.create('PVE.' + type + '.CmdMenu', {
1320 pveSelNode: record,
1321 nodename: record.data.node
1322 });
1323 } else {
1324 return;
1325 }
1326
1327 menu.showAt(event.getXY());
1328 return menu;
1329 },
1330
1331 // helper for deleting field which are set to there default values
1332 delete_if_default: function(values, fieldname, default_val, create) {
1333 if (values[fieldname] === '' || values[fieldname] === default_val) {
1334 if (!create) {
1335 if (values['delete']) {
1336 if (Ext.isArray(values['delete'])) {
1337 values['delete'].push(fieldname);
1338 } else {
1339 values['delete'] += ',' + fieldname;
1340 }
1341 } else {
1342 values['delete'] = fieldname;
1343 }
1344 }
1345
1346 delete values[fieldname];
1347 }
1348 },
1349
1350 loadSSHKeyFromFile: function(file, callback) {
1351 // ssh-keygen produces 740 bytes for an average 4096 bit rsa key, with
1352 // a user@host comment, 1420 for 8192 bits; current max is 16kbit
1353 // assume: 740*8 for max. 32kbit (5920 byte file)
1354 // round upwards to nearest nice number => 8192 bytes, leaves lots of comment space
1355 if (file.size > 8192) {
1356 Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
1357 return;
1358 }
1359 /*global
1360 FileReader
1361 */
1362 var reader = new FileReader();
1363 reader.onload = function(evt) {
1364 callback(evt.target.result);
1365 };
1366 reader.readAsText(file);
1367 },
1368
1369 loadTextFromFile: function(file, callback, maxBytes) {
1370 let maxSize = maxBytes || 8192;
1371 if (file.size > maxSize) {
1372 Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
1373 return;
1374 }
1375 /*global
1376 FileReader
1377 */
1378 let reader = new FileReader();
1379 reader.onload = evt => callback(evt.target.result);
1380 reader.readAsText(file);
1381 },
1382
1383 diskControllerMaxIDs: {
1384 ide: 4,
1385 sata: 6,
1386 scsi: 31,
1387 virtio: 16,
1388 },
1389
1390 // types is either undefined (all busses), an array of busses, or a single bus
1391 forEachBus: function(types, func) {
1392 var busses = Object.keys(PVE.Utils.diskControllerMaxIDs);
1393 var i, j, count, cont;
1394
1395 if (Ext.isArray(types)) {
1396 busses = types;
1397 } else if (Ext.isDefined(types)) {
1398 busses = [ types ];
1399 }
1400
1401 // check if we only have valid busses
1402 for (i = 0; i < busses.length; i++) {
1403 if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) {
1404 throw "invalid bus: '" + busses[i] + "'";
1405 }
1406 }
1407
1408 for (i = 0; i < busses.length; i++) {
1409 count = PVE.Utils.diskControllerMaxIDs[busses[i]];
1410 for (j = 0; j < count; j++) {
1411 cont = func(busses[i], j);
1412 if (!cont && cont !== undefined) {
1413 return;
1414 }
1415 }
1416 }
1417 },
1418
1419 mp_counts: { mps: 256, unused: 256 },
1420
1421 forEachMP: function(func, includeUnused) {
1422 var i, cont;
1423 for (i = 0; i < PVE.Utils.mp_counts.mps; i++) {
1424 cont = func('mp', i);
1425 if (!cont && cont !== undefined) {
1426 return;
1427 }
1428 }
1429
1430 if (!includeUnused) {
1431 return;
1432 }
1433
1434 for (i = 0; i < PVE.Utils.mp_counts.unused; i++) {
1435 cont = func('unused', i);
1436 if (!cont && cont !== undefined) {
1437 return;
1438 }
1439 }
1440 },
1441
1442 hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1 },
1443
1444 cleanEmptyObjectKeys: function (obj) {
1445 var propName;
1446 for (propName in obj) {
1447 if (obj.hasOwnProperty(propName)) {
1448 if (obj[propName] === null || obj[propName] === undefined) {
1449 delete obj[propName];
1450 }
1451 }
1452 }
1453 },
1454
1455 acmedomain_count: 5,
1456
1457 add_domain_to_acme: function(acme, domain) {
1458 if (acme.domains === undefined) {
1459 acme.domains = [domain];
1460 } else {
1461 acme.domains.push(domain);
1462 acme.domains = acme.domains.filter((value, index, self) => {
1463 return self.indexOf(value) === index;
1464 });
1465 }
1466 return acme;
1467 },
1468
1469 remove_domain_from_acme: function(acme, domain) {
1470 if (acme.domains !== undefined) {
1471 acme.domains = acme.domains.filter((value, index, self) => {
1472 return self.indexOf(value) === index && value !== domain;
1473 });
1474 }
1475 return acme;
1476 },
1477
1478 handleStoreErrorOrMask: function(me, store, regex, callback) {
1479
1480 me.mon(store, 'load', function (proxy, response, success, operation) {
1481
1482 if (success) {
1483 Proxmox.Utils.setErrorMask(me, false);
1484 return;
1485 }
1486 var msg;
1487
1488 if (operation.error.statusText) {
1489 if (operation.error.statusText.match(regex)) {
1490 callback(me, operation.error);
1491 return;
1492 } else {
1493 msg = operation.error.statusText + ' (' + operation.error.status + ')';
1494 }
1495 } else {
1496 msg = gettext('Connection error');
1497 }
1498 Proxmox.Utils.setErrorMask(me, msg);
1499 });
1500 },
1501
1502 showCephInstallOrMask: function(container, msg, nodename, callback){
1503 var regex = new RegExp("not (installed|initialized)", "i");
1504 if (msg.match(regex)) {
1505 if (Proxmox.UserName === 'root@pam') {
1506 container.el.mask();
1507 if (!container.down('pveCephInstallWindow')){
1508 var isInstalled = msg.match(/not initialized/i) ? true : false;
1509 var win = Ext.create('PVE.ceph.Install', {
1510 nodename: nodename
1511 });
1512 win.getViewModel().set('isInstalled', isInstalled);
1513 container.add(win);
1514 win.show();
1515 callback(win);
1516 }
1517 } else {
1518 container.mask(Ext.String.format(gettext('{0} not installed.') +
1519 ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
1520 }
1521 return true;
1522 } else {
1523 return false;
1524 }
1525 },
1526
1527 propertyStringSet: function(target, source, name, value) {
1528 if (source) {
1529 if (value === undefined) {
1530 target[name] = source;
1531 } else {
1532 target[name] = value;
1533 }
1534 } else {
1535 delete target[name];
1536 }
1537 },
1538
1539 updateColumns: function(container) {
1540 let mode = Ext.state.Manager.get('summarycolumns') || 'auto';
1541 let factor;
1542 if (mode !== 'auto') {
1543 factor = parseInt(mode, 10);
1544 if (Number.isNaN(factor)) {
1545 factor = 1;
1546 }
1547 } else {
1548 factor = container.getSize().width < 1400 ? 1 : 2;
1549 }
1550
1551 if (container.oldFactor === factor) {
1552 return;
1553 }
1554
1555 let items = container.query('>'); // direct childs
1556 factor = Math.min(factor, items.length);
1557 container.oldFactor = factor;
1558
1559 items.forEach((item) => {
1560 item.columnWidth = 1 / factor;
1561 });
1562
1563 // we have to update the layout twice, since the first layout change
1564 // can trigger the scrollbar which reduces the amount of space left
1565 container.updateLayout();
1566 container.updateLayout();
1567 },
1568
1569 forEachCorosyncLink: function(nodeinfo, cb) {
1570 let re = /(?:ring|link)(\d+)_addr/;
1571 Ext.iterate(nodeinfo, (prop, val) => {
1572 let match = re.exec(prop);
1573 if (match) {
1574 cb(Number(match[1]), val);
1575 }
1576 });
1577 },
1578
1579 cpu_vendor_map: {
1580 'default': 'QEMU',
1581 'AuthenticAMD': 'AMD',
1582 'GenuineIntel': 'Intel'
1583 },
1584
1585 cpu_vendor_order: {
1586 "AMD": 1,
1587 "Intel": 2,
1588 "QEMU": 3,
1589 "Host": 4,
1590 "_default_": 5, // includes custom models
1591 },
1592 },
1593
1594 singleton: true,
1595 constructor: function() {
1596 var me = this;
1597 Ext.apply(me, me.utilities);
1598
1599 Proxmox.Utils.override_task_descriptions({
1600 acmedeactivate: ['ACME Account', gettext('Deactivate')],
1601 acmenewcert: ['SRV', gettext('Order Certificate')],
1602 acmerefresh: ['ACME Account', gettext('Refresh')],
1603 acmeregister: ['ACME Account', gettext('Register')],
1604 acmerenew: ['SRV', gettext('Renew Certificate')],
1605 acmerevoke: ['SRV', gettext('Revoke Certificate')],
1606 acmeupdate: ['ACME Account', gettext('Update')],
1607 'auth-realm-sync': [gettext('Realm'), gettext('Sync')],
1608 'auth-realm-sync-test': [gettext('Realm'), gettext('Sync Preview')],
1609 cephcreatemds: ['Ceph Metadata Server', gettext('Create')],
1610 cephcreatemgr: ['Ceph Manager', gettext('Create')],
1611 cephcreatemon: ['Ceph Monitor', gettext('Create')],
1612 cephcreateosd: ['Ceph OSD', gettext('Create')],
1613 cephcreatepool: ['Ceph Pool', gettext('Create')],
1614 cephdestroymds: ['Ceph Metadata Server', gettext('Destroy')],
1615 cephdestroymgr: ['Ceph Manager', gettext('Destroy')],
1616 cephdestroymon: ['Ceph Monitor', gettext('Destroy')],
1617 cephdestroyosd: ['Ceph OSD', gettext('Destroy')],
1618 cephdestroypool: ['Ceph Pool', gettext('Destroy')],
1619 cephfscreate: ['CephFS', gettext('Create')],
1620 clustercreate: ['', gettext('Create Cluster')],
1621 clusterjoin: ['', gettext('Join Cluster')],
1622 dircreate: [gettext('Directory Storage'), gettext('Create')],
1623 dirremove: [gettext('Directory'), gettext('Remove')],
1624 download: ['', gettext('Download')],
1625 hamigrate: ['HA', gettext('Migrate')],
1626 hashutdown: ['HA', gettext('Shutdown')],
1627 hastart: ['HA', gettext('Start')],
1628 hastop: ['HA', gettext('Stop')],
1629 imgcopy: ['', gettext('Copy data')],
1630 imgdel: ['', gettext('Erase data')],
1631 lvmcreate: [gettext('LVM Storage'), gettext('Create')],
1632 lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
1633 migrateall: ['', gettext('Migrate all VMs and Containers')],
1634 'move_volume': ['CT', gettext('Move Volume')],
1635 pull_file: ['CT', gettext('Pull file')],
1636 push_file: ['CT', gettext('Push file')],
1637 qmclone: ['VM', gettext('Clone')],
1638 qmconfig: ['VM', gettext('Configure')],
1639 qmcreate: ['VM', gettext('Create')],
1640 qmdelsnapshot: ['VM', gettext('Delete Snapshot')],
1641 qmdestroy: ['VM', gettext('Destroy')],
1642 qmigrate: ['VM', gettext('Migrate')],
1643 qmmove: ['VM', gettext('Move disk')],
1644 qmpause: ['VM', gettext('Pause')],
1645 qmreboot: ['VM', gettext('Reboot')],
1646 qmreset: ['VM', gettext('Reset')],
1647 qmrestore: ['VM', gettext('Restore')],
1648 qmresume: ['VM', gettext('Resume')],
1649 qmrollback: ['VM', gettext('Rollback')],
1650 qmshutdown: ['VM', gettext('Shutdown')],
1651 qmsnapshot: ['VM', gettext('Snapshot')],
1652 qmstart: ['VM', gettext('Start')],
1653 qmstop: ['VM', gettext('Stop')],
1654 qmsuspend: ['VM', gettext('Hibernate')],
1655 qmtemplate: ['VM', gettext('Convert to template')],
1656 spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
1657 spiceshell: ['', gettext('Shell') + ' (Spice)'],
1658 startall: ['', gettext('Start all VMs and Containers')],
1659 stopall: ['', gettext('Stop all VMs and Containers')],
1660 unknownimgdel: ['', gettext('Destroy image from unknown guest')],
1661 vncproxy: ['VM/CT', gettext('Console')],
1662 vncshell: ['', gettext('Shell')],
1663 vzclone: ['CT', gettext('Clone')],
1664 vzcreate: ['CT', gettext('Create')],
1665 vzdelsnapshot: ['CT', gettext('Delete Snapshot')],
1666 vzdestroy: ['CT', gettext('Destroy')],
1667 vzdump: (type, id) => id ? `VM/CT ${id} - ${gettext('Backup')}` : gettext('Backup Job'),
1668 vzmigrate: ['CT', gettext('Migrate')],
1669 vzmount: ['CT', gettext('Mount')],
1670 vzreboot: ['CT', gettext('Reboot')],
1671 vzrestore: ['CT', gettext('Restore')],
1672 vzresume: ['CT', gettext('Resume')],
1673 vzrollback: ['CT', gettext('Rollback')],
1674 vzshutdown: ['CT', gettext('Shutdown')],
1675 vzsnapshot: ['CT', gettext('Snapshot')],
1676 vzstart: ['CT', gettext('Start')],
1677 vzstop: ['CT', gettext('Stop')],
1678 vzsuspend: ['CT', gettext('Suspend')],
1679 vztemplate: ['CT', gettext('Convert to template')],
1680 vzumount: ['CT', gettext('Unmount')],
1681 zfscreate: [gettext('ZFS Storage'), gettext('Create')],
1682 });
1683 }
1684
1685 });