]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/ceph/CephInstallWizard.js
gui: ceph installer: fix typo
[pve-manager.git] / www / manager6 / ceph / CephInstallWizard.js
1 /*jslint confusion: true*/
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: {
10 nodename: '',
11 configuration: true,
12 isInstalled: false
13 }
14 },
15 cbindData: {
16 nodename: undefined
17 },
18 title: gettext('Setup'),
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 },
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 },
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 an initial configuration.'+
55 ' The configuration step is only needed once per cluster and will be skipped if a config is already present.</p>'+
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>',
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);
65 this.up('pveCephInstallWizard').down('#next').setText(gettext('Start installation'));
66 },
67 deactivate: function() {
68 if (this.onlineHelp) {
69 Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp);
70 }
71 this.up('pveCephInstallWizard').down('#next').setText(gettext('Next'));
72 }
73 }
74 },
75 {
76 title: gettext('Installation'),
77 xtype: 'panel',
78 layout: 'fit',
79 cbind:{
80 nodename: '{nodename}'
81 },
82 viewModel: {}, // needed to inherit parent viewModel data
83 listeners: {
84 afterrender: function() {
85 var me = this;
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 }
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) {
104
105 if (success) {
106 me.updateStore.stopUpdate();
107 me.down('textfield').setValue('success');
108 } else if (operation.error.statusText.match("not initialized", "i")) {
109 me.updateStore.stopUpdate();
110 me.up('pveCephInstallWizard').getViewModel().set('configuration',false);
111 me.down('textfield').setValue('success');
112 } else if (operation.error.statusText.match("rados_connect failed", "i")) {
113 me.updateStore.stopUpdate();
114 me.up('pveCephInstallWizard').getViewModel().set('configuration',true);
115 me.down('textfield').setValue('success');
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 },
159 viewModel: {
160 data: {
161 replicas: undefined,
162 minreplicas: undefined
163 }
164 },
165 listeners: {
166 activate: function() {
167 this.up('pveCephInstallWizard').down('#submit').setText(gettext('Next'));
168 },
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 },
176 deactivate: function() {
177 this.up('pveCephInstallWizard').down('#submit').setText(gettext('Finish'));
178 }
179 },
180 column1: [
181 {
182 xtype: 'displayfield',
183 value: gettext('Ceph cluster configuration') + ':'
184 },
185 {
186 xtype: 'proxmoxNetworkSelector',
187 name: 'network',
188 value: '',
189 fieldLabel: 'Public Network IP/CIDR',
190 bind: {
191 allowBlank: '{configuration}'
192 }
193 },
194 {
195 xtype: 'proxmoxNetworkSelector',
196 name: 'cluster-network',
197 fieldLabel: 'Cluster Network IP/CIDR',
198 allowBlank: true,
199 autoSelect: false,
200 emptyText: gettext('Same as Public Network')
201 }
202 // FIXME: add hint about cluster network and/or reference user to docs??
203 ],
204 column2: [
205 {
206 xtype: 'displayfield',
207 value: gettext('First Ceph monitor') + ':'
208 },
209 {
210 xtype: 'pveNodeSelector',
211 fieldLabel: gettext('Monitor node'),
212 name: 'mon-node',
213 selectCurNode: true,
214 allowBlank: false
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'
220 }
221 ],
222 advancedColumn1: [
223 {
224 xtype: 'numberfield',
225 name: 'size',
226 fieldLabel: 'Number of replicas',
227 bind: {
228 value: '{replicas}'
229 },
230 maxValue: 7,
231 minValue: 2,
232 emptyText: '3'
233 },
234 {
235 xtype: 'numberfield',
236 name: 'min_size',
237 fieldLabel: 'Minimum replicas',
238 bind: {
239 maxValue: '{replicas}',
240 value: '{minreplicas}'
241 },
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();
251 this.validate();
252 },
253 emptyText: '2'
254 }
255 ],
256 onGetValues: function(values) {
257 ['cluster-network', 'size', 'min_size'].forEach(function(field) {
258 if (!values[field]) {
259 delete values[field];
260 }
261 });
262 return values;
263 },
264 onSubmit: function() {
265 var me = this;
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({
281 url: '/nodes/' + monNode + '/ceph/mon/' + monNode,
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);
294 }
295 });
296
297 } else {
298 me.up('pveCephInstallWizard').navigateNext();
299 }
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>'+
310 '<ol><li>Install Ceph on other nodes</li>'+
311 '<li>Create additional Ceph Monitors</li>'+
312 '<li>Create Ceph OSDs</li>'+
313 '<li>Create Ceph Pools</li></ol>'+
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 ]
343 });