]>
Commit | Line | Data |
---|---|---|
b42d008b TL |
1 | Ext.define('PVE.storage.Ceph.Model', { |
2 | extend: 'Ext.app.ViewModel', | |
3 | alias: 'viewmodel.cephstorage', | |
c0dee88e | 4 | |
b42d008b TL |
5 | data: { |
6 | pveceph: true, | |
f6710aac | 7 | pvecephPossible: true, |
2d6f898b | 8 | namespacePresent: false, |
f6710aac | 9 | }, |
b42d008b | 10 | }); |
0d1ac958 | 11 | |
b42d008b | 12 | Ext.define('PVE.storage.Ceph.Controller', { |
39f2b04f | 13 | extend: 'PVE.controller.StorageEdit', |
b42d008b TL |
14 | alias: 'controller.cephstorage', |
15 | ||
16 | control: { | |
17 | '#': { | |
f6710aac | 18 | afterrender: 'queryMonitors', |
0d1ac958 | 19 | }, |
b42d008b | 20 | 'textfield[name=username]': { |
f6710aac | 21 | disable: 'resetField', |
0d1ac958 | 22 | }, |
b42d008b | 23 | 'displayfield[name=monhost]': { |
f6710aac | 24 | enable: 'queryMonitors', |
b42d008b TL |
25 | }, |
26 | 'textfield[name=monhost]': { | |
27 | disable: 'resetField', | |
f6710aac TL |
28 | enable: 'resetField', |
29 | }, | |
2d6f898b AL |
30 | 'textfield[name=namespace]': { |
31 | change: 'updateNamespaceHint', | |
32 | }, | |
b42d008b TL |
33 | }, |
34 | resetField: function(field) { | |
35 | field.reset(); | |
36 | }, | |
2d6f898b AL |
37 | updateNamespaceHint: function(field, newVal, oldVal) { |
38 | this.getViewModel().set('namespacePresent', newVal); | |
39 | }, | |
b42d008b TL |
40 | queryMonitors: function(field, newVal, oldVal) { |
41 | // we get called with two signatures, the above one for a field | |
42 | // change event and the afterrender from the view, this check only | |
43 | // can be true for the field change one and omit the API request if | |
44 | // pveceph got unchecked - as it's not needed there. | |
45 | if (field && !newVal && oldVal) { | |
46 | return; | |
47 | } | |
48 | var view = this.getView(); | |
49 | var vm = this.getViewModel(); | |
50 | if (!(view.isCreate || vm.get('pveceph'))) { | |
51 | return; // only query on create or if editing a pveceph store | |
52 | } | |
0d1ac958 | 53 | |
b42d008b | 54 | var monhostField = this.lookupReference('monhost'); |
0d1ac958 | 55 | |
b42d008b TL |
56 | Proxmox.Utils.API2Request({ |
57 | url: '/api2/json/nodes/localhost/ceph/mon', | |
58 | method: 'GET', | |
59 | scope: this, | |
60 | callback: function(options, success, response) { | |
61 | var data = response.result.data; | |
62 | if (response.status === 200) { | |
63 | if (data.length > 0) { | |
64 | var monhost = Ext.Array.pluck(data, 'name').sort().join(','); | |
65 | monhostField.setValue(monhost); | |
66 | monhostField.resetOriginalValue(); | |
67 | if (view.isCreate) { | |
68 | vm.set('pvecephPossible', true); | |
0d1ac958 TL |
69 | } |
70 | } else { | |
71 | vm.set('pveceph', false); | |
0d1ac958 | 72 | } |
b42d008b TL |
73 | } else { |
74 | vm.set('pveceph', false); | |
75 | vm.set('pvecephPossible', false); | |
0d1ac958 | 76 | } |
f6710aac | 77 | }, |
b42d008b | 78 | }); |
f6710aac | 79 | }, |
b42d008b TL |
80 | }); |
81 | ||
82 | Ext.define('PVE.storage.RBDInputPanel', { | |
83 | extend: 'PVE.panel.StorageBase', | |
84 | controller: 'cephstorage', | |
85 | ||
96988dfa DC |
86 | onlineHelp: 'ceph_rados_block_devices', |
87 | ||
b42d008b | 88 | viewModel: { |
f6710aac | 89 | type: 'cephstorage', |
0d1ac958 TL |
90 | }, |
91 | ||
92 | setValues: function(values) { | |
93 | if (values.monhost) { | |
94 | this.viewModel.set('pveceph', false); | |
95 | this.lookupReference('pvecephRef').setValue(false); | |
96 | this.lookupReference('pvecephRef').resetOriginalValue(); | |
97 | } | |
2d6f898b AL |
98 | if (values.namespace) { |
99 | this.getViewModel().set('namespacePresent', true); | |
100 | } | |
0d1ac958 TL |
101 | this.callParent([values]); |
102 | }, | |
103 | ||
8058410f | 104 | initComponent: function() { |
c0dee88e DM |
105 | var me = this; |
106 | ||
3c23c025 DC |
107 | if (!me.nodename) { |
108 | me.nodename = 'localhost'; | |
109 | } | |
f28ec3e4 | 110 | me.type = 'rbd'; |
c0dee88e | 111 | |
4e7585f5 DC |
112 | me.column1 = []; |
113 | ||
114 | if (me.isCreate) { | |
115 | me.column1.push({ | |
116 | xtype: 'pveCephPoolSelector', | |
0d1ac958 TL |
117 | nodename: me.nodename, |
118 | name: 'pool', | |
8c93faf9 TL |
119 | bind: { |
120 | disabled: '{!pveceph}', | |
121 | submitValue: '{pveceph}', | |
f6710aac | 122 | hidden: '{!pveceph}', |
8c93faf9 | 123 | }, |
0d1ac958 | 124 | fieldLabel: gettext('Pool'), |
f6710aac TL |
125 | allowBlank: false, |
126 | }, { | |
4e7585f5 | 127 | xtype: 'textfield', |
0d1ac958 TL |
128 | name: 'pool', |
129 | value: 'rbd', | |
8c93faf9 TL |
130 | bind: { |
131 | disabled: '{pveceph}', | |
132 | submitValue: '{!pveceph}', | |
f6710aac | 133 | hidden: '{pveceph}', |
8c93faf9 | 134 | }, |
0d1ac958 | 135 | fieldLabel: gettext('Pool'), |
f6710aac | 136 | allowBlank: false, |
4e7585f5 DC |
137 | }); |
138 | } else { | |
139 | me.column1.push({ | |
140 | xtype: 'displayfield', | |
141 | nodename: me.nodename, | |
142 | name: 'pool', | |
143 | fieldLabel: gettext('Pool'), | |
f6710aac | 144 | allowBlank: false, |
4e7585f5 DC |
145 | }); |
146 | } | |
147 | ||
148 | me.column1.push( | |
0d1ac958 TL |
149 | { |
150 | xtype: 'textfield', | |
151 | name: 'monhost', | |
152 | vtype: 'HostList', | |
8c93faf9 TL |
153 | bind: { |
154 | disabled: '{pveceph}', | |
155 | submitValue: '{!pveceph}', | |
f6710aac | 156 | hidden: '{pveceph}', |
8c93faf9 | 157 | }, |
0d1ac958 TL |
158 | value: '', |
159 | fieldLabel: 'Monitor(s)', | |
f6710aac | 160 | allowBlank: false, |
0d1ac958 TL |
161 | }, |
162 | { | |
163 | xtype: 'displayfield', | |
164 | reference: 'monhost', | |
165 | bind: { | |
166 | disabled: '{!pveceph}', | |
f6710aac | 167 | hidden: '{!pveceph}', |
3c23c025 | 168 | }, |
0d1ac958 | 169 | value: '', |
f6710aac | 170 | fieldLabel: 'Monitor(s)', |
0d1ac958 TL |
171 | }, |
172 | { | |
173 | xtype: me.isCreate ? 'textfield' : 'displayfield', | |
174 | name: 'username', | |
8c93faf9 TL |
175 | bind: { |
176 | disabled: '{pveceph}', | |
f6710aac | 177 | submitValue: '{!pveceph}', |
8c93faf9 | 178 | }, |
0d1ac958 TL |
179 | value: 'admin', |
180 | fieldLabel: gettext('User name'), | |
f6710aac TL |
181 | allowBlank: true, |
182 | }, | |
4e7585f5 | 183 | ); |
3c23c025 | 184 | |
c0dee88e | 185 | me.column2 = [ |
c0dee88e DM |
186 | { |
187 | xtype: 'pveContentTypeSelector', | |
188 | cts: ['images', 'rootdir'], | |
189 | fieldLabel: gettext('Content'), | |
190 | name: 'content', | |
191 | value: ['images'], | |
192 | multiSelect: true, | |
f6710aac | 193 | allowBlank: false, |
c0dee88e DM |
194 | }, |
195 | { | |
896c0d50 | 196 | xtype: 'proxmoxcheckbox', |
c0dee88e DM |
197 | name: 'krbd', |
198 | uncheckedValue: 0, | |
f6710aac TL |
199 | fieldLabel: 'KRBD', |
200 | }, | |
c0dee88e | 201 | ]; |
0d1ac958 | 202 | |
2d6f898b | 203 | me.columnB = [ |
42c455fc AL |
204 | { |
205 | xtype: me.isCreate ? 'textarea' : 'displayfield', | |
206 | name: 'keyring', | |
207 | fieldLabel: 'Keyring', | |
208 | value: me.isCreate ? '' : '***********', | |
209 | allowBlank: false, | |
210 | bind: { | |
211 | hidden: '{pveceph}', | |
212 | disabled: '{pveceph}', | |
213 | }, | |
214 | }, | |
2d6f898b AL |
215 | { |
216 | xtype: 'proxmoxcheckbox', | |
217 | name: 'pveceph', | |
218 | reference: 'pvecephRef', | |
219 | bind: { | |
220 | disabled: '{!pvecephPossible}', | |
221 | value: '{pveceph}', | |
222 | }, | |
223 | checked: true, | |
224 | uncheckedValue: 0, | |
225 | submitValue: false, | |
226 | hidden: !me.isCreate, | |
227 | boxLabel: gettext('Use Proxmox VE managed hyper-converged ceph pool'), | |
0d1ac958 | 228 | }, |
97edb617 TL |
229 | ]; |
230 | ||
231 | me.advancedColumn1 = [ | |
232 | { | |
233 | xtype: 'pmxDisplayEditField', | |
234 | editable: me.isCreate, | |
235 | name: 'namespace', | |
236 | value: '', | |
237 | fieldLabel: gettext('Namespace'), | |
238 | allowBlank: true, | |
239 | }, | |
240 | ]; | |
241 | me.advancedColumn2 = [ | |
2d6f898b AL |
242 | { |
243 | xtype: 'displayfield', | |
244 | name: 'namespace-hint', | |
245 | userCls: 'pmx-hint', | |
246 | value: gettext('RBD namespaces must be created manually!'), | |
247 | bind: { | |
248 | hidden: '{!namespacePresent}', | |
249 | }, | |
250 | }, | |
251 | ]; | |
c0dee88e | 252 | |
c0dee88e | 253 | me.callParent(); |
f6710aac | 254 | }, |
c0dee88e | 255 | }); |