]>
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'], | |
168 | xtype: 'pveNodeNetworkView' | |
169 | }, | |
170 | { | |
171 | title: gettext('DNS'), | |
172 | iconCls: 'fa fa-globe', | |
173 | groups: ['services'], | |
174 | itemId: 'dns', | |
175 | xtype: 'pveNodeDNSView' | |
176 | }, | |
332581a8 DC |
177 | { |
178 | title: gettext('Time'), | |
179 | itemId: 'time', | |
a14b3223 | 180 | groups: ['services'], |
332581a8 DC |
181 | xtype: 'pveNodeTimeView', |
182 | iconCls: 'fa fa-clock-o' | |
183 | }); | |
184 | } | |
185 | ||
186 | if (caps.nodes['Sys.Syslog']) { | |
187 | me.items.push({ | |
188 | title: 'Syslog', | |
189 | iconCls: 'fa fa-list', | |
a14b3223 | 190 | groups: ['services'], |
332581a8 DC |
191 | disabled: !caps.nodes['Sys.Syslog'], |
192 | itemId: 'syslog', | |
193 | xtype: 'pveLogView', | |
194 | url: "/api2/extjs/nodes/" + nodename + "/syslog", | |
195 | log_select_timespan: 1 | |
196 | }); | |
197 | ||
198 | if (caps.nodes['Sys.Modify']) { | |
199 | me.items.push({ | |
200 | title: gettext('Updates'), | |
201 | iconCls: 'fa fa-refresh', | |
202 | disabled: !caps.nodes['Sys.Console'], | |
0f9347a6 | 203 | // do we want to link to system updates instead? |
332581a8 DC |
204 | itemId: 'apt', |
205 | xtype: 'pveNodeAPT', | |
206 | nodename: nodename | |
207 | }); | |
208 | } | |
209 | } | |
210 | ||
211 | if (caps.nodes['Sys.Audit']) { | |
212 | me.items.push( | |
2ba22ee4 | 213 | { |
332581a8 DC |
214 | xtype: 'pveFirewallRules', |
215 | iconCls: 'fa fa-shield', | |
332581a8 DC |
216 | title: gettext('Firewall'), |
217 | allow_iface: true, | |
218 | base_url: '/nodes/' + nodename + '/firewall/rules', | |
219 | list_refs_url: '/cluster/firewall/refs', | |
220 | itemId: 'firewall' | |
221 | }, | |
222 | { | |
223 | xtype: 'pveFirewallOptions', | |
224 | title: gettext('Options'), | |
225 | iconCls: 'fa fa-gear', | |
c8802a60 | 226 | onlineHelp: 'pve_firewall_host_specific_configuration', |
a14b3223 | 227 | groups: ['firewall'], |
332581a8 DC |
228 | base_url: '/nodes/' + nodename + '/firewall/options', |
229 | fwtype: 'node', | |
230 | itemId: 'firewall-options' | |
231 | }); | |
2ba22ee4 DM |
232 | } |
233 | ||
332581a8 DC |
234 | |
235 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 236 | me.items.push( |
fc2916c1 DC |
237 | { |
238 | title: gettext('Disks'), | |
239 | itemId: 'storage', | |
240 | expandedOnInit: true, | |
241 | iconCls: 'fa fa-hdd-o', | |
242 | xtype: 'pveNodeDiskList' | |
243 | }, | |
2ba22ee4 | 244 | { |
332581a8 DC |
245 | title: 'Ceph', |
246 | itemId: 'ceph', | |
247 | iconCls: 'fa fa-ceph', | |
248 | xtype: 'pveNodeCephStatus' | |
249 | }, | |
cb6df20c DC |
250 | { |
251 | xtype: 'pveReplicaView', | |
252 | iconCls: 'fa fa-retweet', | |
253 | title: gettext('Replication'), | |
254 | itemId: 'replication' | |
255 | }, | |
332581a8 | 256 | { |
7247077d | 257 | xtype: 'pveNodeCephConfigCrush', |
ec99b1c3 | 258 | title: gettext('Configuration'), |
332581a8 DC |
259 | iconCls: 'fa fa-gear', |
260 | groups: ['ceph'], | |
261 | itemId: 'ceph-config' | |
262 | }, | |
263 | { | |
264 | xtype: 'pveNodeCephMonList', | |
265 | title: gettext('Monitor'), | |
266 | iconCls: 'fa fa-tv', | |
267 | groups: ['ceph'], | |
268 | itemId: 'ceph-monlist' | |
269 | }, | |
270 | { | |
271 | xtype: 'pveNodeCephOsdTree', | |
272 | title: 'OSD', | |
273 | iconCls: 'fa fa-hdd-o', | |
274 | groups: ['ceph'], | |
275 | itemId: 'ceph-osdtree' | |
276 | }, | |
277 | { | |
278 | xtype: 'pveNodeCephPoolList', | |
4d02b4fe | 279 | title: 'Pools', |
332581a8 DC |
280 | iconCls: 'fa fa-sitemap', |
281 | groups: ['ceph'], | |
282 | itemId: 'ceph-pools' | |
2ba22ee4 | 283 | } |
7621bfbf | 284 | ); |
2ba22ee4 DM |
285 | } |
286 | ||
332581a8 | 287 | if (caps.nodes['Sys.Syslog']) { |
7621bfbf | 288 | me.items.push( |
2ba22ee4 | 289 | { |
332581a8 DC |
290 | xtype: 'pveLogView', |
291 | title: gettext('Log'), | |
292 | iconCls: 'fa fa-list', | |
a14b3223 | 293 | groups: ['firewall'], |
c8802a60 | 294 | onlineHelp: 'chapter_pve_firewall', |
332581a8 DC |
295 | url: '/api2/extjs/nodes/' + nodename + '/firewall/log', |
296 | itemId: 'firewall-fwlog' | |
2ba22ee4 DM |
297 | }, |
298 | { | |
332581a8 DC |
299 | title: gettext('Log'), |
300 | itemId: 'ceph-log', | |
301 | iconCls: 'fa fa-list', | |
302 | groups: ['ceph'], | |
c8802a60 | 303 | onlineHelp: 'chapter_pveceph', |
332581a8 DC |
304 | xtype: 'pveLogView', |
305 | url: "/api2/extjs/nodes/" + nodename + "/ceph/log" | |
306 | }); | |
307 | } | |
308 | ||
7621bfbf | 309 | me.items.push( |
332581a8 DC |
310 | { |
311 | title: gettext('Task History'), | |
312 | iconCls: 'fa fa-list', | |
313 | itemId: 'tasks', | |
314 | xtype: 'pveNodeTasks' | |
315 | }, | |
2ba22ee4 DM |
316 | { |
317 | title: gettext('Subscription'), | |
332581a8 | 318 | iconCls: 'fa fa-support', |
2ba22ee4 | 319 | itemId: 'support', |
a1460d8d | 320 | xtype: 'pveNodeSubscription', |
2ba22ee4 DM |
321 | nodename: nodename |
322 | } | |
7621bfbf | 323 | ); |
2ba22ee4 DM |
324 | |
325 | me.callParent(); | |
326 | ||
540fdc8b | 327 | me.mon(me.statusStore, 'load', function(s, records, success) { |
2ba22ee4 DM |
328 | var uptimerec = s.data.get('uptime'); |
329 | var powermgmt = uptimerec ? uptimerec.data.value : false; | |
330 | if (!caps.nodes['Sys.PowerMgmt']) { | |
331 | powermgmt = false; | |
332 | } | |
333 | restartBtn.setDisabled(!powermgmt); | |
334 | shutdownBtn.setDisabled(!powermgmt); | |
335 | shellBtn.setDisabled(!powermgmt); | |
336 | }); | |
337 | ||
338 | me.on('afterrender', function() { | |
339 | me.statusStore.startUpdate(); | |
340 | }); | |
341 | ||
342 | me.on('destroy', function() { | |
343 | me.statusStore.stopUpdate(); | |
344 | }); | |
345 | } | |
346 | }); |