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