]>
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 | ||
17 | me.statusStore = Ext.create('PVE.data.ObjectStore', { | |
18 | url: "/api2/json/nodes/" + nodename + "/status", | |
19 | interval: 1000 | |
20 | }); | |
21 | ||
22 | var node_command = function(cmd) { | |
23 | PVE.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 | }; | |
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 DM |
82 | |
83 | var restartBtn = Ext.create('PVE.button.Button', { | |
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 | ||
94 | var shutdownBtn = Ext.create('PVE.button.Button', { | |
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' |
a14b3223 DC |
128 | } |
129 | ); | |
130 | } | |
131 | ||
132 | if (caps.nodes['Sys.Console']) { | |
133 | me.items.push( | |
134 | { | |
135 | title: gettext('Shell'), | |
136 | iconCls: 'fa fa-terminal', | |
137 | itemId: 'console', | |
138 | xtype: 'pveNoVncConsole', | |
139 | consoleType: 'shell', | |
140 | nodename: nodename | |
d345d7ad DC |
141 | }, |
142 | { | |
143 | title: gettext('Shell (JS)'), | |
144 | iconCls: 'fa fa-terminal', | |
145 | itemId: 'jsconsole', | |
146 | xtype: 'pveNoVncConsole', | |
147 | consoleType: 'shell', | |
148 | xtermjs: true, | |
149 | nodename: nodename | |
a14b3223 DC |
150 | } |
151 | ); | |
152 | } | |
153 | ||
154 | if (caps.nodes['Sys.Audit']) { | |
155 | me.items.push( | |
2ba22ee4 | 156 | { |
a14b3223 | 157 | title: gettext('System'), |
332581a8 | 158 | iconCls: 'fa fa-cogs', |
2ba22ee4 | 159 | itemId: 'services', |
a14b3223 | 160 | expandedOnInit: true, |
22f2f9d6 | 161 | xtype: 'pveNodeServiceView' |
2ba22ee4 | 162 | }, |
a14b3223 DC |
163 | { |
164 | title: gettext('Network'), | |
165 | iconCls: 'fa fa-exchange', | |
166 | itemId: 'network', | |
167 | groups: ['services'], | |
13ff8209 DC |
168 | nodename: nodename, |
169 | onlineHelp: 'sysadmin_network_configuration', | |
170 | xtype: 'proxmoxNodeNetworkView' | |
a14b3223 DC |
171 | }, |
172 | { | |
173 | title: gettext('DNS'), | |
174 | iconCls: 'fa fa-globe', | |
175 | groups: ['services'], | |
176 | itemId: 'dns', | |
177 | xtype: 'pveNodeDNSView' | |
178 | }, | |
332581a8 DC |
179 | { |
180 | title: gettext('Time'), | |
181 | itemId: 'time', | |
a14b3223 | 182 | groups: ['services'], |
939edd73 DC |
183 | nodename: nodename, |
184 | xtype: 'proxmoxNodeTimeView', | |
332581a8 DC |
185 | iconCls: 'fa fa-clock-o' |
186 | }); | |
187 | } | |
188 | ||
189 | if (caps.nodes['Sys.Syslog']) { | |
190 | me.items.push({ | |
191 | title: 'Syslog', | |
192 | iconCls: 'fa fa-list', | |
a14b3223 | 193 | groups: ['services'], |
332581a8 DC |
194 | disabled: !caps.nodes['Sys.Syslog'], |
195 | itemId: 'syslog', | |
196 | xtype: 'pveLogView', | |
197 | url: "/api2/extjs/nodes/" + nodename + "/syslog", | |
198 | log_select_timespan: 1 | |
199 | }); | |
200 | ||
201 | if (caps.nodes['Sys.Modify']) { | |
202 | me.items.push({ | |
203 | title: gettext('Updates'), | |
204 | iconCls: 'fa fa-refresh', | |
205 | disabled: !caps.nodes['Sys.Console'], | |
0f9347a6 | 206 | // do we want to link to system updates instead? |
332581a8 | 207 | itemId: 'apt', |
371d39ef DC |
208 | xtype: 'proxmoxNodeAPT', |
209 | upgradeBtn: { | |
210 | xtype: 'pveConsoleButton', | |
211 | disabled: PVE.UserName !== 'root@pam', | |
212 | text: gettext('Upgrade'), | |
213 | consoleType: 'upgrade', | |
214 | nodename: nodename | |
215 | }, | |
332581a8 DC |
216 | nodename: nodename |
217 | }); | |
218 | } | |
219 | } | |
220 | ||
221 | if (caps.nodes['Sys.Audit']) { | |
222 | me.items.push( | |
2ba22ee4 | 223 | { |
332581a8 DC |
224 | xtype: 'pveFirewallRules', |
225 | iconCls: 'fa fa-shield', | |
332581a8 DC |
226 | title: gettext('Firewall'), |
227 | allow_iface: true, | |
228 | base_url: '/nodes/' + nodename + '/firewall/rules', | |
229 | list_refs_url: '/cluster/firewall/refs', | |
230 | itemId: 'firewall' | |
231 | }, | |
232 | { | |
233 | xtype: 'pveFirewallOptions', | |
234 | title: gettext('Options'), | |
235 | iconCls: 'fa fa-gear', | |
c8802a60 | 236 | onlineHelp: 'pve_firewall_host_specific_configuration', |
a14b3223 | 237 | groups: ['firewall'], |
332581a8 DC |
238 | base_url: '/nodes/' + nodename + '/firewall/options', |
239 | fwtype: 'node', | |
240 | itemId: 'firewall-options' | |
241 | }); | |
2ba22ee4 DM |
242 | } |
243 | ||
332581a8 DC |
244 | |
245 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 246 | me.items.push( |
fc2916c1 DC |
247 | { |
248 | title: gettext('Disks'), | |
249 | itemId: 'storage', | |
250 | expandedOnInit: true, | |
251 | iconCls: 'fa fa-hdd-o', | |
252 | xtype: 'pveNodeDiskList' | |
253 | }, | |
2ba22ee4 | 254 | { |
332581a8 DC |
255 | title: 'Ceph', |
256 | itemId: 'ceph', | |
257 | iconCls: 'fa fa-ceph', | |
258 | xtype: 'pveNodeCephStatus' | |
259 | }, | |
cb6df20c DC |
260 | { |
261 | xtype: 'pveReplicaView', | |
262 | iconCls: 'fa fa-retweet', | |
263 | title: gettext('Replication'), | |
264 | itemId: 'replication' | |
265 | }, | |
332581a8 | 266 | { |
7247077d | 267 | xtype: 'pveNodeCephConfigCrush', |
ec99b1c3 | 268 | title: gettext('Configuration'), |
332581a8 DC |
269 | iconCls: 'fa fa-gear', |
270 | groups: ['ceph'], | |
271 | itemId: 'ceph-config' | |
272 | }, | |
273 | { | |
274 | xtype: 'pveNodeCephMonList', | |
275 | title: gettext('Monitor'), | |
276 | iconCls: 'fa fa-tv', | |
277 | groups: ['ceph'], | |
278 | itemId: 'ceph-monlist' | |
279 | }, | |
280 | { | |
281 | xtype: 'pveNodeCephOsdTree', | |
282 | title: 'OSD', | |
283 | iconCls: 'fa fa-hdd-o', | |
284 | groups: ['ceph'], | |
285 | itemId: 'ceph-osdtree' | |
286 | }, | |
287 | { | |
288 | xtype: 'pveNodeCephPoolList', | |
4d02b4fe | 289 | title: 'Pools', |
332581a8 DC |
290 | iconCls: 'fa fa-sitemap', |
291 | groups: ['ceph'], | |
292 | itemId: 'ceph-pools' | |
2ba22ee4 | 293 | } |
7621bfbf | 294 | ); |
2ba22ee4 DM |
295 | } |
296 | ||
332581a8 | 297 | if (caps.nodes['Sys.Syslog']) { |
7621bfbf | 298 | me.items.push( |
2ba22ee4 | 299 | { |
332581a8 DC |
300 | xtype: 'pveLogView', |
301 | title: gettext('Log'), | |
302 | iconCls: 'fa fa-list', | |
a14b3223 | 303 | groups: ['firewall'], |
c8802a60 | 304 | onlineHelp: 'chapter_pve_firewall', |
332581a8 DC |
305 | url: '/api2/extjs/nodes/' + nodename + '/firewall/log', |
306 | itemId: 'firewall-fwlog' | |
2ba22ee4 DM |
307 | }, |
308 | { | |
332581a8 DC |
309 | title: gettext('Log'), |
310 | itemId: 'ceph-log', | |
311 | iconCls: 'fa fa-list', | |
312 | groups: ['ceph'], | |
c8802a60 | 313 | onlineHelp: 'chapter_pveceph', |
332581a8 DC |
314 | xtype: 'pveLogView', |
315 | url: "/api2/extjs/nodes/" + nodename + "/ceph/log" | |
316 | }); | |
317 | } | |
318 | ||
7621bfbf | 319 | me.items.push( |
332581a8 DC |
320 | { |
321 | title: gettext('Task History'), | |
322 | iconCls: 'fa fa-list', | |
323 | itemId: 'tasks', | |
6c60ab5e DC |
324 | nodename: nodename, |
325 | xtype: 'proxmoxNodeTasks' | |
332581a8 | 326 | }, |
2ba22ee4 DM |
327 | { |
328 | title: gettext('Subscription'), | |
332581a8 | 329 | iconCls: 'fa fa-support', |
2ba22ee4 | 330 | itemId: 'support', |
a1460d8d | 331 | xtype: 'pveNodeSubscription', |
2ba22ee4 DM |
332 | nodename: nodename |
333 | } | |
7621bfbf | 334 | ); |
2ba22ee4 DM |
335 | |
336 | me.callParent(); | |
337 | ||
540fdc8b | 338 | me.mon(me.statusStore, 'load', function(s, records, success) { |
2ba22ee4 DM |
339 | var uptimerec = s.data.get('uptime'); |
340 | var powermgmt = uptimerec ? uptimerec.data.value : false; | |
341 | if (!caps.nodes['Sys.PowerMgmt']) { | |
342 | powermgmt = false; | |
343 | } | |
344 | restartBtn.setDisabled(!powermgmt); | |
345 | shutdownBtn.setDisabled(!powermgmt); | |
346 | shellBtn.setDisabled(!powermgmt); | |
347 | }); | |
348 | ||
349 | me.on('afterrender', function() { | |
350 | me.statusStore.startUpdate(); | |
351 | }); | |
352 | ||
353 | me.on('destroy', function() { | |
354 | me.statusStore.stopUpdate(); | |
355 | }); | |
356 | } | |
357 | }); |