]>
Commit | Line | Data |
---|---|---|
8ba2d669 | 1 | /*jslint confusion: true*/ |
4616a55b TM |
2 | Ext.define('PVE.ceph.CephInstallWizard', { |
3 | extend: 'PVE.window.Wizard', | |
4 | alias: 'widget.pveCephInstallWizard', | |
5 | mixins: ['Proxmox.Mixin.CBind'], | |
6 | resizable: false, | |
7 | nodename: undefined, | |
8 | viewModel: { | |
9 | data: { | |
8ba2d669 | 10 | nodename: '', |
f992ef80 TM |
11 | configuration: true, |
12 | isInstalled: false | |
4616a55b TM |
13 | } |
14 | }, | |
15 | cbindData: { | |
16 | nodename: undefined | |
17 | }, | |
f992ef80 | 18 | title: gettext('Setup'), |
8ba2d669 TM |
19 | navigateNext: function() { |
20 | var tp = this.down('#wizcontent'); | |
21 | var atab = tp.getActiveTab(); | |
22 | ||
23 | var next = tp.items.indexOf(atab) + 1; | |
24 | var ntab = tp.items.getAt(next); | |
25 | if (ntab) { | |
26 | ntab.enable(); | |
27 | tp.setActiveTab(ntab); | |
28 | } | |
29 | }, | |
4e36fbab TM |
30 | setInitialTab: function (index) { |
31 | var tp = this.down('#wizcontent'); | |
32 | var initialTab = tp.items.getAt(index); | |
33 | initialTab.enable(); | |
34 | tp.setActiveTab(initialTab); | |
35 | }, | |
36 | onShow: function() { | |
37 | this.callParent(arguments); | |
38 | var isInstalled = this.getViewModel().get('isInstalled'); | |
39 | if (isInstalled) { | |
40 | this.getViewModel().set('configuration', false); | |
41 | this.setInitialTab(2); | |
42 | } | |
43 | }, | |
4616a55b TM |
44 | items: [ |
45 | { | |
46 | title: gettext('Info'), | |
47 | xtype: 'panel', | |
48 | border: false, | |
49 | bodyBorder: false, | |
50 | onlineHelp: 'chapter_pveceph', | |
51 | html: '<h3>Ceph?</h3>'+ | |
52 | '<blockquote cite="https://ceph.com/"><p>"<b>Ceph</b> is a unified, distributed storage system designed for excellent performance, reliability and scalability."</p></blockquote>'+ | |
53 | '<p><b>Ceph</b> is currently <b>not installed</b> on this node, click on the next button below to start the installation.'+ | |
54 | ' This wizard will guide you through the necessary steps, after the initial installation you will be offered to create a initial configuration.'+ | |
55 | ' The configuration step is only needed once per cluster and will be skipped if a config is already present.</p>'+ | |
3ef34e3c TL |
56 | '<p>Please take a look at our documentation, by clicking the help button below, before starting the installation, '+ |
57 | 'if you want to gain deeper knowledge about Ceph visit <a target="_blank" href="http://docs.ceph.com/docs/master/">ceph.com</a>.</p>', | |
4616a55b TM |
58 | listeners: { |
59 | activate: function() { | |
60 | // notify owning container that it should display a help button | |
61 | if (this.onlineHelp) { | |
62 | Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp); | |
63 | } | |
64 | this.up('pveCephInstallWizard').down('#back').hide(true); | |
fc360d85 | 65 | this.up('pveCephInstallWizard').down('#next').setText(gettext('Start installation')); |
4616a55b TM |
66 | }, |
67 | deactivate: function() { | |
68 | if (this.onlineHelp) { | |
69 | Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp); | |
70 | } | |
fc360d85 | 71 | this.up('pveCephInstallWizard').down('#next').setText(gettext('Next')); |
4616a55b TM |
72 | } |
73 | } | |
74 | }, | |
75 | { | |
76 | title: gettext('Installation'), | |
77 | xtype: 'panel', | |
78 | layout: 'fit', | |
79 | cbind:{ | |
80 | nodename: '{nodename}' | |
81 | }, | |
f992ef80 | 82 | viewModel: {}, // needed to inherit parent viewModel data |
4616a55b TM |
83 | listeners: { |
84 | afterrender: function() { | |
85 | var me = this; | |
f992ef80 TM |
86 | if (this.getViewModel().get('isInstalled')) { |
87 | this.mask("Ceph is already installed, click next to create your configuration.",['pve-static-mask']); | |
88 | } else { | |
89 | me.down('pveNoVncConsole').fireEvent('activate'); | |
90 | } | |
4616a55b TM |
91 | }, |
92 | activate: function() { | |
93 | var me = this; | |
94 | var nodename = me.nodename; | |
95 | me.updateStore = Ext.create('Proxmox.data.UpdateStore', { | |
96 | storeid: 'ceph-status-' + nodename, | |
97 | interval: 1000, | |
98 | proxy: { | |
99 | type: 'proxmox', | |
100 | url: '/api2/json/nodes/' + nodename + '/ceph/status' | |
101 | }, | |
102 | listeners: { | |
103 | load: function(rec, response, success, operation) { | |
8ba2d669 | 104 | |
4616a55b TM |
105 | if (success) { |
106 | me.updateStore.stopUpdate(); | |
8ba2d669 | 107 | me.down('textfield').setValue('success'); |
4616a55b TM |
108 | } else if (operation.error.statusText.match("not initialized", "i")) { |
109 | me.updateStore.stopUpdate(); | |
8ba2d669 | 110 | me.up('pveCephInstallWizard').getViewModel().set('configuration',false); |
4616a55b TM |
111 | me.down('textfield').setValue('success'); |
112 | } else if (operation.error.statusText.match("rados_connect failed", "i")) { | |
113 | me.updateStore.stopUpdate(); | |
8ba2d669 TM |
114 | me.up('pveCephInstallWizard').getViewModel().set('configuration',true); |
115 | me.down('textfield').setValue('success'); | |
4616a55b TM |
116 | } else if (!operation.error.statusText.match("not installed", "i")) { |
117 | Proxmox.Utils.setErrorMask(me, operation.error.statusText); | |
118 | } | |
119 | } | |
120 | } | |
121 | }); | |
122 | me.updateStore.startUpdate(); | |
123 | }, | |
124 | destroy: function() { | |
125 | var me = this; | |
126 | if (me.updateStore) { | |
127 | me.updateStore.stopUpdate(); | |
128 | } | |
129 | } | |
130 | }, | |
131 | items: [ | |
132 | { | |
133 | itemId: 'jsconsole', | |
134 | consoleType: 'cmd', | |
135 | xtermjs: true, | |
136 | xtype: 'pveNoVncConsole', | |
137 | cbind:{ | |
138 | nodename: '{nodename}' | |
139 | }, | |
140 | cmd: 'ceph_install' | |
141 | }, | |
142 | { | |
143 | xtype: 'textfield', | |
144 | name: 'installSuccess', | |
145 | value: '', | |
146 | allowBlank: false, | |
147 | submitValue: false, | |
148 | hidden: true | |
149 | } | |
150 | ] | |
151 | }, | |
152 | { | |
153 | xtype: 'inputpanel', | |
154 | title: gettext('Configuration'), | |
155 | onlineHelp: 'chapter_pveceph', | |
156 | cbind: { | |
157 | nodename: '{nodename}' | |
158 | }, | |
836d66f7 TM |
159 | viewModel: { |
160 | data: { | |
161 | replicas: undefined, | |
162 | minreplicas: undefined | |
163 | } | |
164 | }, | |
4616a55b TM |
165 | listeners: { |
166 | activate: function() { | |
167 | this.up('pveCephInstallWizard').down('#submit').setText(gettext('Next')); | |
168 | }, | |
8ba2d669 TM |
169 | beforeshow: function() { |
170 | if (this.up('pveCephInstallWizard').getViewModel().get('configuration')) { | |
171 | this.mask("Coniguration already initialized",['pve-static-mask']); | |
172 | } else { | |
173 | this.unmask(); | |
174 | } | |
175 | }, | |
4616a55b TM |
176 | deactivate: function() { |
177 | this.up('pveCephInstallWizard').down('#submit').setText(gettext('Finish')); | |
178 | } | |
179 | }, | |
180 | column1: [ | |
8ba2d669 | 181 | { |
218c9be5 TL |
182 | xtype: 'displayfield', |
183 | value: gettext('Ceph cluster configuration') + ':' | |
4616a55b TM |
184 | }, |
185 | { | |
6c7b8e23 | 186 | xtype: 'proxmoxNetworkSelector', |
4616a55b | 187 | name: 'network', |
4616a55b | 188 | value: '', |
2248c6c8 | 189 | fieldLabel: 'Public Network IP/CIDR', |
8ba2d669 TM |
190 | bind: { |
191 | allowBlank: '{configuration}' | |
8ba2d669 | 192 | } |
4616a55b TM |
193 | }, |
194 | { | |
6c7b8e23 | 195 | xtype: 'proxmoxNetworkSelector', |
4616a55b | 196 | name: 'cluster-network', |
2248c6c8 | 197 | fieldLabel: 'Cluster Network IP/CIDR', |
4616a55b | 198 | allowBlank: true, |
6c7b8e23 | 199 | autoSelect: false, |
2248c6c8 | 200 | emptyText: gettext('Same as Public Network') |
4616a55b | 201 | } |
218c9be5 | 202 | // FIXME: add hint about cluster network and/or reference user to docs?? |
4616a55b | 203 | ], |
8ba2d669 TM |
204 | column2: [ |
205 | { | |
218c9be5 TL |
206 | xtype: 'displayfield', |
207 | value: gettext('First Ceph monitor') + ':' | |
8ba2d669 TM |
208 | }, |
209 | { | |
210 | xtype: 'pveNodeSelector', | |
211 | fieldLabel: gettext('Monitor node'), | |
212 | name: 'mon-node', | |
213 | selectCurNode: true, | |
214 | allowBlank: false | |
71798b4b TL |
215 | }, |
216 | { | |
217 | xtype: 'displayfield', | |
218 | value: gettext('Additional monitors are recommended. They can be created at any time in the Monitor tab.'), | |
219 | userCls: 'pve-hint' | |
8ba2d669 TM |
220 | } |
221 | ], | |
4616a55b TM |
222 | advancedColumn1: [ |
223 | { | |
224 | xtype: 'numberfield', | |
225 | name: 'size', | |
0b985d6f | 226 | fieldLabel: 'Number of replicas', |
836d66f7 | 227 | bind: { |
8134b6b7 | 228 | value: '{replicas}' |
836d66f7 | 229 | }, |
4616a55b | 230 | maxValue: 7, |
8134b6b7 TL |
231 | minValue: 2, |
232 | emptyText: '3' | |
4616a55b TM |
233 | }, |
234 | { | |
235 | xtype: 'numberfield', | |
236 | name: 'min_size', | |
0b985d6f | 237 | fieldLabel: 'Minimum replicas', |
836d66f7 TM |
238 | bind: { |
239 | maxValue: '{replicas}', | |
8134b6b7 | 240 | value: '{minreplicas}' |
836d66f7 | 241 | }, |
8134b6b7 TL |
242 | minValue: 2, |
243 | maxValue: 3, | |
244 | setMaxValue: function(value) { | |
245 | this.maxValue = Ext.Number.from(value, 2); | |
246 | // allow enough to avoid split brains with max 'size', but more makes simply no sense | |
247 | if (this.maxValue > 4) { | |
248 | this.maxValue = 4; | |
249 | } | |
250 | this.toggleSpinners(); | |
836d66f7 | 251 | this.validate(); |
8134b6b7 TL |
252 | }, |
253 | emptyText: '2' | |
4616a55b TM |
254 | } |
255 | ], | |
256 | onGetValues: function(values) { | |
bf996912 | 257 | ['cluster-network', 'size', 'min_size'].forEach(function(field) { |
4616a55b TM |
258 | if (!values[field]) { |
259 | delete values[field]; | |
260 | } | |
261 | }); | |
262 | return values; | |
263 | }, | |
264 | onSubmit: function() { | |
265 | var me = this; | |
8ba2d669 TM |
266 | if (!this.up('pveCephInstallWizard').getViewModel().get('configuration')) { |
267 | var wizard = me.up('window'); | |
268 | var kv = wizard.getValues(); | |
269 | delete kv['delete']; | |
270 | var monNode = kv['mon-node']; | |
271 | delete kv['mon-node']; | |
272 | var nodename = me.nodename; | |
273 | delete kv.nodename; | |
274 | Proxmox.Utils.API2Request({ | |
275 | url: '/nodes/' + nodename + '/ceph/init', | |
276 | waitMsgTarget: wizard, | |
277 | method: 'POST', | |
278 | params: kv, | |
279 | success: function() { | |
280 | Proxmox.Utils.API2Request({ | |
ca62eebd | 281 | url: '/nodes/' + monNode + '/ceph/mon/' + monNode, |
8ba2d669 TM |
282 | waitMsgTarget: wizard, |
283 | method: 'POST', | |
284 | success: function() { | |
285 | me.up('pveCephInstallWizard').navigateNext(); | |
286 | }, | |
287 | failure: function(response, opts) { | |
288 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
289 | } | |
290 | }); | |
291 | }, | |
292 | failure: function(response, opts) { | |
293 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
4616a55b | 294 | } |
8ba2d669 TM |
295 | }); |
296 | ||
297 | } else { | |
298 | me.up('pveCephInstallWizard').navigateNext(); | |
299 | } | |
4616a55b TM |
300 | } |
301 | }, | |
302 | { | |
303 | title: gettext('Success'), | |
304 | xtype: 'panel', | |
305 | border: false, | |
306 | bodyBorder: false, | |
307 | onlineHelp: 'pve_ceph_install', | |
308 | html: '<h3>Installation successful!</h3>'+ | |
309 | '<p>The basic installation and configuration is completed, depending on your setup some of the following steps are required to start using Ceph:</p>'+ | |
4711d998 | 310 | '<ol><li>Install Ceph on other nodes</li>'+ |
fc29d138 WL |
311 | '<li>Create additional Ceph Monitors</li>'+ |
312 | '<li>Create Ceph OSDs</li>'+ | |
313 | '<li>Create Ceph Pools</li></ol>'+ | |
4616a55b TM |
314 | '<p>To learn more click on the help button below.</p>', |
315 | listeners: { | |
316 | activate: function() { | |
317 | // notify owning container that it should display a help button | |
318 | if (this.onlineHelp) { | |
319 | Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp); | |
320 | } | |
321 | ||
322 | var tp = this.up('#wizcontent'); | |
323 | var idx = tp.items.indexOf(this)-1; | |
324 | for(;idx >= 0;idx--) { | |
325 | var nc = tp.items.getAt(idx); | |
326 | if (nc) { | |
327 | nc.disable(); | |
328 | } | |
329 | } | |
330 | }, | |
331 | deactivate: function() { | |
332 | if (this.onlineHelp) { | |
333 | Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp); | |
334 | } | |
335 | } | |
336 | }, | |
337 | onSubmit: function() { | |
338 | var wizard = this.up('pveCephInstallWizard'); | |
339 | wizard.close(); | |
340 | } | |
341 | } | |
342 | ] | |
2248c6c8 | 343 | }); |