]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/ceph/CephInstallWizard.js
added basic ability to install ceph via gui
[pve-manager.git] / www / manager6 / ceph / CephInstallWizard.js
1 Ext.define('PVE.ceph.CephInstallWizard', {
2 extend: 'PVE.window.Wizard',
3 alias: 'widget.pveCephInstallWizard',
4 mixins: ['Proxmox.Mixin.CBind'],
5 resizable: false,
6 nodename: undefined,
7 viewModel: {
8 data: {
9 nodename: ''
10 }
11 },
12 cbindData: {
13 nodename: undefined
14 },
15 title: gettext('Installation'),
16 items: [
17 {
18 title: gettext('Info'),
19 xtype: 'panel',
20 border: false,
21 bodyBorder: false,
22 onlineHelp: 'chapter_pveceph',
23 html: '<h3>Ceph?</h3>'+
24 '<blockquote cite="https://ceph.com/"><p>"<b>Ceph</b> is a unified, distributed storage system designed for excellent performance, reliability and scalability."</p></blockquote>'+
25 '<p><b>Ceph</b> is currently <b>not installed</b> on this node, click on the next button below to start the installation.'+
26 ' This wizard will guide you through the necessary steps, after the initial installation you will be offered to create a initial configuration.'+
27 ' The configuration step is only needed once per cluster and will be skipped if a config is already present.</p>'+
28 '<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>',
29 listeners: {
30 activate: function() {
31 // notify owning container that it should display a help button
32 if (this.onlineHelp) {
33 Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp);
34 }
35 this.up('pveCephInstallWizard').down('#back').hide(true);
36 },
37 deactivate: function() {
38 if (this.onlineHelp) {
39 Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp);
40 }
41 }
42 }
43 },
44 {
45 title: gettext('Installation'),
46 xtype: 'panel',
47 layout: 'fit',
48 cbind:{
49 nodename: '{nodename}'
50 },
51 listeners: {
52 afterrender: function() {
53 var me = this;
54 me.down('pveNoVncConsole').fireEvent('activate');
55 },
56 activate: function() {
57 var me = this;
58 var nodename = me.nodename;
59 me.updateStore = Ext.create('Proxmox.data.UpdateStore', {
60 storeid: 'ceph-status-' + nodename,
61 interval: 1000,
62 proxy: {
63 type: 'proxmox',
64 url: '/api2/json/nodes/' + nodename + '/ceph/status'
65 },
66 listeners: {
67 load: function(rec, response, success, operation) {
68 var wizard = me.up('#wizcontent');
69 var tabs = wizard.items;
70 var lastTab = tabs.items[tabs.length-1];
71 if (success) {
72 me.updateStore.stopUpdate();
73 lastTab.enable();
74 wizard.setActiveTab(lastTab);
75 } else if (operation.error.statusText.match("not initialized", "i")) {
76 me.updateStore.stopUpdate();
77 me.down('textfield').setValue('success');
78 } else if (operation.error.statusText.match("rados_connect failed", "i")) {
79 me.updateStore.stopUpdate();
80 lastTab.enable();
81 wizard.setActiveTab(lastTab);
82 } else if (!operation.error.statusText.match("not installed", "i")) {
83 Proxmox.Utils.setErrorMask(me, operation.error.statusText);
84 }
85 }
86 }
87 });
88 me.updateStore.startUpdate();
89 },
90 destroy: function() {
91 var me = this;
92 if (me.updateStore) {
93 me.updateStore.stopUpdate();
94 }
95 }
96 },
97 items: [
98 {
99 itemId: 'jsconsole',
100 consoleType: 'cmd',
101 xtermjs: true,
102 xtype: 'pveNoVncConsole',
103 cbind:{
104 nodename: '{nodename}'
105 },
106 cmd: 'ceph_install'
107 },
108 {
109 xtype: 'textfield',
110 name: 'installSuccess',
111 value: '',
112 allowBlank: false,
113 submitValue: false,
114 hidden: true
115 }
116 ]
117 },
118 {
119 xtype: 'inputpanel',
120 title: gettext('Configuration'),
121 onlineHelp: 'chapter_pveceph',
122 cbind: {
123 nodename: '{nodename}'
124 },
125 listeners: {
126 activate: function() {
127 this.up('pveCephInstallWizard').down('#submit').setText(gettext('Next'));
128 },
129 deactivate: function() {
130 this.up('pveCephInstallWizard').down('#submit').setText(gettext('Finish'));
131 }
132 },
133 column1: [
134 {
135 xtype: 'displayfield',
136 name: 'nodename',
137 fieldLabel: gettext('Node'),
138 cbind: {
139 value: '{nodename}'
140 },
141 padding: 5
142 },
143 {
144 xtype: 'textfield',
145 name: 'network',
146 vtype: 'IPCIDRAddress',
147 value: '',
148 fieldLabel: 'Network IPv4/CIDR',
149 allowBlank: false
150 },
151 {
152 xtype: 'textfield',
153 name: 'cluster-network',
154 vtype: 'IPCIDRAddress',
155 fieldLabel: 'Cluster-Network IPv4/CIDR',
156 allowBlank: true,
157 emptyText: gettext('default')
158 }
159 ],
160 advancedColumn1: [
161 {
162 xtype: 'numberfield',
163 name: 'size',
164 fieldLabel: gettext('Number of replicas'),
165 value: '',
166 maxValue: 7,
167 minValue: 1,
168 allowBlank: true,
169 emptyText: gettext('default')
170 },
171 {
172 xtype: 'numberfield',
173 name: 'min_size',
174 fieldLabel: gettext('Minimum replicas'),
175 value: '',
176 maxValue: 7,
177 minValue: 1,
178 allowBlank: true,
179 emptyText: gettext('default')
180 },
181 {
182 xtype: 'numberfield',
183 name: 'pg_bits',
184 fieldLabel: 'Placement group bits',
185 value: '',
186 maxValue: 14,
187 minValue: 6,
188 allowBlank: true,
189 emptyText: gettext('default')
190 }
191 ],
192 onGetValues: function(values) {
193 ['cluster-network', 'size', 'min_size', 'pg_bits'].forEach(function(field) {
194 if (!values[field]) {
195 delete values[field];
196 }
197 });
198 return values;
199 },
200 onSubmit: function() {
201 var me = this;
202 var wizard = me.up('window');
203 var kv = wizard.getValues();
204 delete kv['delete'];
205 var nodename = me.nodename;
206 delete kv.nodename;
207 Proxmox.Utils.API2Request({
208 url: '/nodes/'+nodename+'/ceph/init',
209 waitMsgTarget: wizard,
210 method: 'POST',
211 params: kv,
212 success: function() {
213 var tp = me.up('#wizcontent');
214 var atab = tp.getActiveTab();
215
216 var next = tp.items.indexOf(atab) + 1;
217 var ntab = tp.items.getAt(next);
218 if (ntab) {
219 ntab.enable();
220 tp.setActiveTab(ntab);
221 }
222 },
223 failure: function(response, opts) {
224 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
225 }
226 });
227 }
228 },
229 {
230 title: gettext('Success'),
231 xtype: 'panel',
232 border: false,
233 bodyBorder: false,
234 onlineHelp: 'pve_ceph_install',
235 html: '<h3>Installation successful!</h3>'+
236 '<p>The basic installation and configuration is completed, depending on your setup some of the following steps are required to start using Ceph:</p>'+
237 '<ul><li>Creating Ceph Monitors</li><li>Creating Ceph OSDs</li><li>Creating Ceph Pools</li></ul>'+
238 '<p>To learn more click on the help button below.</p>',
239 listeners: {
240 activate: function() {
241 // notify owning container that it should display a help button
242 if (this.onlineHelp) {
243 Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp);
244 }
245
246 var tp = this.up('#wizcontent');
247 var idx = tp.items.indexOf(this)-1;
248 for(;idx >= 0;idx--) {
249 var nc = tp.items.getAt(idx);
250 if (nc) {
251 nc.disable();
252 }
253 }
254 },
255 deactivate: function() {
256 if (this.onlineHelp) {
257 Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp);
258 }
259 }
260 },
261 onSubmit: function() {
262 var wizard = this.up('pveCephInstallWizard');
263 wizard.close();
264 }
265 }
266 ]
267 });