]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/Config.js
4d9062f382a6694c6542eb58fe13dde1fc62eac4
[pve-manager.git] / www / manager6 / node / Config.js
1 Ext.define('PVE.node.Config', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.node.Config',
4
5 onlineHelp: 'chapter_system_administration',
6
7 initComponent: function() {
8 var me = this;
9
10 var nodename = me.pveSelNode.data.node;
11 if (!nodename) {
12 throw "no node name specified";
13 }
14
15 var caps = Ext.state.Manager.get('GuiCap');
16
17 me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
18 url: "/api2/json/nodes/" + nodename + "/status",
19 interval: 5000,
20 });
21
22 var node_command = function(cmd) {
23 Proxmox.Utils.API2Request({
24 params: { command: cmd },
25 url: '/nodes/' + nodename + '/status',
26 method: 'POST',
27 waitMsgTarget: me,
28 failure: function(response, opts) {
29 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
30 },
31 });
32 };
33
34 var actionBtn = Ext.create('Ext.Button', {
35 text: gettext('Bulk Actions'),
36 iconCls: 'fa fa-fw fa-ellipsis-v',
37 disabled: !caps.vms['VM.PowerMgmt'] && !caps.vms['VM.Migrate'],
38 menu: new Ext.menu.Menu({
39 items: [
40 {
41 text: gettext('Bulk Start'),
42 iconCls: 'fa fa-fw fa-play',
43 disabled: !caps.vms['VM.PowerMgmt'],
44 handler: function() {
45 Ext.create('PVE.window.BulkAction', {
46 autoShow: true,
47 nodename: nodename,
48 title: gettext('Bulk Start'),
49 btnText: gettext('Start'),
50 action: 'startall',
51 });
52 },
53 },
54 {
55 text: gettext('Bulk Shutdown'),
56 iconCls: 'fa fa-fw fa-stop',
57 disabled: !caps.vms['VM.PowerMgmt'],
58 handler: function() {
59 Ext.create('PVE.window.BulkAction', {
60 autoShow: true,
61 nodename: nodename,
62 title: gettext('Bulk Shutdown'),
63 btnText: gettext('Shutdown'),
64 action: 'stopall',
65 });
66 },
67 },
68 {
69 text: gettext('Bulk Suspend'),
70 iconCls: 'fa fa-fw fa-download',
71 disabled: !caps.vms['VM.PowerMgmt'],
72 handler: function() {
73 Ext.create('PVE.window.BulkAction', {
74 autoShow: true,
75 nodename: nodename,
76 title: gettext('Bulk Suspend'),
77 btnText: gettext('Suspend'),
78 action: 'suspendall',
79 });
80 },
81 },
82 {
83 text: gettext('Bulk Migrate'),
84 iconCls: 'fa fa-fw fa-send-o',
85 disabled: !caps.vms['VM.Migrate'],
86 hidden: PVE.Utils.isStandaloneNode(),
87 handler: function() {
88 Ext.create('PVE.window.BulkAction', {
89 autoShow: true,
90 nodename: nodename,
91 title: gettext('Bulk Migrate'),
92 btnText: gettext('Migrate'),
93 action: 'migrateall',
94 });
95 },
96 },
97 ],
98 }),
99 });
100
101 let restartBtn = Ext.create('Proxmox.button.Button', {
102 text: gettext('Reboot'),
103 disabled: !caps.nodes['Sys.PowerMgmt'],
104 dangerous: true,
105 confirmMsg: Ext.String.format(gettext("Reboot node '{0}'?"), nodename),
106 handler: function() {
107 node_command('reboot');
108 },
109 iconCls: 'fa fa-undo',
110 });
111
112 var shutdownBtn = Ext.create('Proxmox.button.Button', {
113 text: gettext('Shutdown'),
114 disabled: !caps.nodes['Sys.PowerMgmt'],
115 dangerous: true,
116 confirmMsg: Ext.String.format(gettext("Shutdown node '{0}'?"), nodename),
117 handler: function() {
118 node_command('shutdown');
119 },
120 iconCls: 'fa fa-power-off',
121 });
122
123 var shellBtn = Ext.create('PVE.button.ConsoleButton', {
124 disabled: !caps.nodes['Sys.Console'],
125 text: gettext('Shell'),
126 consoleType: 'shell',
127 nodename: nodename,
128 });
129
130 me.items = [];
131
132 Ext.apply(me, {
133 title: gettext('Node') + " '" + nodename + "'",
134 hstateid: 'nodetab',
135 defaults: {
136 statusStore: me.statusStore,
137 },
138 tbar: [restartBtn, shutdownBtn, shellBtn, actionBtn],
139 });
140
141 if (caps.nodes['Sys.Audit']) {
142 me.items.push(
143 {
144 xtype: 'pveNodeSummary',
145 title: gettext('Summary'),
146 iconCls: 'fa fa-book',
147 itemId: 'summary',
148 },
149 {
150 xtype: 'pmxNotesView',
151 title: gettext('Notes'),
152 iconCls: 'fa fa-sticky-note-o',
153 itemId: 'notes',
154 },
155 );
156 }
157
158 if (caps.nodes['Sys.Console']) {
159 me.items.push(
160 {
161 xtype: 'pveNoVncConsole',
162 title: gettext('Shell'),
163 iconCls: 'fa fa-terminal',
164 itemId: 'jsconsole',
165 consoleType: 'shell',
166 xtermjs: true,
167 nodename: nodename,
168 },
169 );
170 }
171
172 if (caps.nodes['Sys.Audit']) {
173 me.items.push(
174 {
175 xtype: 'proxmoxNodeServiceView',
176 title: gettext('System'),
177 iconCls: 'fa fa-cogs',
178 itemId: 'services',
179 expandedOnInit: true,
180 restartCommand: 'reload', // avoid disruptions
181 startOnlyServices: {
182 'pveproxy': true,
183 'pvedaemon': true,
184 'pve-cluster': true,
185 },
186 nodename: nodename,
187 onlineHelp: 'pve_service_daemons',
188 },
189 {
190 xtype: 'proxmoxNodeNetworkView',
191 title: gettext('Network'),
192 iconCls: 'fa fa-exchange',
193 itemId: 'network',
194 showApplyBtn: true,
195 groups: ['services'],
196 nodename: nodename,
197 onlineHelp: 'sysadmin_network_configuration',
198 },
199 {
200 xtype: 'pveCertificatesView',
201 title: gettext('Certificates'),
202 iconCls: 'fa fa-certificate',
203 itemId: 'certificates',
204 groups: ['services'],
205 nodename: nodename,
206 },
207 {
208 xtype: 'proxmoxNodeDNSView',
209 title: gettext('DNS'),
210 iconCls: 'fa fa-globe',
211 groups: ['services'],
212 itemId: 'dns',
213 nodename: nodename,
214 onlineHelp: 'sysadmin_network_configuration',
215 },
216 {
217 xtype: 'proxmoxNodeHostsView',
218 title: gettext('Hosts'),
219 iconCls: 'fa fa-globe',
220 groups: ['services'],
221 itemId: 'hosts',
222 nodename: nodename,
223 onlineHelp: 'sysadmin_network_configuration',
224 },
225 {
226 xtype: 'proxmoxNodeOptionsView',
227 title: gettext('Options'),
228 iconCls: 'fa fa-gear',
229 groups: ['services'],
230 itemId: 'options',
231 nodename: nodename,
232 onlineHelp: 'proxmox_node_management',
233 },
234 {
235 xtype: 'proxmoxNodeTimeView',
236 title: gettext('Time'),
237 itemId: 'time',
238 groups: ['services'],
239 nodename: nodename,
240 iconCls: 'fa fa-clock-o',
241 });
242 }
243
244 if (caps.nodes['Sys.Syslog']) {
245 me.items.push({
246 xtype: 'proxmoxJournalView',
247 title: 'Syslog',
248 iconCls: 'fa fa-list',
249 groups: ['services'],
250 disabled: !caps.nodes['Sys.Syslog'],
251 itemId: 'syslog',
252 url: "/api2/extjs/nodes/" + nodename + "/journal",
253 });
254
255 if (caps.nodes['Sys.Modify']) {
256 me.items.push({
257 xtype: 'proxmoxNodeAPT',
258 title: gettext('Updates'),
259 iconCls: 'fa fa-refresh',
260 expandedOnInit: true,
261 disabled: !caps.nodes['Sys.Console'],
262 // do we want to link to system updates instead?
263 itemId: 'apt',
264 upgradeBtn: {
265 xtype: 'pveConsoleButton',
266 disabled: Proxmox.UserName !== 'root@pam',
267 text: gettext('Upgrade'),
268 consoleType: 'upgrade',
269 nodename: nodename,
270 },
271 nodename: nodename,
272 });
273
274 me.items.push({
275 xtype: 'proxmoxNodeAPTRepositories',
276 title: gettext('Repositories'),
277 iconCls: 'fa fa-files-o',
278 itemId: 'aptrepositories',
279 nodename: nodename,
280 onlineHelp: 'sysadmin_package_repositories',
281 groups: ['apt'],
282 });
283 }
284 }
285
286 if (caps.nodes['Sys.Audit']) {
287 me.items.push(
288 {
289 xtype: 'pveFirewallRules',
290 iconCls: 'fa fa-shield',
291 title: gettext('Firewall'),
292 allow_iface: true,
293 base_url: '/nodes/' + nodename + '/firewall/rules',
294 list_refs_url: '/cluster/firewall/refs',
295 itemId: 'firewall',
296 },
297 {
298 xtype: 'pveFirewallOptions',
299 title: gettext('Options'),
300 iconCls: 'fa fa-gear',
301 onlineHelp: 'pve_firewall_host_specific_configuration',
302 groups: ['firewall'],
303 base_url: '/nodes/' + nodename + '/firewall/options',
304 fwtype: 'node',
305 itemId: 'firewall-options',
306 });
307 }
308
309
310 if (caps.nodes['Sys.Audit']) {
311 me.items.push(
312 {
313 xtype: 'pmxDiskList',
314 title: gettext('Disks'),
315 itemId: 'storage',
316 expandedOnInit: true,
317 iconCls: 'fa fa-hdd-o',
318 nodename: nodename,
319 includePartitions: true,
320 supportsWipeDisk: true,
321 },
322 {
323 xtype: 'pveLVMList',
324 title: 'LVM',
325 itemId: 'lvm',
326 onlineHelp: 'chapter_lvm',
327 iconCls: 'fa fa-square',
328 groups: ['storage'],
329 },
330 {
331 xtype: 'pveLVMThinList',
332 title: 'LVM-Thin',
333 itemId: 'lvmthin',
334 onlineHelp: 'chapter_lvm',
335 iconCls: 'fa fa-square-o',
336 groups: ['storage'],
337 },
338 {
339 xtype: 'pveDirectoryList',
340 title: Proxmox.Utils.directoryText,
341 itemId: 'directory',
342 onlineHelp: 'chapter_storage',
343 iconCls: 'fa fa-folder',
344 groups: ['storage'],
345 },
346 {
347 title: 'ZFS',
348 itemId: 'zfs',
349 onlineHelp: 'chapter_zfs',
350 iconCls: 'fa fa-th-large',
351 groups: ['storage'],
352 xtype: 'pveZFSList',
353 },
354 {
355 xtype: 'pveNodeCephStatus',
356 title: 'Ceph',
357 itemId: 'ceph',
358 iconCls: 'fa fa-ceph',
359 },
360 {
361 xtype: 'pveNodeCephConfigCrush',
362 title: gettext('Configuration'),
363 iconCls: 'fa fa-gear',
364 groups: ['ceph'],
365 itemId: 'ceph-config',
366 },
367 {
368 xtype: 'pveNodeCephMonMgr',
369 title: gettext('Monitor'),
370 iconCls: 'fa fa-tv',
371 groups: ['ceph'],
372 itemId: 'ceph-monlist',
373 },
374 {
375 xtype: 'pveNodeCephOsdTree',
376 title: 'OSD',
377 iconCls: 'fa fa-hdd-o',
378 groups: ['ceph'],
379 itemId: 'ceph-osdtree',
380 },
381 {
382 xtype: 'pveNodeCephFSPanel',
383 title: 'CephFS',
384 iconCls: 'fa fa-folder',
385 groups: ['ceph'],
386 nodename: nodename,
387 itemId: 'ceph-cephfspanel',
388 },
389 {
390 xtype: 'pveNodeCephPoolList',
391 title: gettext('Pools'),
392 iconCls: 'fa fa-sitemap',
393 groups: ['ceph'],
394 itemId: 'ceph-pools',
395 },
396 {
397 xtype: 'pveReplicaView',
398 iconCls: 'fa fa-retweet',
399 title: gettext('Replication'),
400 itemId: 'replication',
401 },
402 );
403 }
404
405 if (caps.nodes['Sys.Syslog']) {
406 me.items.push(
407 {
408 xtype: 'proxmoxLogView',
409 title: gettext('Log'),
410 iconCls: 'fa fa-list',
411 groups: ['firewall'],
412 onlineHelp: 'chapter_pve_firewall',
413 url: '/api2/extjs/nodes/' + nodename + '/firewall/log',
414 itemId: 'firewall-fwlog',
415 log_select_timespan: true,
416 submitFormat: 'U',
417 },
418 {
419 xtype: 'cephLogView',
420 title: gettext('Log'),
421 itemId: 'ceph-log',
422 iconCls: 'fa fa-list',
423 groups: ['ceph'],
424 onlineHelp: 'chapter_pveceph',
425 url: "/api2/extjs/nodes/" + nodename + "/ceph/log",
426 nodename: nodename,
427 });
428 }
429
430 me.items.push(
431 {
432 title: gettext('Task History'),
433 iconCls: 'fa fa-list-alt',
434 itemId: 'tasks',
435 nodename: nodename,
436 xtype: 'proxmoxNodeTasks',
437 extraFilter: [
438 {
439 xtype: 'pveGuestIDSelector',
440 fieldLabel: 'VMID',
441 allowBlank: true,
442 name: 'vmid',
443 },
444 ],
445 },
446 {
447 title: gettext('Subscription'),
448 iconCls: 'fa fa-support',
449 itemId: 'support',
450 xtype: 'pveNodeSubscription',
451 nodename: nodename,
452 },
453 );
454
455 me.callParent();
456
457 me.mon(me.statusStore, 'load', function(store, records, success) {
458 let uptimerec = store.data.get('uptime');
459 let powermgmt = caps.nodes['Sys.PowerMgmt'] && uptimerec && uptimerec.data.value;
460
461 restartBtn.setDisabled(!powermgmt);
462 shutdownBtn.setDisabled(!powermgmt);
463 shellBtn.setDisabled(!powermgmt);
464 });
465
466 me.on('afterrender', function() {
467 me.statusStore.startUpdate();
468 });
469
470 me.on('destroy', function() {
471 me.statusStore.stopUpdate();
472 });
473 },
474 });