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