]>
Commit | Line | Data |
---|---|---|
64f9c6d6 DC |
1 | Ext.define('PVE.node.CreateLVMThin', { |
2 | extend: 'Proxmox.window.Edit', | |
3 | xtype: 'pveCreateLVMThin', | |
4 | ||
0a778d02 | 5 | onlineHelp: 'chapter_lvm', |
64f9c6d6 DC |
6 | subject: 'LVM Thinpool', |
7 | ||
8 | showProgress: true, | |
0a778d02 | 9 | isCreate: true, |
64f9c6d6 | 10 | |
8058410f | 11 | initComponent: function() { |
0a778d02 | 12 | let me = this; |
64f9c6d6 DC |
13 | |
14 | if (!me.nodename) { | |
15 | throw "no node name specified"; | |
16 | } | |
17 | ||
64f9c6d6 | 18 | Ext.applyIf(me, { |
0a778d02 | 19 | url: `/nodes/${me.nodename}/disks/lvmthin`, |
64f9c6d6 DC |
20 | method: 'POST', |
21 | items: [ | |
22 | { | |
d0cfe2ea | 23 | xtype: 'pmxDiskSelector', |
64f9c6d6 DC |
24 | name: 'device', |
25 | nodename: me.nodename, | |
26 | diskType: 'unused', | |
27 | fieldLabel: gettext('Disk'), | |
f6710aac | 28 | allowBlank: false, |
64f9c6d6 DC |
29 | }, |
30 | { | |
31 | xtype: 'proxmoxtextfield', | |
32 | name: 'name', | |
33 | fieldLabel: gettext('Name'), | |
f6710aac | 34 | allowBlank: false, |
64f9c6d6 DC |
35 | }, |
36 | { | |
37 | xtype: 'proxmoxcheckbox', | |
38 | name: 'add_storage', | |
39 | fieldLabel: gettext('Add Storage'), | |
f6710aac TL |
40 | value: '1', |
41 | }, | |
42 | ], | |
64f9c6d6 DC |
43 | }); |
44 | ||
45 | me.callParent(); | |
f6710aac | 46 | }, |
64f9c6d6 DC |
47 | }); |
48 | ||
49 | Ext.define('PVE.node.LVMThinList', { | |
50 | extend: 'Ext.grid.Panel', | |
51 | xtype: 'pveLVMThinList', | |
52 | ||
14066c09 FE |
53 | viewModel: { |
54 | data: { | |
55 | thinPool: '', | |
56 | volumeGroup: '', | |
57 | }, | |
58 | }, | |
59 | ||
60 | controller: { | |
61 | xclass: 'Ext.app.ViewController', | |
62 | ||
63 | destroyThinPool: function() { | |
64 | let me = this; | |
65 | let vm = me.getViewModel(); | |
66 | let view = me.getView(); | |
67 | ||
68 | const thinPool = vm.get('thinPool'); | |
69 | const volumeGroup = vm.get('volumeGroup'); | |
70 | ||
71 | if (!view.nodename) { | |
72 | throw "no node name specified"; | |
73 | } | |
74 | ||
75 | if (!thinPool) { | |
76 | throw "no thin pool specified"; | |
77 | } | |
78 | ||
79 | if (!volumeGroup) { | |
80 | throw "no volume group specified"; | |
81 | } | |
82 | ||
83 | Ext.create('Proxmox.window.SafeDestroy', { | |
84 | url: `/nodes/${view.nodename}/disks/lvmthin/${thinPool}`, | |
85 | params: { 'volume-group': volumeGroup }, | |
86 | item: { id: `${volumeGroup}/${thinPool}` }, | |
87 | showProgress: true, | |
88 | taskName: 'lvmthinremove', | |
89 | taskDone: () => { view.reload(); }, | |
90 | }).show(); | |
91 | }, | |
92 | }, | |
93 | ||
64f9c6d6 | 94 | emptyText: gettext('No thinpools found'), |
0a778d02 | 95 | |
64f9c6d6 DC |
96 | stateful: true, |
97 | stateId: 'grid-node-lvmthin', | |
0a778d02 TL |
98 | |
99 | rootVisible: false, | |
100 | useArrows: true, | |
101 | ||
64f9c6d6 DC |
102 | columns: [ |
103 | { | |
104 | text: gettext('Name'), | |
105 | dataIndex: 'lv', | |
f6710aac | 106 | flex: 1, |
64f9c6d6 | 107 | }, |
92a1b603 FE |
108 | { |
109 | header: 'Volume Group', | |
110 | width: 110, | |
111 | dataIndex: 'vg', | |
112 | }, | |
64f9c6d6 DC |
113 | { |
114 | header: gettext('Usage'), | |
115 | width: 110, | |
116 | dataIndex: 'usage', | |
117 | tdCls: 'x-progressbar-default-cell', | |
118 | xtype: 'widgetcolumn', | |
119 | widget: { | |
f6710aac TL |
120 | xtype: 'pveProgressBar', |
121 | }, | |
64f9c6d6 DC |
122 | }, |
123 | { | |
124 | header: gettext('Size'), | |
125 | width: 100, | |
126 | align: 'right', | |
127 | sortable: true, | |
128 | renderer: Proxmox.Utils.format_size, | |
f6710aac | 129 | dataIndex: 'lv_size', |
64f9c6d6 DC |
130 | }, |
131 | { | |
132 | header: gettext('Used'), | |
133 | width: 100, | |
134 | align: 'right', | |
135 | sortable: true, | |
136 | renderer: Proxmox.Utils.format_size, | |
f6710aac | 137 | dataIndex: 'used', |
64f9c6d6 DC |
138 | }, |
139 | { | |
140 | header: gettext('Metadata Usage'), | |
141 | width: 120, | |
142 | dataIndex: 'metadata_usage', | |
143 | tdCls: 'x-progressbar-default-cell', | |
144 | xtype: 'widgetcolumn', | |
145 | widget: { | |
f6710aac TL |
146 | xtype: 'pveProgressBar', |
147 | }, | |
64f9c6d6 DC |
148 | }, |
149 | { | |
150 | header: gettext('Metadata Size'), | |
151 | width: 120, | |
152 | align: 'right', | |
153 | sortable: true, | |
154 | renderer: Proxmox.Utils.format_size, | |
f6710aac | 155 | dataIndex: 'metadata_size', |
64f9c6d6 DC |
156 | }, |
157 | { | |
158 | header: gettext('Metadata Used'), | |
159 | width: 125, | |
160 | align: 'right', | |
161 | sortable: true, | |
162 | renderer: Proxmox.Utils.format_size, | |
f6710aac TL |
163 | dataIndex: 'metadata_used', |
164 | }, | |
64f9c6d6 DC |
165 | ], |
166 | ||
64f9c6d6 DC |
167 | tbar: [ |
168 | { | |
169 | text: gettext('Reload'), | |
170 | iconCls: 'fa fa-refresh', | |
171 | handler: function() { | |
0a778d02 | 172 | this.up('panel').reload(); |
f6710aac | 173 | }, |
64f9c6d6 DC |
174 | }, |
175 | { | |
176 | text: gettext('Create') + ': Thinpool', | |
177 | handler: function() { | |
0a778d02 TL |
178 | var view = this.up('panel'); |
179 | Ext.create('PVE.node.CreateLVMThin', { | |
180 | nodename: view.nodename, | |
181 | taskDone: () => view.reload(), | |
182 | autoShow: true, | |
183 | }); | |
f6710aac TL |
184 | }, |
185 | }, | |
14066c09 FE |
186 | '->', |
187 | { | |
188 | xtype: 'tbtext', | |
189 | data: { | |
190 | thinPool: undefined, | |
191 | volumeGroup: undefined, | |
192 | }, | |
193 | bind: { | |
194 | data: { | |
195 | thinPool: "{thinPool}", | |
196 | volumeGroup: "{volumeGroup}", | |
197 | }, | |
198 | }, | |
199 | tpl: [ | |
200 | '<tpl if="thinPool">', | |
201 | '<tpl if="volumeGroup">', | |
202 | 'Thinpool {volumeGroup}/{thinPool}:', | |
203 | '<tpl else>', // volumeGroup | |
204 | 'Missing volume group (node running old version?)', | |
205 | '</tpl>', | |
206 | '<tpl else>', // thinPool | |
207 | Ext.String.format(gettext('No {0} selected'), 'thinpool'), | |
208 | '</tpl>', | |
209 | ], | |
210 | }, | |
211 | { | |
212 | text: gettext('More'), | |
213 | iconCls: 'fa fa-bars', | |
214 | disabled: true, | |
215 | bind: { | |
216 | disabled: '{!volumeGroup || !thinPool}', | |
217 | }, | |
218 | menu: [ | |
219 | { | |
220 | text: gettext('Destroy'), | |
221 | itemId: 'remove', | |
222 | iconCls: 'fa fa-fw fa-trash-o', | |
223 | handler: 'destroyThinPool', | |
224 | disabled: true, | |
225 | bind: { | |
226 | disabled: '{!volumeGroup || !thinPool}', | |
227 | }, | |
228 | }, | |
229 | ], | |
230 | }, | |
64f9c6d6 DC |
231 | ], |
232 | ||
233 | reload: function() { | |
0a778d02 | 234 | let me = this; |
64f9c6d6 DC |
235 | me.store.load(); |
236 | me.store.sort(); | |
237 | }, | |
238 | ||
239 | listeners: { | |
240 | activate: function() { | |
0a778d02 | 241 | this.reload(); |
f6710aac | 242 | }, |
14066c09 FE |
243 | selectionchange: function(model, selected) { |
244 | let me = this; | |
245 | let vm = me.getViewModel(); | |
246 | ||
247 | vm.set('volumeGroup', selected[0]?.data.vg || ''); | |
248 | vm.set('thinPool', selected[0]?.data.lv || ''); | |
249 | }, | |
64f9c6d6 DC |
250 | }, |
251 | ||
252 | initComponent: function() { | |
0a778d02 | 253 | let me = this; |
64f9c6d6 DC |
254 | |
255 | me.nodename = me.pveSelNode.data.node; | |
256 | if (!me.nodename) { | |
257 | throw "no node name specified"; | |
258 | } | |
259 | ||
260 | Ext.apply(me, { | |
261 | store: { | |
0a778d02 TL |
262 | fields: [ |
263 | 'lv', | |
264 | 'lv_size', | |
265 | 'used', | |
266 | 'metadata_size', | |
267 | 'metadata_used', | |
64f9c6d6 DC |
268 | { |
269 | type: 'number', | |
270 | name: 'usage', | |
0a778d02 | 271 | calculate: data => data.used / data.lv_size, |
64f9c6d6 DC |
272 | }, |
273 | { | |
274 | type: 'number', | |
275 | name: 'metadata_usage', | |
0a778d02 | 276 | calculate: data => data.metadata_used / data.metadata_size, |
f6710aac | 277 | }, |
64f9c6d6 DC |
278 | ], |
279 | proxy: { | |
280 | type: 'proxmox', | |
0a778d02 | 281 | url: `/api2/json/nodes/${me.nodename}/disks/lvmthin`, |
64f9c6d6 | 282 | }, |
f6710aac TL |
283 | sorters: 'lv', |
284 | }, | |
64f9c6d6 DC |
285 | }); |
286 | ||
287 | me.callParent(); | |
288 | ||
289 | Proxmox.Utils.monStoreErrors(me, me.getStore(), true); | |
290 | me.reload(); | |
f6710aac | 291 | }, |
64f9c6d6 DC |
292 | }); |
293 |