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