]>
Commit | Line | Data |
---|---|---|
2ba22ee4 DM |
1 | Ext.define('PVE.node.Config', { |
2 | extend: 'PVE.panel.Config', | |
3 | alias: 'widget.PVE.node.Config', | |
4 | ||
0f9347a6 DC |
5 | onlineHelp: 'chapter-sysadmin.html', |
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 DM |
34 | var actionBtn = Ext.create('Ext.Button', { |
35 | text: gettext('More'), | |
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 | { | |
16152937 | 41 | text: gettext('Start all VMs and Containers'), |
d4333933 | 42 | iconCls: 'fa fa-fw fa-play', |
2ba22ee4 | 43 | handler: function() { |
16152937 | 44 | var msg = gettext('Start all VMs and Containers') + ' (' + gettext('Node') + " '" + nodename + "')"; |
2ba22ee4 DM |
45 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
46 | if (btn !== 'yes') { | |
47 | return; | |
48 | } | |
49 | PVE.Utils.API2Request({ | |
50 | params: { force: 1 }, | |
51 | url: '/nodes/' + nodename + '/startall', | |
52 | method: 'POST', | |
53 | waitMsgTarget: me, | |
54 | failure: function(response, opts) { | |
55 | Ext.Msg.alert('Error', response.htmlStatus); | |
56 | } | |
57 | }); | |
58 | }); | |
59 | } | |
60 | }, | |
61 | { | |
16152937 | 62 | text: gettext('Stop all VMs and Containers'), |
d4333933 | 63 | iconCls: 'fa fa-fw fa-stop fa-red', |
2ba22ee4 | 64 | handler: function() { |
16152937 | 65 | var msg = gettext('Stop all VMs and Containers') + ' (' + gettext('Node') + " '" + nodename + "')"; |
2ba22ee4 DM |
66 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
67 | if (btn !== 'yes') { | |
68 | return; | |
69 | } | |
c474314e | 70 | |
2ba22ee4 DM |
71 | PVE.Utils.API2Request({ |
72 | url: '/nodes/' + nodename + '/stopall', | |
73 | method: 'POST', | |
74 | waitMsgTarget: me, | |
75 | failure: function(response, opts) { | |
76 | Ext.Msg.alert('Error', response.htmlStatus); | |
77 | } | |
78 | }); | |
79 | }); | |
80 | } | |
81 | }, | |
82 | { | |
16152937 | 83 | text: gettext('Migrate all VMs and Containers'), |
d4333933 | 84 | iconCls: 'fa fa-fw fa-send-o', |
2ba22ee4 DM |
85 | handler: function() { |
86 | var win = Ext.create('PVE.window.MigrateAll', { | |
22f2f9d6 | 87 | nodename: nodename |
2ba22ee4 DM |
88 | }); |
89 | win.show(); | |
90 | } | |
91 | } | |
92 | ] | |
93 | }) | |
c474314e | 94 | }); |
2ba22ee4 DM |
95 | |
96 | var restartBtn = Ext.create('PVE.button.Button', { | |
97 | text: gettext('Restart'), | |
98 | disabled: !caps.nodes['Sys.PowerMgmt'], | |
16152937 | 99 | confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Restart'), |
c474314e | 100 | handler: function() { |
2ba22ee4 | 101 | node_command('reboot'); |
d4333933 DC |
102 | }, |
103 | iconCls: 'fa fa-undo' | |
2ba22ee4 DM |
104 | }); |
105 | ||
106 | var shutdownBtn = Ext.create('PVE.button.Button', { | |
107 | text: gettext('Shutdown'), | |
108 | disabled: !caps.nodes['Sys.PowerMgmt'], | |
16152937 | 109 | confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Shutdown'), |
c474314e | 110 | handler: function() { |
2ba22ee4 | 111 | node_command('shutdown'); |
d4333933 DC |
112 | }, |
113 | iconCls: 'fa fa-power-off' | |
2ba22ee4 DM |
114 | }); |
115 | ||
116 | var shellBtn = Ext.create('PVE.button.ConsoleButton', { | |
117 | disabled: !caps.nodes['Sys.Console'], | |
118 | text: gettext('Shell'), | |
119 | consoleType: 'shell', | |
d4333933 DC |
120 | nodename: nodename, |
121 | iconCls: 'fa fa-terminal' | |
2ba22ee4 DM |
122 | }); |
123 | ||
124 | me.items = []; | |
125 | ||
126 | Ext.apply(me, { | |
127 | title: gettext('Node') + " '" + nodename + "'", | |
128 | hstateid: 'nodetab', | |
129 | defaults: { statusStore: me.statusStore }, | |
130 | tbar: [ restartBtn, shutdownBtn, shellBtn, actionBtn] | |
131 | }); | |
132 | ||
133 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 134 | me.items.push( |
2ba22ee4 DM |
135 | { |
136 | title: gettext('Summary'), | |
332581a8 | 137 | iconCls: 'fa fa-book', |
a14b3223 | 138 | itemId: 'summary', |
2ba22ee4 | 139 | xtype: 'pveNodeSummary' |
a14b3223 DC |
140 | } |
141 | ); | |
142 | } | |
143 | ||
144 | if (caps.nodes['Sys.Console']) { | |
145 | me.items.push( | |
146 | { | |
147 | title: gettext('Shell'), | |
148 | iconCls: 'fa fa-terminal', | |
149 | itemId: 'console', | |
150 | xtype: 'pveNoVncConsole', | |
151 | consoleType: 'shell', | |
152 | nodename: nodename | |
153 | } | |
154 | ); | |
155 | } | |
156 | ||
157 | if (caps.nodes['Sys.Audit']) { | |
158 | me.items.push( | |
2ba22ee4 | 159 | { |
a14b3223 | 160 | title: gettext('System'), |
332581a8 | 161 | iconCls: 'fa fa-cogs', |
2ba22ee4 | 162 | itemId: 'services', |
0f9347a6 | 163 | onlineHelp: 'index.html#_service_daemons', |
a14b3223 | 164 | expandedOnInit: true, |
22f2f9d6 | 165 | xtype: 'pveNodeServiceView' |
2ba22ee4 | 166 | }, |
a14b3223 DC |
167 | { |
168 | title: gettext('Network'), | |
169 | iconCls: 'fa fa-exchange', | |
170 | itemId: 'network', | |
0f9347a6 | 171 | onlineHelp: 'chapter-sysadmin.html#_network_configuration', |
a14b3223 DC |
172 | groups: ['services'], |
173 | xtype: 'pveNodeNetworkView' | |
174 | }, | |
175 | { | |
176 | title: gettext('DNS'), | |
177 | iconCls: 'fa fa-globe', | |
178 | groups: ['services'], | |
179 | itemId: 'dns', | |
0f9347a6 | 180 | onlineHelp: 'chapter-sysadmin.html#_network_configuration', |
a14b3223 DC |
181 | xtype: 'pveNodeDNSView' |
182 | }, | |
332581a8 DC |
183 | { |
184 | title: gettext('Time'), | |
185 | itemId: 'time', | |
a14b3223 | 186 | groups: ['services'], |
332581a8 DC |
187 | xtype: 'pveNodeTimeView', |
188 | iconCls: 'fa fa-clock-o' | |
189 | }); | |
190 | } | |
191 | ||
192 | if (caps.nodes['Sys.Syslog']) { | |
193 | me.items.push({ | |
194 | title: 'Syslog', | |
195 | iconCls: 'fa fa-list', | |
a14b3223 | 196 | groups: ['services'], |
332581a8 DC |
197 | disabled: !caps.nodes['Sys.Syslog'], |
198 | itemId: 'syslog', | |
199 | xtype: 'pveLogView', | |
200 | url: "/api2/extjs/nodes/" + nodename + "/syslog", | |
201 | log_select_timespan: 1 | |
202 | }); | |
203 | ||
204 | if (caps.nodes['Sys.Modify']) { | |
205 | me.items.push({ | |
206 | title: gettext('Updates'), | |
207 | iconCls: 'fa fa-refresh', | |
208 | disabled: !caps.nodes['Sys.Console'], | |
0f9347a6 DC |
209 | // do we want to link to system updates instead? |
210 | onlineHelp: 'chapter-sysadmin.html#_package_repositories', | |
332581a8 DC |
211 | itemId: 'apt', |
212 | xtype: 'pveNodeAPT', | |
213 | nodename: nodename | |
214 | }); | |
215 | } | |
216 | } | |
217 | ||
218 | if (caps.nodes['Sys.Audit']) { | |
219 | me.items.push( | |
2ba22ee4 | 220 | { |
332581a8 DC |
221 | xtype: 'pveFirewallRules', |
222 | iconCls: 'fa fa-shield', | |
0f9347a6 | 223 | onlineHelp: 'chapter-pve-firewall.html', |
332581a8 DC |
224 | title: gettext('Firewall'), |
225 | allow_iface: true, | |
226 | base_url: '/nodes/' + nodename + '/firewall/rules', | |
227 | list_refs_url: '/cluster/firewall/refs', | |
228 | itemId: 'firewall' | |
229 | }, | |
230 | { | |
231 | xtype: 'pveFirewallOptions', | |
232 | title: gettext('Options'), | |
233 | iconCls: 'fa fa-gear', | |
0f9347a6 | 234 | onlineHelp: 'chapter-pve-firewall.html#_host_specific_configuration', |
a14b3223 | 235 | groups: ['firewall'], |
332581a8 DC |
236 | base_url: '/nodes/' + nodename + '/firewall/options', |
237 | fwtype: 'node', | |
238 | itemId: 'firewall-options' | |
239 | }); | |
2ba22ee4 DM |
240 | } |
241 | ||
332581a8 DC |
242 | |
243 | if (caps.nodes['Sys.Audit']) { | |
7621bfbf | 244 | me.items.push( |
fc2916c1 DC |
245 | { |
246 | title: gettext('Disks'), | |
247 | itemId: 'storage', | |
248 | expandedOnInit: true, | |
249 | iconCls: 'fa fa-hdd-o', | |
250 | xtype: 'pveNodeDiskList' | |
251 | }, | |
2ba22ee4 | 252 | { |
332581a8 DC |
253 | title: 'Ceph', |
254 | itemId: 'ceph', | |
0f9347a6 | 255 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
256 | iconCls: 'fa fa-ceph', |
257 | xtype: 'pveNodeCephStatus' | |
258 | }, | |
332581a8 | 259 | { |
7247077d | 260 | xtype: 'pveNodeCephConfigCrush', |
332581a8 DC |
261 | title: gettext('Config'), |
262 | iconCls: 'fa fa-gear', | |
0f9347a6 | 263 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
264 | groups: ['ceph'], |
265 | itemId: 'ceph-config' | |
266 | }, | |
267 | { | |
268 | xtype: 'pveNodeCephMonList', | |
269 | title: gettext('Monitor'), | |
270 | iconCls: 'fa fa-tv', | |
0f9347a6 | 271 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
272 | groups: ['ceph'], |
273 | itemId: 'ceph-monlist' | |
274 | }, | |
275 | { | |
276 | xtype: 'pveNodeCephOsdTree', | |
277 | title: 'OSD', | |
278 | iconCls: 'fa fa-hdd-o', | |
0f9347a6 | 279 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
280 | groups: ['ceph'], |
281 | itemId: 'ceph-osdtree' | |
282 | }, | |
283 | { | |
284 | xtype: 'pveNodeCephPoolList', | |
285 | title: gettext('Pools'), | |
286 | iconCls: 'fa fa-sitemap', | |
0f9347a6 | 287 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
288 | groups: ['ceph'], |
289 | itemId: 'ceph-pools' | |
2ba22ee4 | 290 | } |
7621bfbf | 291 | ); |
2ba22ee4 DM |
292 | } |
293 | ||
332581a8 | 294 | if (caps.nodes['Sys.Syslog']) { |
7621bfbf | 295 | me.items.push( |
2ba22ee4 | 296 | { |
332581a8 DC |
297 | xtype: 'pveLogView', |
298 | title: gettext('Log'), | |
299 | iconCls: 'fa fa-list', | |
a14b3223 | 300 | groups: ['firewall'], |
dc6e32eb | 301 | onlineHelp: 'chapter-pve-firewall.html', |
332581a8 DC |
302 | url: '/api2/extjs/nodes/' + nodename + '/firewall/log', |
303 | itemId: 'firewall-fwlog' | |
2ba22ee4 DM |
304 | }, |
305 | { | |
332581a8 DC |
306 | title: gettext('Log'), |
307 | itemId: 'ceph-log', | |
308 | iconCls: 'fa fa-list', | |
309 | groups: ['ceph'], | |
0f9347a6 | 310 | onlineHelp: 'pveceph.1.html', |
332581a8 DC |
311 | xtype: 'pveLogView', |
312 | url: "/api2/extjs/nodes/" + nodename + "/ceph/log" | |
313 | }); | |
314 | } | |
315 | ||
7621bfbf | 316 | me.items.push( |
332581a8 DC |
317 | { |
318 | title: gettext('Task History'), | |
319 | iconCls: 'fa fa-list', | |
320 | itemId: 'tasks', | |
321 | xtype: 'pveNodeTasks' | |
322 | }, | |
2ba22ee4 DM |
323 | { |
324 | title: gettext('Subscription'), | |
332581a8 | 325 | iconCls: 'fa fa-support', |
2ba22ee4 | 326 | itemId: 'support', |
0f9347a6 | 327 | onlineHelp: 'chapter-sysadmin.html#_getting_help', |
a1460d8d | 328 | xtype: 'pveNodeSubscription', |
2ba22ee4 DM |
329 | nodename: nodename |
330 | } | |
7621bfbf | 331 | ); |
2ba22ee4 DM |
332 | |
333 | me.callParent(); | |
334 | ||
540fdc8b | 335 | me.mon(me.statusStore, 'load', function(s, records, success) { |
2ba22ee4 DM |
336 | var uptimerec = s.data.get('uptime'); |
337 | var powermgmt = uptimerec ? uptimerec.data.value : false; | |
338 | if (!caps.nodes['Sys.PowerMgmt']) { | |
339 | powermgmt = false; | |
340 | } | |
341 | restartBtn.setDisabled(!powermgmt); | |
342 | shutdownBtn.setDisabled(!powermgmt); | |
343 | shellBtn.setDisabled(!powermgmt); | |
344 | }); | |
345 | ||
346 | me.on('afterrender', function() { | |
347 | me.statusStore.startUpdate(); | |
348 | }); | |
349 | ||
350 | me.on('destroy', function() { | |
351 | me.statusStore.stopUpdate(); | |
352 | }); | |
353 | } | |
354 | }); |