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