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