]>
Commit | Line | Data |
---|---|---|
1 | Ext.ns('PVE'); | |
2 | ||
3 | console.log("Starting Proxmox VE Manager"); | |
4 | ||
5 | Ext.Ajax.defaultHeaders = { | |
6 | 'Accept': 'application/json', | |
7 | }; | |
8 | ||
9 | Ext.define('PVE.Utils', { | |
10 | utilities: { | |
11 | ||
12 | // this singleton contains miscellaneous utilities | |
13 | ||
14 | toolkit: undefined, // (extjs|touch), set inside Toolkit.js | |
15 | ||
16 | bus_match: /^(ide|sata|virtio|scsi)(\d+)$/, | |
17 | ||
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", | |
26 | 7: "debug", | |
27 | }, | |
28 | ||
29 | support_level_hash: { | |
30 | 'c': gettext('Community'), | |
31 | 'b': gettext('Basic'), | |
32 | 's': gettext('Standard'), | |
33 | 'p': gettext('Premium'), | |
34 | }, | |
35 | ||
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.', | |
39 | ||
40 | kvm_ostypes: { | |
41 | 'Linux': [ | |
42 | { desc: '5.x - 2.6 Kernel', val: 'l26' }, | |
43 | { desc: '2.4 Kernel', val: 'l24' }, | |
44 | ], | |
45 | 'Microsoft Windows': [ | |
46 | { desc: '11/2022', val: 'win11' }, | |
47 | { desc: '10/2016/2019', val: 'win10' }, | |
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' }, | |
52 | { desc: '2000', val: 'w2k' }, | |
53 | ], | |
54 | 'Solaris Kernel': [ | |
55 | { desc: '-', val: 'solaris' }, | |
56 | ], | |
57 | 'Other': [ | |
58 | { desc: '-', val: 'other' }, | |
59 | ], | |
60 | }, | |
61 | ||
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 | ||
71 | get_health_icon: function(state, circle) { | |
72 | if (circle === undefined) { | |
73 | circle = false; | |
74 | } | |
75 | ||
76 | if (state === undefined) { | |
77 | state = 'uknown'; | |
78 | } | |
79 | ||
80 | var icon = 'faded fa-question'; | |
81 | switch (state) { | |
82 | case 'good': | |
83 | icon = 'good fa-check'; | |
84 | break; | |
85 | case 'upgrade': | |
86 | icon = 'warning fa-upload'; | |
87 | break; | |
88 | case 'old': | |
89 | icon = 'warning fa-refresh'; | |
90 | break; | |
91 | case 'warning': | |
92 | icon = 'warning fa-exclamation'; | |
93 | break; | |
94 | case 'critical': | |
95 | icon = 'critical fa-times'; | |
96 | break; | |
97 | default: break; | |
98 | } | |
99 | ||
100 | if (circle) { | |
101 | icon += '-circle'; | |
102 | } | |
103 | ||
104 | return icon; | |
105 | }, | |
106 | ||
107 | parse_ceph_version: function(service) { | |
108 | if (service.ceph_version_short) { | |
109 | return service.ceph_version_short; | |
110 | } | |
111 | ||
112 | if (service.ceph_version) { | |
113 | var match = service.ceph_version.match(/version (\d+(\.\d+)*)/); | |
114 | if (match) { | |
115 | return match[1]; | |
116 | } | |
117 | } | |
118 | ||
119 | return undefined; | |
120 | }, | |
121 | ||
122 | compare_ceph_versions: function(a, b) { | |
123 | let avers = []; | |
124 | let bvers = []; | |
125 | ||
126 | if (a === b) { | |
127 | return 0; | |
128 | } | |
129 | ||
130 | if (Ext.isArray(a)) { | |
131 | avers = a.slice(); // copy array | |
132 | } else { | |
133 | avers = a.toString().split('.'); | |
134 | } | |
135 | ||
136 | if (Ext.isArray(b)) { | |
137 | bvers = b.slice(); // copy array | |
138 | } else { | |
139 | bvers = b.toString().split('.'); | |
140 | } | |
141 | ||
142 | for (;;) { | |
143 | let av = avers.shift(); | |
144 | let bv = bvers.shift(); | |
145 | ||
146 | if (av === undefined && bv === undefined) { | |
147 | return 0; | |
148 | } else if (av === undefined) { | |
149 | return -1; | |
150 | } else if (bv === undefined) { | |
151 | return 1; | |
152 | } else { | |
153 | let diff = parseInt(av, 10) - parseInt(bv, 10); | |
154 | if (diff !== 0) return diff; | |
155 | // else we need to look at the next parts | |
156 | } | |
157 | } | |
158 | }, | |
159 | ||
160 | 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 | ||
169 | map_ceph_health: { | |
170 | 'HEALTH_OK': 'good', | |
171 | 'HEALTH_UPGRADE': 'upgrade', | |
172 | 'HEALTH_OLD': 'old', | |
173 | 'HEALTH_WARN': 'warning', | |
174 | 'HEALTH_ERR': 'critical', | |
175 | }, | |
176 | ||
177 | render_sdn_pending: function(rec, value, key, index) { | |
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 | } | |
188 | } else if (rec.data.pending[key] !== undefined && rec.data.pending[key] !== null) { | |
189 | if (rec.data.pending[key] === 'deleted') { | |
190 | return ' '; | |
191 | } else { | |
192 | return rec.data.pending[key]; | |
193 | } | |
194 | } | |
195 | return value; | |
196 | }, | |
197 | ||
198 | render_sdn_pending_state: function(rec, value) { | |
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 | ||
209 | let tip = gettext('Pending Changes') + ': <br>'; | |
210 | ||
211 | for (const [key, keyvalue] of Object.entries(rec.data.pending)) { | |
212 | if ((rec.data[key] !== undefined && rec.data.pending[key] !== rec.data[key]) || | |
213 | rec.data[key] === undefined | |
214 | ) { | |
215 | tip += `${key}: ${keyvalue} <br>`; | |
216 | } | |
217 | } | |
218 | return '<span data-qtip="' + tip + '">'+ icon + value + '</span>'; | |
219 | }, | |
220 | ||
221 | render_ceph_health: function(healthObj) { | |
222 | var state = { | |
223 | iconCls: PVE.Utils.get_health_icon(), | |
224 | text: '', | |
225 | }; | |
226 | ||
227 | if (!healthObj || !healthObj.status) { | |
228 | return state; | |
229 | } | |
230 | ||
231 | var health = PVE.Utils.map_ceph_health[healthObj.status]; | |
232 | ||
233 | state.iconCls = PVE.Utils.get_health_icon(health, true); | |
234 | state.text = healthObj.status; | |
235 | ||
236 | return state; | |
237 | }, | |
238 | ||
239 | render_zfs_health: function(value) { | |
240 | if (typeof value === 'undefined') { | |
241 | return ""; | |
242 | } | |
243 | var iconCls = 'question-circle'; | |
244 | switch (value) { | |
245 | case 'AVAIL': | |
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 | ||
264 | render_pbs_fingerprint: fp => fp.substring(0, 23), | |
265 | ||
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 | ||
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 | } | |
284 | let tip = ""; | |
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 | ||
302 | render_backup_status: function(value, meta, record) { | |
303 | if (typeof value === 'undefined') { | |
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 | ||
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; | |
331 | val.split(',').forEach(function(day) { | |
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) { | |
354 | days.push(Ext.Date.dayNames[cur+1] + '-' + Ext.Date.dayNames[(cur+item)%7]); | |
355 | cur += item-1; | |
356 | } else if (item === 2) { | |
357 | days.push(Ext.Date.dayNames[cur+1]); | |
358 | days.push(Ext.Date.dayNames[(cur+2)%7]); | |
359 | cur++; | |
360 | } else if (item === 1) { | |
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 | ||
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 | ||
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 | }); | |
406 | } | |
407 | return info; | |
408 | }, | |
409 | ||
410 | render_kvm_ostype: function(value) { | |
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; | |
416 | } | |
417 | }, | |
418 | ||
419 | render_hotplug_features: function(value) { | |
420 | var fa = []; | |
421 | ||
422 | if (!value || value === '0') { | |
423 | return gettext('Disabled'); | |
424 | } | |
425 | ||
426 | if (value === '1') { | |
427 | value = 'disk,network,usb'; | |
428 | } | |
429 | ||
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') { | |
436 | fa.push('USB'); | |
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 | ||
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 | ||
456 | render_qga_features: function(config) { | |
457 | if (!config) { | |
458 | return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')'; | |
459 | } | |
460 | let qga = PVE.Parser.parsePropertyString(config, 'enabled'); | |
461 | if (!PVE.Parser.parseBoolean(qga.enabled)) { | |
462 | return Proxmox.Utils.disabledText; | |
463 | } | |
464 | delete qga.enabled; | |
465 | ||
466 | let agentstring = Proxmox.Utils.enabledText; | |
467 | ||
468 | for (const [key, value] of Object.entries(qga)) { | |
469 | let displayText = Proxmox.Utils.disabledText; | |
470 | if (key === 'type') { | |
471 | let map = { | |
472 | isa: "ISA", | |
473 | virtio: "VirtIO", | |
474 | }; | |
475 | displayText = map[value] || Proxmox.Utils.unknownText; | |
476 | } else if (PVE.Parser.parseBoolean(value)) { | |
477 | displayText = Proxmox.Utils.enabledText; | |
478 | } | |
479 | agentstring += `, ${key}: ${displayText}`; | |
480 | } | |
481 | ||
482 | return agentstring; | |
483 | }, | |
484 | ||
485 | render_qemu_machine: function(value) { | |
486 | return value || Proxmox.Utils.defaultText + ' (i440fx)'; | |
487 | }, | |
488 | ||
489 | render_qemu_bios: function(value) { | |
490 | if (!value) { | |
491 | return Proxmox.Utils.defaultText + ' (SeaBIOS)'; | |
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 | ||
501 | render_dc_ha_opts: function(value) { | |
502 | if (!value) { | |
503 | return Proxmox.Utils.defaultText; | |
504 | } else { | |
505 | return PVE.Parser.printPropertyString(value); | |
506 | } | |
507 | }, | |
508 | render_as_property_string: v => !v ? Proxmox.Utils.defaultText : PVE.Parser.printPropertyString(v), | |
509 | ||
510 | render_scsihw: function(value) { | |
511 | if (!value) { | |
512 | return Proxmox.Utils.defaultText + ' (LSI 53C895A)'; | |
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') { | |
520 | return 'VirtIO SCSI'; | |
521 | } else if (value === 'virtio-scsi-single') { | |
522 | return 'VirtIO SCSI single'; | |
523 | } else if (value === 'pvscsi') { | |
524 | return 'VMware PVSCSI'; | |
525 | } else { | |
526 | return value; | |
527 | } | |
528 | }, | |
529 | ||
530 | render_spice_enhancements: function(values) { | |
531 | let props = PVE.Parser.parsePropertyString(values); | |
532 | if (Ext.Object.isEmpty(props)) { | |
533 | return Proxmox.Utils.noneText; | |
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 | ||
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', | |
551 | de: 'German', | |
552 | 'de-ch': 'German (Swiss)', | |
553 | 'en-gb': 'English (UK)', | |
554 | 'en-us': 'English (USA)', | |
555 | es: 'Spanish', | |
556 | //et: 'Estonia', | |
557 | fi: 'Finnish', | |
558 | //fo: 'Faroe Islands', | |
559 | fr: 'French', | |
560 | 'fr-be': 'French (Belgium)', | |
561 | 'fr-ca': 'French (Canada)', | |
562 | 'fr-ch': 'French (Swiss)', | |
563 | //hr: 'Croatia', | |
564 | hu: 'Hungarian', | |
565 | is: 'Icelandic', | |
566 | it: 'Italian', | |
567 | ja: 'Japanese', | |
568 | lt: 'Lithuanian', | |
569 | //lv: 'Latvian', | |
570 | mk: 'Macedonian', | |
571 | nl: 'Dutch', | |
572 | //'nl-be': 'Dutch (Belgium)', | |
573 | no: 'Norwegian', | |
574 | pl: 'Polish', | |
575 | pt: 'Portuguese', | |
576 | 'pt-br': 'Portuguese (Brazil)', | |
577 | //ru: 'Russian', | |
578 | sl: 'Slovenian', | |
579 | sv: 'Swedish', | |
580 | //th: 'Thai', | |
581 | tr: 'Turkish', | |
582 | }, | |
583 | ||
584 | kvm_vga_drivers: { | |
585 | std: gettext('Standard VGA'), | |
586 | vmware: gettext('VMware compatible'), | |
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', | |
594 | serial3: gettext('Serial terminal') + ' 3', | |
595 | virtio: 'VirtIO-GPU', | |
596 | none: Proxmox.Utils.noneText, | |
597 | }, | |
598 | ||
599 | render_kvm_language: function(value) { | |
600 | if (!value || value === '__default__') { | |
601 | return Proxmox.Utils.defaultText; | |
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() { | |
611 | var data = [['__default__', PVE.Utils.render_kvm_language('')]]; | |
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 | ||
619 | console_map: { | |
620 | '__default__': Proxmox.Utils.defaultText + ' (xterm.js)', | |
621 | 'vv': 'SPICE (remote-viewer)', | |
622 | 'html5': 'HTML5 (noVNC)', | |
623 | 'xtermjs': 'xterm.js', | |
624 | }, | |
625 | ||
626 | render_console_viewer: function(value) { | |
627 | value = value || '__default__'; | |
628 | if (PVE.Utils.console_map[value]) { | |
629 | return PVE.Utils.console_map[value]; | |
630 | } | |
631 | return value; | |
632 | }, | |
633 | ||
634 | console_viewer_array: function() { | |
635 | return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) { | |
636 | return [v, PVE.Utils.render_console_viewer(v)]; | |
637 | }); | |
638 | }, | |
639 | ||
640 | render_kvm_vga_driver: function(value) { | |
641 | if (!value) { | |
642 | return Proxmox.Utils.defaultText; | |
643 | } | |
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 | } | |
649 | if (text) { | |
650 | return text + ' (' + value + ')'; | |
651 | } | |
652 | return value; | |
653 | }, | |
654 | ||
655 | kvm_vga_driver_array: function() { | |
656 | var data = [['__default__', PVE.Utils.render_kvm_vga_driver('')]]; | |
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 | ||
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: | |
698 | msg = Proxmox.Utils.extractRequestError(action.result, true); | |
699 | break; | |
700 | } | |
701 | return msg; | |
702 | }, | |
703 | ||
704 | contentTypes: { | |
705 | 'images': gettext('Disk image'), | |
706 | 'backup': gettext('VZDump backup file'), | |
707 | 'vztmpl': gettext('Container template'), | |
708 | 'iso': gettext('ISO image'), | |
709 | 'rootdir': gettext('Container'), | |
710 | 'snippets': gettext('Snippets'), | |
711 | }, | |
712 | ||
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 | ||
721 | authSchema: { | |
722 | ad: { | |
723 | name: gettext('Active Directory Server'), | |
724 | ipanel: 'pveAuthADPanel', | |
725 | syncipanel: 'pveAuthLDAPSyncPanel', | |
726 | add: true, | |
727 | tfa: true, | |
728 | pwchange: true, | |
729 | }, | |
730 | ldap: { | |
731 | name: gettext('LDAP Server'), | |
732 | ipanel: 'pveAuthLDAPPanel', | |
733 | syncipanel: 'pveAuthLDAPSyncPanel', | |
734 | add: true, | |
735 | tfa: true, | |
736 | pwchange: true, | |
737 | }, | |
738 | openid: { | |
739 | name: gettext('OpenID Connect Server'), | |
740 | ipanel: 'pveAuthOpenIDPanel', | |
741 | add: true, | |
742 | tfa: false, | |
743 | pwchange: false, | |
744 | iconCls: 'pmx-itype-icon-openid-logo', | |
745 | }, | |
746 | pam: { | |
747 | name: 'Linux PAM', | |
748 | ipanel: 'pveAuthBasePanel', | |
749 | add: false, | |
750 | tfa: true, | |
751 | pwchange: true, | |
752 | }, | |
753 | pve: { | |
754 | name: 'Proxmox VE authentication server', | |
755 | ipanel: 'pveAuthBasePanel', | |
756 | add: false, | |
757 | tfa: true, | |
758 | pwchange: true, | |
759 | }, | |
760 | }, | |
761 | ||
762 | storageSchema: { | |
763 | dir: { | |
764 | name: Proxmox.Utils.directoryText, | |
765 | ipanel: 'DirInputPanel', | |
766 | faIcon: 'folder', | |
767 | backups: true, | |
768 | }, | |
769 | lvm: { | |
770 | name: 'LVM', | |
771 | ipanel: 'LVMInputPanel', | |
772 | faIcon: 'folder', | |
773 | backups: false, | |
774 | }, | |
775 | lvmthin: { | |
776 | name: 'LVM-Thin', | |
777 | ipanel: 'LvmThinInputPanel', | |
778 | faIcon: 'folder', | |
779 | backups: false, | |
780 | }, | |
781 | btrfs: { | |
782 | name: 'BTRFS', | |
783 | ipanel: 'BTRFSInputPanel', | |
784 | faIcon: 'folder', | |
785 | backups: true, | |
786 | }, | |
787 | nfs: { | |
788 | name: 'NFS', | |
789 | ipanel: 'NFSInputPanel', | |
790 | faIcon: 'building', | |
791 | backups: true, | |
792 | }, | |
793 | cifs: { | |
794 | name: 'SMB/CIFS', | |
795 | ipanel: 'CIFSInputPanel', | |
796 | faIcon: 'building', | |
797 | backups: true, | |
798 | }, | |
799 | glusterfs: { | |
800 | name: 'GlusterFS', | |
801 | ipanel: 'GlusterFsInputPanel', | |
802 | faIcon: 'building', | |
803 | backups: true, | |
804 | }, | |
805 | iscsi: { | |
806 | name: 'iSCSI', | |
807 | ipanel: 'IScsiInputPanel', | |
808 | faIcon: 'building', | |
809 | backups: false, | |
810 | }, | |
811 | cephfs: { | |
812 | name: 'CephFS', | |
813 | ipanel: 'CephFSInputPanel', | |
814 | faIcon: 'building', | |
815 | backups: true, | |
816 | }, | |
817 | pvecephfs: { | |
818 | name: 'CephFS (PVE)', | |
819 | ipanel: 'CephFSInputPanel', | |
820 | hideAdd: true, | |
821 | faIcon: 'building', | |
822 | backups: true, | |
823 | }, | |
824 | rbd: { | |
825 | name: 'RBD', | |
826 | ipanel: 'RBDInputPanel', | |
827 | faIcon: 'building', | |
828 | backups: false, | |
829 | }, | |
830 | pveceph: { | |
831 | name: 'RBD (PVE)', | |
832 | ipanel: 'RBDInputPanel', | |
833 | hideAdd: true, | |
834 | faIcon: 'building', | |
835 | backups: false, | |
836 | }, | |
837 | zfs: { | |
838 | name: 'ZFS over iSCSI', | |
839 | ipanel: 'ZFSInputPanel', | |
840 | faIcon: 'building', | |
841 | backups: false, | |
842 | }, | |
843 | zfspool: { | |
844 | name: 'ZFS', | |
845 | ipanel: 'ZFSPoolInputPanel', | |
846 | faIcon: 'folder', | |
847 | backups: false, | |
848 | }, | |
849 | pbs: { | |
850 | name: 'Proxmox Backup Server', | |
851 | ipanel: 'PBSInputPanel', | |
852 | faIcon: 'floppy-o', | |
853 | backups: true, | |
854 | }, | |
855 | drbd: { | |
856 | name: 'DRBD', | |
857 | hideAdd: true, | |
858 | backups: false, | |
859 | }, | |
860 | }, | |
861 | ||
862 | sdnvnetSchema: { | |
863 | vnet: { | |
864 | name: 'vnet', | |
865 | faIcon: 'folder', | |
866 | }, | |
867 | }, | |
868 | ||
869 | sdnzoneSchema: { | |
870 | zone: { | |
871 | name: 'zone', | |
872 | hideAdd: true, | |
873 | }, | |
874 | simple: { | |
875 | name: 'Simple', | |
876 | ipanel: 'SimpleInputPanel', | |
877 | faIcon: 'th', | |
878 | }, | |
879 | vlan: { | |
880 | name: 'VLAN', | |
881 | ipanel: 'VlanInputPanel', | |
882 | faIcon: 'th', | |
883 | }, | |
884 | qinq: { | |
885 | name: 'QinQ', | |
886 | ipanel: 'QinQInputPanel', | |
887 | faIcon: 'th', | |
888 | }, | |
889 | vxlan: { | |
890 | name: 'VXLAN', | |
891 | ipanel: 'VxlanInputPanel', | |
892 | faIcon: 'th', | |
893 | }, | |
894 | evpn: { | |
895 | name: 'EVPN', | |
896 | ipanel: 'EvpnInputPanel', | |
897 | faIcon: 'th', | |
898 | }, | |
899 | }, | |
900 | ||
901 | sdncontrollerSchema: { | |
902 | controller: { | |
903 | name: 'controller', | |
904 | hideAdd: true, | |
905 | }, | |
906 | evpn: { | |
907 | name: 'evpn', | |
908 | ipanel: 'EvpnInputPanel', | |
909 | faIcon: 'crosshairs', | |
910 | }, | |
911 | bgp: { | |
912 | name: 'bgp', | |
913 | ipanel: 'BgpInputPanel', | |
914 | faIcon: 'crosshairs', | |
915 | }, | |
916 | }, | |
917 | ||
918 | sdnipamSchema: { | |
919 | ipam: { | |
920 | name: 'ipam', | |
921 | hideAdd: true, | |
922 | }, | |
923 | pve: { | |
924 | name: 'PVE', | |
925 | ipanel: 'PVEIpamInputPanel', | |
926 | faIcon: 'th', | |
927 | hideAdd: true, | |
928 | }, | |
929 | netbox: { | |
930 | name: 'Netbox', | |
931 | ipanel: 'NetboxInputPanel', | |
932 | faIcon: 'th', | |
933 | }, | |
934 | phpipam: { | |
935 | name: 'PhpIpam', | |
936 | ipanel: 'PhpIpamInputPanel', | |
937 | faIcon: 'th', | |
938 | }, | |
939 | }, | |
940 | ||
941 | sdndnsSchema: { | |
942 | dns: { | |
943 | name: 'dns', | |
944 | hideAdd: true, | |
945 | }, | |
946 | powerdns: { | |
947 | name: 'powerdns', | |
948 | ipanel: 'PowerdnsInputPanel', | |
949 | faIcon: 'th', | |
950 | }, | |
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) { | |
964 | return schema.name; | |
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 | ||
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 | ||
993 | format_storage_type: function(value, md, record) { | |
994 | if (value === 'rbd') { | |
995 | value = !record || record.get('monhost') ? 'rbd' : 'pveceph'; | |
996 | } else if (value === 'cephfs') { | |
997 | value = !record || record.get('monhost') ? 'cephfs' : 'pvecephfs'; | |
998 | } | |
999 | ||
1000 | var schema = PVE.Utils.storageSchema[value]; | |
1001 | if (schema) { | |
1002 | return schema.name; | |
1003 | } | |
1004 | return Proxmox.Utils.unknownText; | |
1005 | }, | |
1006 | ||
1007 | format_ha: function(value) { | |
1008 | var text = Proxmox.Utils.noneText; | |
1009 | ||
1010 | if (value.managed) { | |
1011 | text = value.state || Proxmox.Utils.noneText; | |
1012 | ||
1013 | text += ', ' + Proxmox.Utils.groupText + ': '; | |
1014 | text += value.group || Proxmox.Utils.noneText; | |
1015 | } | |
1016 | ||
1017 | return text; | |
1018 | }, | |
1019 | ||
1020 | format_content_types: function(value) { | |
1021 | return value.split(',').sort().map(function(ct) { | |
1022 | return PVE.Utils.contentTypes[ct] || ct; | |
1023 | }).join(', '); | |
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)) { | |
1031 | return "CH " + | |
1032 | Ext.String.leftPad(data.channel, 2, '0') + | |
1033 | " ID " + data.id + " LUN " + data.lun; | |
1034 | } | |
1035 | return data.volid.replace(/^.*?:(.*?\/)?/, ''); | |
1036 | }, | |
1037 | ||
1038 | render_serverity: function(value) { | |
1039 | return PVE.Utils.log_severity_hash[value] || value; | |
1040 | }, | |
1041 | ||
1042 | calculate_hostcpu: function(data) { | |
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 | ||
1062 | return (data.cpu/maxcpu) * data.maxcpu; | |
1063 | }, | |
1064 | ||
1065 | render_hostcpu: function(value, metaData, record, rowIndex, colIndex, store) { | |
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 | ||
1090 | render_bandwidth: function(value) { | |
1091 | if (!Ext.isNumeric(value)) { | |
1092 | return ''; | |
1093 | } | |
1094 | ||
1095 | return Proxmox.Utils.format_size(value) + '/s'; | |
1096 | }, | |
1097 | ||
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 | ||
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 | ||
1109 | return data.mem / data.maxmem; | |
1110 | }, | |
1111 | ||
1112 | calculate_hostmem_usage: function(data) { | |
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 | ||
1131 | return data.mem / maxmem; | |
1132 | }, | |
1133 | ||
1134 | render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) { | |
1135 | if (!Ext.isNumeric(value) || value === -1) { | |
1136 | return ''; | |
1137 | } | |
1138 | if (value > 1) { | |
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 | ||
1148 | return (mem*100/maxmem).toFixed(1) + " %"; | |
1149 | } | |
1150 | return (value*100).toFixed(1) + " %"; | |
1151 | }, | |
1152 | ||
1153 | render_hostmem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) { | |
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 | ||
1166 | if (record.data.mem > 1) { | |
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 | ||
1180 | render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) { | |
1181 | var mem = value; | |
1182 | var maxmem = record.data.maxmem; | |
1183 | ||
1184 | if (!record.data.uptime) { | |
1185 | return ''; | |
1186 | } | |
1187 | ||
1188 | if (!(Ext.isNumeric(mem) && maxmem)) { | |
1189 | return ''; | |
1190 | } | |
1191 | ||
1192 | return Proxmox.Utils.render_size(value); | |
1193 | }, | |
1194 | ||
1195 | calculate_disk_usage: function(data) { | |
1196 | if (!Ext.isNumeric(data.disk) || | |
1197 | ((data.type === 'qemu' || data.type === 'lxc') && data.uptime === 0) || | |
1198 | data.maxdisk === 0 | |
1199 | ) { | |
1200 | return -1; | |
1201 | } | |
1202 | ||
1203 | return data.disk / data.maxdisk; | |
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 | ||
1214 | render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) { | |
1215 | var disk = value; | |
1216 | var maxdisk = record.data.maxdisk; | |
1217 | var type = record.data.type; | |
1218 | ||
1219 | if (!Ext.isNumeric(disk) || | |
1220 | maxdisk === 0 || | |
1221 | ((type === 'qemu' || type === 'lxc') && record.data.uptime === 0) | |
1222 | ) { | |
1223 | return ''; | |
1224 | } | |
1225 | ||
1226 | return Proxmox.Utils.render_size(value); | |
1227 | }, | |
1228 | ||
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; | |
1243 | } | |
1244 | ||
1245 | if (record.lock) { | |
1246 | status += ' locked lock-' + record.lock; | |
1247 | } | |
1248 | ||
1249 | var defaults = PVE.tree.ResourceTree.typeDefaults[objType]; | |
1250 | if (defaults && defaults.iconCls) { | |
1251 | var retVal = defaults.iconCls + ' ' + status; | |
1252 | return retVal; | |
1253 | } | |
1254 | ||
1255 | return ''; | |
1256 | }, | |
1257 | ||
1258 | render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) { | |
1259 | var cls = PVE.Utils.get_object_icon_class(value, record.data); | |
1260 | ||
1261 | var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> '; | |
1262 | return fa + value; | |
1263 | }, | |
1264 | ||
1265 | render_support_level: function(value, metaData, record) { | |
1266 | return PVE.Utils.support_level_hash[value] || '-'; | |
1267 | }, | |
1268 | ||
1269 | render_upid: function(value, metaData, record) { | |
1270 | var type = record.data.type; | |
1271 | var id = record.data.id; | |
1272 | ||
1273 | return Proxmox.Utils.format_task_description(type, id); | |
1274 | }, | |
1275 | ||
1276 | render_optional_url: function(value) { | |
1277 | if (value && value.match(/^https?:\/\//)) { | |
1278 | return '<a target="_blank" href="' + value + '">' + value + '</a>'; | |
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 | ||
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 | ||
1302 | windowHostname: function() { | |
1303 | return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match, | |
1304 | function(m, addr, offset, original) { return addr; }); | |
1305 | }, | |
1306 | ||
1307 | openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) { | |
1308 | var dv = PVE.Utils.defaultViewer(consoles, consoleType); | |
1309 | PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd); | |
1310 | }, | |
1311 | ||
1312 | openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) { | |
1313 | if (vmid === undefined && (consoleType === 'kvm' || consoleType === 'lxc')) { | |
1314 | throw "missing vmid"; | |
1315 | } | |
1316 | if (!nodename) { | |
1317 | throw "no nodename specified"; | |
1318 | } | |
1319 | ||
1320 | if (viewer === 'html5') { | |
1321 | PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd); | |
1322 | } else if (viewer === 'xtermjs') { | |
1323 | Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd); | |
1324 | } else if (viewer === 'vv') { | |
1325 | let url = '/nodes/' + nodename + '/spiceshell'; | |
1326 | let params = { | |
1327 | proxy: PVE.Utils.windowHostname(), | |
1328 | }; | |
1329 | if (consoleType === 'kvm') { | |
1330 | url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; | |
1331 | } else if (consoleType === 'lxc') { | |
1332 | url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy'; | |
1333 | } else if (consoleType === 'upgrade') { | |
1334 | params.cmd = 'upgrade'; | |
1335 | } else if (consoleType === 'cmd') { | |
1336 | params.cmd = cmd; | |
1337 | } else if (consoleType !== 'shell') { | |
1338 | throw `unknown spice viewer type '${consoleType}'`; | |
1339 | } | |
1340 | PVE.Utils.openSpiceViewer(url, params); | |
1341 | } else { | |
1342 | throw `unknown viewer type '${viewer}'`; | |
1343 | } | |
1344 | }, | |
1345 | ||
1346 | defaultViewer: function(consoles, type) { | |
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; | |
1354 | allowXtermjs = !!consoles.xtermjs; | |
1355 | } | |
1356 | let dv = PVE.VersionInfo.console || (type === 'kvm' ? 'vv' : 'xtermjs'); | |
1357 | if (dv === 'vv' && !allowSpice) { | |
1358 | dv = allowXtermjs ? 'xtermjs' : 'html5'; | |
1359 | } else if (dv === 'xtermjs' && !allowXtermjs) { | |
1360 | dv = allowSpice ? 'vv' : 'html5'; | |
1361 | } | |
1362 | ||
1363 | return dv; | |
1364 | }, | |
1365 | ||
1366 | openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) { | |
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 | } | |
1372 | var url = Ext.Object.toQueryString({ | |
1373 | console: vmtype, // kvm, lxc, upgrade or shell | |
1374 | novnc: 1, | |
1375 | vmid: vmid, | |
1376 | vmname: vmname, | |
1377 | node: nodename, | |
1378 | resize: scaling, | |
1379 | cmd: cmd, | |
1380 | }); | |
1381 | var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427"); | |
1382 | if (nw) { | |
1383 | nw.focus(); | |
1384 | } | |
1385 | }, | |
1386 | ||
1387 | openSpiceViewer: function(url, params) { | |
1388 | var downloadWithName = function(uri, name) { | |
1389 | var link = Ext.DomHelper.append(document.body, { | |
1390 | tag: 'a', | |
1391 | href: uri, | |
1392 | css: 'display:none;visibility:hidden;height:0px;', | |
1393 | }); | |
1394 | ||
1395 | // Note: we need to tell Android and Chrome the correct file name extension | |
1396 | // but we do not set 'download' tag for other environments, because | |
1397 | // It can have strange side effects (additional user prompt on firefox) | |
1398 | if (navigator.userAgent.match(/Android|Chrome/i)) { | |
1399 | link.download = name; | |
1400 | } | |
1401 | ||
1402 | if (link.fireEvent) { | |
1403 | link.fireEvent('onclick'); | |
1404 | } else { | |
1405 | let evt = document.createEvent("MouseEvents"); | |
1406 | evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); | |
1407 | link.dispatchEvent(evt); | |
1408 | } | |
1409 | }; | |
1410 | ||
1411 | Proxmox.Utils.API2Request({ | |
1412 | url: url, | |
1413 | params: params, | |
1414 | method: 'POST', | |
1415 | failure: function(response, opts) { | |
1416 | Ext.Msg.alert('Error', response.htmlStatus); | |
1417 | }, | |
1418 | success: function(response, opts) { | |
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"); | |
1423 | }, | |
1424 | }); | |
1425 | }, | |
1426 | ||
1427 | openTreeConsole: function(tree, record, item, index, e) { | |
1428 | e.stopEvent(); | |
1429 | let nodename = record.data.node; | |
1430 | let vmid = record.data.vmid; | |
1431 | let vmname = record.data.name; | |
1432 | if (record.data.type === 'qemu' && !record.data.template) { | |
1433 | Proxmox.Utils.API2Request({ | |
1434 | url: `/nodes/${nodename}/qemu/${vmid}/status/current`, | |
1435 | failure: response => Ext.Msg.alert('Error', response.htmlStatus), | |
1436 | success: function(response, opts) { | |
1437 | let conf = response.result.data; | |
1438 | let consoles = { | |
1439 | spice: !!conf.spice, | |
1440 | xtermjs: !!conf.serial, | |
1441 | }; | |
1442 | PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname); | |
1443 | }, | |
1444 | }); | |
1445 | } else if (record.data.type === 'lxc' && !record.data.template) { | |
1446 | PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname); | |
1447 | } | |
1448 | }, | |
1449 | ||
1450 | // test automation helper | |
1451 | call_menu_handler: function(menu, text) { | |
1452 | let item = menu.query('menuitem').find(el => el.text === text); | |
1453 | if (item && item.handler) { | |
1454 | item.handler(); | |
1455 | } | |
1456 | }, | |
1457 | ||
1458 | createCmdMenu: function(v, record, item, index, event) { | |
1459 | event.stopEvent(); | |
1460 | if (!(v instanceof Ext.tree.View)) { | |
1461 | v.select(record); | |
1462 | } | |
1463 | let menu; | |
1464 | let type = record.data.type; | |
1465 | ||
1466 | if (record.data.template) { | |
1467 | if (type === 'qemu' || type === 'lxc') { | |
1468 | menu = Ext.create('PVE.menu.TemplateMenu', { | |
1469 | pveSelNode: record, | |
1470 | }); | |
1471 | } | |
1472 | } else if (type === 'qemu' || type === 'lxc' || type === 'node') { | |
1473 | menu = Ext.create('PVE.' + type + '.CmdMenu', { | |
1474 | pveSelNode: record, | |
1475 | nodename: record.data.node, | |
1476 | }); | |
1477 | } else { | |
1478 | return undefined; | |
1479 | } | |
1480 | ||
1481 | menu.showAt(event.getXY()); | |
1482 | return menu; | |
1483 | }, | |
1484 | ||
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) { | |
1489 | if (values.delete) { | |
1490 | if (Ext.isArray(values.delete)) { | |
1491 | values.delete.push(fieldname); | |
1492 | } else { | |
1493 | values.delete += ',' + fieldname; | |
1494 | } | |
1495 | } else { | |
1496 | values.delete = fieldname; | |
1497 | } | |
1498 | } | |
1499 | ||
1500 | delete values[fieldname]; | |
1501 | } | |
1502 | }, | |
1503 | ||
1504 | loadSSHKeyFromFile: function(file, callback) { | |
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}`); | |
1514 | return; | |
1515 | } | |
1516 | let reader = new FileReader(); | |
1517 | reader.onload = evt => callback(evt.target.result); | |
1518 | reader.readAsText(file); | |
1519 | }, | |
1520 | ||
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 | } | |
1527 | let reader = new FileReader(); | |
1528 | reader.onload = evt => callback(evt.target.result); | |
1529 | reader.readAsText(file); | |
1530 | }, | |
1531 | ||
1532 | diskControllerMaxIDs: { | |
1533 | ide: 4, | |
1534 | sata: 6, | |
1535 | scsi: 31, | |
1536 | virtio: 16, | |
1537 | }, | |
1538 | ||
1539 | // types is either undefined (all busses), an array of busses, or a single bus | |
1540 | forEachBus: function(types, func) { | |
1541 | let busses = Object.keys(PVE.Utils.diskControllerMaxIDs); | |
1542 | ||
1543 | if (Ext.isArray(types)) { | |
1544 | busses = types; | |
1545 | } else if (Ext.isDefined(types)) { | |
1546 | busses = [types]; | |
1547 | } | |
1548 | ||
1549 | // check if we only have valid busses | |
1550 | for (let i = 0; i < busses.length; i++) { | |
1551 | if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) { | |
1552 | throw "invalid bus: '" + busses[i] + "'"; | |
1553 | } | |
1554 | } | |
1555 | ||
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); | |
1560 | if (!cont && cont !== undefined) { | |
1561 | return; | |
1562 | } | |
1563 | } | |
1564 | } | |
1565 | }, | |
1566 | ||
1567 | mp_counts: { | |
1568 | mps: 256, | |
1569 | unused: 256, | |
1570 | }, | |
1571 | ||
1572 | forEachMP: function(func, includeUnused) { | |
1573 | for (let i = 0; i < PVE.Utils.mp_counts.mps; i++) { | |
1574 | let cont = func('mp', i); | |
1575 | if (!cont && cont !== undefined) { | |
1576 | return; | |
1577 | } | |
1578 | } | |
1579 | ||
1580 | if (!includeUnused) { | |
1581 | return; | |
1582 | } | |
1583 | ||
1584 | for (let i = 0; i < PVE.Utils.mp_counts.unused; i++) { | |
1585 | let cont = func('unused', i); | |
1586 | if (!cont && cont !== undefined) { | |
1587 | return; | |
1588 | } | |
1589 | } | |
1590 | }, | |
1591 | ||
1592 | hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1, tpmstate: 1 }, | |
1593 | ||
1594 | cleanEmptyObjectKeys: function(obj) { | |
1595 | for (const propName of Object.keys(obj)) { | |
1596 | if (obj[propName] === null || obj[propName] === undefined) { | |
1597 | delete obj[propName]; | |
1598 | } | |
1599 | } | |
1600 | }, | |
1601 | ||
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); | |
1609 | acme.domains = acme.domains.filter((value, index, self) => self.indexOf(value) === index); | |
1610 | } | |
1611 | return acme; | |
1612 | }, | |
1613 | ||
1614 | remove_domain_from_acme: function(acme, domain) { | |
1615 | if (acme.domains !== undefined) { | |
1616 | acme.domains = acme | |
1617 | .domains | |
1618 | .filter((value, index, self) => self.indexOf(value) === index && value !== domain); | |
1619 | } | |
1620 | return acme; | |
1621 | }, | |
1622 | ||
1623 | handleStoreErrorOrMask: function(view, store, regex, callback) { | |
1624 | view.mon(store, 'load', function(proxy, response, success, operation) { | |
1625 | if (success) { | |
1626 | Proxmox.Utils.setErrorMask(view, false); | |
1627 | return; | |
1628 | } | |
1629 | let msg; | |
1630 | if (operation.error.statusText) { | |
1631 | if (operation.error.statusText.match(regex)) { | |
1632 | callback(view, operation.error); | |
1633 | return; | |
1634 | } else { | |
1635 | msg = operation.error.statusText + ' (' + operation.error.status + ')'; | |
1636 | } | |
1637 | } else { | |
1638 | msg = gettext('Connection error'); | |
1639 | } | |
1640 | Proxmox.Utils.setErrorMask(view, msg); | |
1641 | }); | |
1642 | }, | |
1643 | ||
1644 | showCephInstallOrMask: function(container, msg, nodename, callback) { | |
1645 | if (msg.match(/not (installed|initialized)/i)) { | |
1646 | if (Proxmox.UserName === 'root@pam') { | |
1647 | container.el.mask(); | |
1648 | if (!container.down('pveCephInstallWindow')) { | |
1649 | var isInstalled = !!msg.match(/not initialized/i); | |
1650 | var win = Ext.create('PVE.ceph.Install', { | |
1651 | nodename: nodename, | |
1652 | }); | |
1653 | win.getViewModel().set('isInstalled', isInstalled); | |
1654 | container.add(win); | |
1655 | win.show(); | |
1656 | callback(win); | |
1657 | } | |
1658 | } else { | |
1659 | container.mask(Ext.String.format(gettext('{0} not installed.') + | |
1660 | ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']); | |
1661 | } | |
1662 | return true; | |
1663 | } else { | |
1664 | return false; | |
1665 | } | |
1666 | }, | |
1667 | ||
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 | ||
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 | } | |
1695 | }, | |
1696 | ||
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 | }, | |
1706 | ||
1707 | cpu_vendor_map: { | |
1708 | 'default': 'QEMU', | |
1709 | 'AuthenticAMD': 'AMD', | |
1710 | 'GenuineIntel': 'Intel', | |
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 | }, | |
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 | }, | |
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 | }, | |
1793 | }, | |
1794 | ||
1795 | singleton: true, | |
1796 | constructor: function() { | |
1797 | var me = this; | |
1798 | Ext.apply(me, me.utilities); | |
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')], | |
1820 | cephdestroyfs: ['CephFS', gettext('Destroy')], | |
1821 | cephfscreate: ['CephFS', gettext('Create')], | |
1822 | cephsetpool: ['Ceph Pool', gettext('Edit')], | |
1823 | cephsetflags: ['', gettext('Change global Ceph flags')], | |
1824 | clustercreate: ['', gettext('Create Cluster')], | |
1825 | clusterjoin: ['', gettext('Join Cluster')], | |
1826 | dircreate: [gettext('Directory Storage'), gettext('Create')], | |
1827 | dirremove: [gettext('Directory'), gettext('Remove')], | |
1828 | download: [gettext('File'), gettext('Download')], | |
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')], | |
1836 | lvmremove: ['Volume Group', gettext('Remove')], | |
1837 | lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')], | |
1838 | lvmthinremove: ['Thinpool', gettext('Remove')], | |
1839 | migrateall: ['', gettext('Migrate all VMs and Containers')], | |
1840 | 'move_volume': ['CT', gettext('Move Volume')], | |
1841 | 'pbs-download': ['VM/CT', gettext('File Restore Download')], | |
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')], | |
1868 | wipedisk: ['Device', gettext('Wipe Disk')], | |
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')], | |
1890 | zfsremove: ['ZFS Pool', gettext('Remove')], | |
1891 | }); | |
1892 | }, | |
1893 | ||
1894 | }); |