]>
Commit | Line | Data |
---|---|---|
2ba22ee4 DM |
1 | Ext.define('PVE.node.Config', { |
2 | extend: 'PVE.panel.Config', | |
3 | alias: 'widget.PVE.node.Config', | |
4 | ||
c8802a60 | 5 | onlineHelp: 'chapter_system_administration', |
0f9347a6 | 6 | |
2ba22ee4 DM |
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 | ||
9cb193cf | 17 | me.statusStore = Ext.create('Proxmox.data.ObjectStore', { |
2ba22ee4 DM |
18 | url: "/api2/json/nodes/" + nodename + "/status", |
19 | interval: 1000 | |
20 | }); | |
21 | ||
22 | var node_command = function(cmd) { | |
e7ade592 | 23 | Proxmox.Utils.API2Request({ |
2ba22ee4 DM |
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 | }; | |
c474314e | 33 | |
2ba22ee4 | 34 | var actionBtn = Ext.create('Ext.Button', { |
6a4edbd1 | 35 | text: gettext('Bulk Actions'), |
9a132f4a | 36 | iconCls: 'fa fa-fw fa-ellipsis-v', |
2ba22ee4 DM |
37 | disabled: !caps.nodes['Sys.PowerMgmt'], |
38 | menu: new Ext.menu.Menu({ | |
39 | items: [ | |
40 | { | |
6a4edbd1 | 41 | text: gettext('Bulk Start'), |
d4333933 | 42 | iconCls: 'fa fa-fw fa-play', |
2ba22ee4 | 43 | handler: function() { |
6a4edbd1 DC |
44 | var win = Ext.create('PVE.window.BulkAction', { |
45 | nodename: nodename, | |
46 | title: gettext('Bulk Start'), | |
47 | btnText: gettext('Start'), | |
48 | action: 'startall' | |
2ba22ee4 | 49 | }); |
6a4edbd1 | 50 | win.show(); |
2ba22ee4 DM |
51 | } |
52 | }, | |
53 | { | |
6a4edbd1 DC |
54 | text: gettext('Bulk Stop'), |
55 | iconCls: 'fa fa-fw fa-stop', | |
2ba22ee4 | 56 | handler: function() { |
6a4edbd1 DC |
57 | var win = Ext.create('PVE.window.BulkAction', { |
58 | nodename: nodename, | |
59 | title: gettext('Bulk Stop'), | |
60 | btnText: gettext('Stop'), | |
61 | action: 'stopall' | |
2ba22ee4 | 62 | }); |
6a4edbd1 | 63 | win.show(); |
2ba22ee4 DM |
64 | } |
65 | }, | |
66 | { | |
6a4edbd1 | 67 | text: gettext('Bulk Migrate'), |
d4333933 | 68 | iconCls: 'fa fa-fw fa-send-o', |
2ba22ee4 | 69 | handler: function() { |
6a4edbd1 DC |
70 | var win = Ext.create('PVE.window.BulkAction', { |
71 | nodename: nodename, | |
72 | title: gettext('Bulk Migrate'), | |
73 | btnText: gettext('Migrate'), | |
74 | action: 'migrateall' | |
2ba22ee4 DM |
75 | }); |
76 | win.show(); | |
77 | } | |
78 | } | |
79 | ] | |
80 | }) | |
c474314e | 81 | }); |
2ba22ee4 | 82 | |
5720fafa | 83 | var restartBtn = Ext.create('Proxmox.button.Button', { |
2ba22ee4 DM |
84 | text: gettext('Restart'), |
85 | disabled: !caps.nodes['Sys.PowerMgmt'], | |
31cb3622 | 86 | dangerous: true, |
16152937 | 87 | confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Restart'), |
c474314e | 88 | handler: function() { |
2ba22ee4 | 89 | node_command('reboot'); |
d4333933 DC |
90 | }, |
91 | iconCls: 'fa fa-undo' | |
2ba22ee4 DM |
92 | }); |
93 | ||
5720fafa | 94 | var shutdownBtn = Ext.create('Proxmox.button.Button', { |
2ba22ee4 DM |
95 | text: gettext('Shutdown'), |
96 | disabled: !caps.nodes['Sys.PowerMgmt'], | |
31cb3622 | 97 | dangerous: true, |
16152937 | 98 | confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Shutdown'), |
c474314e | 99 | handler: function() { |
2ba22ee4 | 100 | node_command('shutdown'); |
d4333933 DC |
101 | }, |
102 | iconCls: 'fa fa-power-off' | |
2ba22ee4 DM |
103 | }); |
104 | ||
105 | var shellBtn = Ext.create('PVE.button.ConsoleButton', { | |
106 | disabled: !caps.nodes['Sys.Console'], | |
107 | text: gettext('Shell'), | |
108 | consoleType: 'shell', | |
ea541321 | 109 | nodename: nodename |
2ba22ee4 DM |
110 | }); |
111 | ||
112 | me.items = []; | |
113 | ||
114 | Ext.apply(me, { | |
115 | title: gettext('Node') + " '" + nodename + "'", | |
116 | hstateid: 'nodetab', | |
117 | defaults: { statusStore: me.statusStore }, | |
118 | tbar: [ restartBtn, shutdownBtn, shellBtn, actionBtn] | |
119 | }); | |
120 | ||
121 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 122 | me.items.push( |
2ba22ee4 DM |
123 | { |
124 | title: gettext('Summary'), | |
332581a8 | 125 | iconCls: 'fa fa-book', |
a14b3223 | 126 | itemId: 'summary', |
2ba22ee4 | 127 | xtype: 'pveNodeSummary' |
799ea12f DC |
128 | }, |
129 | { | |
130 | title: gettext('Notes'), | |
131 | iconCls: 'fa fa-sticky-note-o', | |
132 | itemId: 'notes', | |
133 | xtype: 'pveNotesView' | |
a14b3223 DC |
134 | } |
135 | ); | |
136 | } | |
137 | ||
138 | if (caps.nodes['Sys.Console']) { | |
139 | me.items.push( | |
140 | { | |
141 | title: gettext('Shell'), | |
142 | iconCls: 'fa fa-terminal', | |
d345d7ad DC |
143 | itemId: 'jsconsole', |
144 | xtype: 'pveNoVncConsole', | |
145 | consoleType: 'shell', | |
146 | xtermjs: true, | |
147 | nodename: nodename | |
a14b3223 DC |
148 | } |
149 | ); | |
150 | } | |
151 | ||
152 | if (caps.nodes['Sys.Audit']) { | |
153 | me.items.push( | |
2ba22ee4 | 154 | { |
a14b3223 | 155 | title: gettext('System'), |
332581a8 | 156 | iconCls: 'fa fa-cogs', |
2ba22ee4 | 157 | itemId: 'services', |
a14b3223 | 158 | expandedOnInit: true, |
4178b82a DC |
159 | startOnlyServices: { |
160 | 'pveproxy': true, | |
161 | 'pvedaemon': true, | |
162 | 'pve-cluster': true | |
163 | }, | |
164 | nodename: nodename, | |
165 | onlineHelp: 'pve_service_daemons', | |
166 | xtype: 'proxmoxNodeServiceView' | |
2ba22ee4 | 167 | }, |
a14b3223 DC |
168 | { |
169 | title: gettext('Network'), | |
170 | iconCls: 'fa fa-exchange', | |
171 | itemId: 'network', | |
172 | groups: ['services'], | |
13ff8209 DC |
173 | nodename: nodename, |
174 | onlineHelp: 'sysadmin_network_configuration', | |
175 | xtype: 'proxmoxNodeNetworkView' | |
a14b3223 | 176 | }, |
c287e233 DC |
177 | { |
178 | title: gettext('Certificates'), | |
179 | iconCls: 'fa fa-certificate', | |
180 | itemId: 'certificates', | |
181 | groups: ['services'], | |
182 | nodename: nodename, | |
183 | xtype: 'pveCertificatesView' | |
184 | }, | |
a14b3223 DC |
185 | { |
186 | title: gettext('DNS'), | |
187 | iconCls: 'fa fa-globe', | |
188 | groups: ['services'], | |
189 | itemId: 'dns', | |
66ce20fd DC |
190 | nodename: nodename, |
191 | onlineHelp: 'sysadmin_network_configuration', | |
192 | xtype: 'proxmoxNodeDNSView' | |
a14b3223 | 193 | }, |
332581a8 DC |
194 | { |
195 | title: gettext('Time'), | |
196 | itemId: 'time', | |
a14b3223 | 197 | groups: ['services'], |
939edd73 DC |
198 | nodename: nodename, |
199 | xtype: 'proxmoxNodeTimeView', | |
332581a8 DC |
200 | iconCls: 'fa fa-clock-o' |
201 | }); | |
202 | } | |
203 | ||
204 | if (caps.nodes['Sys.Syslog']) { | |
205 | me.items.push({ | |
206 | title: 'Syslog', | |
207 | iconCls: 'fa fa-list', | |
a14b3223 | 208 | groups: ['services'], |
332581a8 DC |
209 | disabled: !caps.nodes['Sys.Syslog'], |
210 | itemId: 'syslog', | |
0ee5a21e | 211 | xtype: 'proxmoxLogView', |
332581a8 DC |
212 | url: "/api2/extjs/nodes/" + nodename + "/syslog", |
213 | log_select_timespan: 1 | |
214 | }); | |
215 | ||
216 | if (caps.nodes['Sys.Modify']) { | |
217 | me.items.push({ | |
218 | title: gettext('Updates'), | |
219 | iconCls: 'fa fa-refresh', | |
220 | disabled: !caps.nodes['Sys.Console'], | |
0f9347a6 | 221 | // do we want to link to system updates instead? |
332581a8 | 222 | itemId: 'apt', |
371d39ef DC |
223 | xtype: 'proxmoxNodeAPT', |
224 | upgradeBtn: { | |
225 | xtype: 'pveConsoleButton', | |
35a04562 | 226 | disabled: Proxmox.UserName !== 'root@pam', |
371d39ef DC |
227 | text: gettext('Upgrade'), |
228 | consoleType: 'upgrade', | |
229 | nodename: nodename | |
230 | }, | |
332581a8 DC |
231 | nodename: nodename |
232 | }); | |
233 | } | |
234 | } | |
235 | ||
236 | if (caps.nodes['Sys.Audit']) { | |
237 | me.items.push( | |
2ba22ee4 | 238 | { |
332581a8 DC |
239 | xtype: 'pveFirewallRules', |
240 | iconCls: 'fa fa-shield', | |
332581a8 DC |
241 | title: gettext('Firewall'), |
242 | allow_iface: true, | |
243 | base_url: '/nodes/' + nodename + '/firewall/rules', | |
244 | list_refs_url: '/cluster/firewall/refs', | |
245 | itemId: 'firewall' | |
246 | }, | |
247 | { | |
248 | xtype: 'pveFirewallOptions', | |
249 | title: gettext('Options'), | |
250 | iconCls: 'fa fa-gear', | |
c8802a60 | 251 | onlineHelp: 'pve_firewall_host_specific_configuration', |
a14b3223 | 252 | groups: ['firewall'], |
332581a8 DC |
253 | base_url: '/nodes/' + nodename + '/firewall/options', |
254 | fwtype: 'node', | |
255 | itemId: 'firewall-options' | |
256 | }); | |
2ba22ee4 DM |
257 | } |
258 | ||
332581a8 DC |
259 | |
260 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 261 | me.items.push( |
fc2916c1 DC |
262 | { |
263 | title: gettext('Disks'), | |
264 | itemId: 'storage', | |
265 | expandedOnInit: true, | |
266 | iconCls: 'fa fa-hdd-o', | |
267 | xtype: 'pveNodeDiskList' | |
268 | }, | |
d660ba8a DC |
269 | { |
270 | title: 'LVM', | |
271 | itemId: 'lvm', | |
705edf41 | 272 | onlineHelp: 'chapter_lvm', |
d660ba8a DC |
273 | iconCls: 'fa fa-square', |
274 | groups: ['storage'], | |
275 | xtype: 'pveLVMList' | |
276 | }, | |
64f9c6d6 DC |
277 | { |
278 | title: 'LVM-Thin', | |
279 | itemId: 'lvmthin', | |
705edf41 | 280 | onlineHelp: 'chapter_lvm', |
64f9c6d6 DC |
281 | iconCls: 'fa fa-square-o', |
282 | groups: ['storage'], | |
283 | xtype: 'pveLVMThinList' | |
284 | }, | |
6ac46211 DC |
285 | { |
286 | title: Proxmox.Utils.directoryText, | |
287 | itemId: 'directory', | |
705edf41 | 288 | onlineHelp: 'chapter_storage', |
6ac46211 DC |
289 | iconCls: 'fa fa-folder', |
290 | groups: ['storage'], | |
291 | xtype: 'pveDirectoryList' | |
292 | }, | |
2ba22ee4 | 293 | { |
332581a8 DC |
294 | title: 'Ceph', |
295 | itemId: 'ceph', | |
296 | iconCls: 'fa fa-ceph', | |
297 | xtype: 'pveNodeCephStatus' | |
298 | }, | |
cb6df20c DC |
299 | { |
300 | xtype: 'pveReplicaView', | |
301 | iconCls: 'fa fa-retweet', | |
302 | title: gettext('Replication'), | |
303 | itemId: 'replication' | |
304 | }, | |
332581a8 | 305 | { |
7247077d | 306 | xtype: 'pveNodeCephConfigCrush', |
ec99b1c3 | 307 | title: gettext('Configuration'), |
332581a8 DC |
308 | iconCls: 'fa fa-gear', |
309 | groups: ['ceph'], | |
310 | itemId: 'ceph-config' | |
311 | }, | |
312 | { | |
313 | xtype: 'pveNodeCephMonList', | |
314 | title: gettext('Monitor'), | |
315 | iconCls: 'fa fa-tv', | |
316 | groups: ['ceph'], | |
317 | itemId: 'ceph-monlist' | |
318 | }, | |
319 | { | |
320 | xtype: 'pveNodeCephOsdTree', | |
321 | title: 'OSD', | |
322 | iconCls: 'fa fa-hdd-o', | |
323 | groups: ['ceph'], | |
324 | itemId: 'ceph-osdtree' | |
325 | }, | |
326 | { | |
327 | xtype: 'pveNodeCephPoolList', | |
4d02b4fe | 328 | title: 'Pools', |
332581a8 DC |
329 | iconCls: 'fa fa-sitemap', |
330 | groups: ['ceph'], | |
331 | itemId: 'ceph-pools' | |
2ba22ee4 | 332 | } |
7621bfbf | 333 | ); |
2ba22ee4 DM |
334 | } |
335 | ||
332581a8 | 336 | if (caps.nodes['Sys.Syslog']) { |
7621bfbf | 337 | me.items.push( |
2ba22ee4 | 338 | { |
0ee5a21e | 339 | xtype: 'proxmoxLogView', |
332581a8 DC |
340 | title: gettext('Log'), |
341 | iconCls: 'fa fa-list', | |
a14b3223 | 342 | groups: ['firewall'], |
c8802a60 | 343 | onlineHelp: 'chapter_pve_firewall', |
332581a8 DC |
344 | url: '/api2/extjs/nodes/' + nodename + '/firewall/log', |
345 | itemId: 'firewall-fwlog' | |
2ba22ee4 DM |
346 | }, |
347 | { | |
332581a8 DC |
348 | title: gettext('Log'), |
349 | itemId: 'ceph-log', | |
350 | iconCls: 'fa fa-list', | |
351 | groups: ['ceph'], | |
c8802a60 | 352 | onlineHelp: 'chapter_pveceph', |
0ee5a21e | 353 | xtype: 'proxmoxLogView', |
332581a8 DC |
354 | url: "/api2/extjs/nodes/" + nodename + "/ceph/log" |
355 | }); | |
356 | } | |
357 | ||
7621bfbf | 358 | me.items.push( |
332581a8 DC |
359 | { |
360 | title: gettext('Task History'), | |
361 | iconCls: 'fa fa-list', | |
362 | itemId: 'tasks', | |
6c60ab5e DC |
363 | nodename: nodename, |
364 | xtype: 'proxmoxNodeTasks' | |
332581a8 | 365 | }, |
2ba22ee4 DM |
366 | { |
367 | title: gettext('Subscription'), | |
332581a8 | 368 | iconCls: 'fa fa-support', |
2ba22ee4 | 369 | itemId: 'support', |
a1460d8d | 370 | xtype: 'pveNodeSubscription', |
2ba22ee4 DM |
371 | nodename: nodename |
372 | } | |
7621bfbf | 373 | ); |
2ba22ee4 DM |
374 | |
375 | me.callParent(); | |
376 | ||
540fdc8b | 377 | me.mon(me.statusStore, 'load', function(s, records, success) { |
2ba22ee4 DM |
378 | var uptimerec = s.data.get('uptime'); |
379 | var powermgmt = uptimerec ? uptimerec.data.value : false; | |
380 | if (!caps.nodes['Sys.PowerMgmt']) { | |
381 | powermgmt = false; | |
382 | } | |
383 | restartBtn.setDisabled(!powermgmt); | |
384 | shutdownBtn.setDisabled(!powermgmt); | |
385 | shellBtn.setDisabled(!powermgmt); | |
386 | }); | |
387 | ||
388 | me.on('afterrender', function() { | |
389 | me.statusStore.startUpdate(); | |
390 | }); | |
391 | ||
392 | me.on('destroy', function() { | |
393 | me.statusStore.stopUpdate(); | |
394 | }); | |
395 | } | |
396 | }); |