mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-11-03 02:47:18 +00:00
add lvmthin to gui
this patch adds the ability to add existing lvm thinpools to the storage configuration via the gui Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
8bc518aca4
commit
0ed3141561
@ -165,6 +165,7 @@ JSSRC= \
|
||||
storage/GlusterFsEdit.js \
|
||||
storage/IScsiEdit.js \
|
||||
storage/LVMEdit.js \
|
||||
storage/LvmThinEdit.js \
|
||||
storage/RBDEdit.js \
|
||||
storage/SheepdogEdit.js \
|
||||
storage/ZFSEdit.js \
|
||||
|
||||
@ -41,6 +41,8 @@ Ext.define('PVE.dc.StorageView', {
|
||||
editor = 'PVE.storage.GlusterFsEdit';
|
||||
} else if (type === 'lvm') {
|
||||
editor = 'PVE.storage.LVMEdit';
|
||||
} else if (type === 'lvmthin') {
|
||||
editor = 'PVE.storage.LvmThinEdit';
|
||||
} else if (type === 'iscsi') {
|
||||
editor = 'PVE.storage.IScsiEdit';
|
||||
} else if (type === 'rbd') {
|
||||
@ -123,6 +125,15 @@ Ext.define('PVE.dc.StorageView', {
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: PVE.Utils.format_storage_type('lvmthin'),
|
||||
iconCls: 'pve-itype-icon-storage',
|
||||
handler: function() {
|
||||
var win = Ext.create('PVE.storage.LvmThinEdit', {});
|
||||
win.on('destroy', reload);
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: PVE.Utils.format_storage_type('nfs'),
|
||||
iconCls: 'pve-itype-icon-network-server',
|
||||
|
||||
269
www/manager/storage/LvmThinEdit.js
Normal file
269
www/manager/storage/LvmThinEdit.js
Normal file
@ -0,0 +1,269 @@
|
||||
Ext.define('PVE.storage.TPoolSelector', {
|
||||
extend: 'Ext.form.field.ComboBox',
|
||||
alias: 'widget.pveTPSelector',
|
||||
|
||||
queryParam: 'vg',
|
||||
|
||||
doRawQuery: function() {
|
||||
},
|
||||
|
||||
onTriggerClick: function() {
|
||||
var me = this;
|
||||
|
||||
if (!me.queryCaching || me.lastQuery !== me.vg) {
|
||||
me.store.removeAll();
|
||||
}
|
||||
|
||||
me.allQuery = me.vg;
|
||||
|
||||
me.callParent();
|
||||
},
|
||||
|
||||
setVG: function(myvg) {
|
||||
var me = this;
|
||||
|
||||
me.vg = myvg;
|
||||
},
|
||||
|
||||
initComponent : function() {
|
||||
var me = this;
|
||||
|
||||
if (!me.nodename) {
|
||||
me.nodename = 'localhost';
|
||||
}
|
||||
|
||||
var store = Ext.create('Ext.data.Store', {
|
||||
fields: [ 'lv' ],
|
||||
proxy: {
|
||||
type: 'pve',
|
||||
url: '/api2/json/nodes/' + me.nodename + '/scan/lvmthin'
|
||||
}
|
||||
});
|
||||
|
||||
Ext.apply(me, {
|
||||
store: store,
|
||||
valueField: 'lv',
|
||||
displayField: 'lv',
|
||||
editable: false,
|
||||
listConfig: {
|
||||
loadingText: gettext('Scanning...'),
|
||||
listeners: {
|
||||
// hack: call setHeight to show scroll bars correctly
|
||||
refresh: function(list) {
|
||||
var lh = PVE.Utils.gridLineHeigh();
|
||||
var count = store.getCount();
|
||||
list.setHeight(lh * ((count > 10) ? 10 : count));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.define('PVE.storage.BaseVGSelector', {
|
||||
extend: 'Ext.form.field.ComboBox',
|
||||
alias: 'widget.pveBaseVGSelector',
|
||||
|
||||
initComponent : function() {
|
||||
var me = this;
|
||||
|
||||
if (!me.nodename) {
|
||||
me.nodename = 'localhost';
|
||||
}
|
||||
|
||||
var store = Ext.create('Ext.data.Store', {
|
||||
autoLoad: {},
|
||||
fields: [ 'vg', 'size', 'free'],
|
||||
proxy: {
|
||||
type: 'pve',
|
||||
url: '/api2/json/nodes/' + me.nodename + '/scan/lvm'
|
||||
}
|
||||
});
|
||||
|
||||
Ext.apply(me, {
|
||||
store: store,
|
||||
valueField: 'vg',
|
||||
displayField: 'vg',
|
||||
queryMode: 'local',
|
||||
editable: false,
|
||||
listConfig: {
|
||||
loadingText: gettext('Scanning...'),
|
||||
listeners: {
|
||||
// hack: call setHeight to show scroll bars correctly
|
||||
refresh: function(list) {
|
||||
var lh = PVE.Utils.gridLineHeigh();
|
||||
var count = store.getCount();
|
||||
list.setHeight(lh * ((count > 10) ? 10 : count));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.define('PVE.storage.LvmThinInputPanel', {
|
||||
extend: 'PVE.panel.InputPanel',
|
||||
|
||||
onGetValues: function(values) {
|
||||
var me = this;
|
||||
|
||||
if (me.create) {
|
||||
values.type = 'lvmthin';
|
||||
} else {
|
||||
delete values.storage;
|
||||
}
|
||||
|
||||
values.disable = values.enable ? 0 : 1;
|
||||
delete values.enable;
|
||||
|
||||
return values;
|
||||
},
|
||||
|
||||
initComponent : function() {
|
||||
var me = this;
|
||||
|
||||
me.column1 = [
|
||||
{
|
||||
xtype: me.create ? 'textfield' : 'displayfield',
|
||||
name: 'storage',
|
||||
height: 22, // hack: set same height as text fields
|
||||
value: me.storageId || '',
|
||||
fieldLabel: 'ID',
|
||||
vtype: 'StorageId',
|
||||
submitValue: !!me.create,
|
||||
allowBlank: false
|
||||
}
|
||||
];
|
||||
|
||||
var vgnameField = Ext.createWidget(me.create ? 'textfield' : 'displayfield', {
|
||||
height: 22, // hack: set same height as text fields
|
||||
name: 'vgname',
|
||||
hidden: !!me.create,
|
||||
disabled: !!me.create,
|
||||
value: '',
|
||||
fieldLabel: gettext('Volume group'),
|
||||
allowBlank: false
|
||||
});
|
||||
|
||||
var thinpoolField = Ext.createWidget(me.create ? 'textfield' : 'displayfield', {
|
||||
height: 22, // hack: set same height as text fields
|
||||
name: 'thinpool',
|
||||
hidden: !!me.create,
|
||||
disabled: !!me.create,
|
||||
value: '',
|
||||
fieldLabel: gettext('Thin Pool'),
|
||||
allowBlank: false
|
||||
});
|
||||
|
||||
if (me.create) {
|
||||
var vgField = Ext.create('PVE.storage.TPoolSelector', {
|
||||
name: 'thinpool',
|
||||
fieldLabel: gettext('Thin Pool'),
|
||||
allowBlank: false
|
||||
});
|
||||
|
||||
me.column1.push({
|
||||
xtype: 'pveBaseVGSelector',
|
||||
name: 'vgname',
|
||||
fieldLabel: gettext('Volume Group'),
|
||||
listeners: {
|
||||
change: function(f, value) {
|
||||
if (me.create) {
|
||||
vgField.setVG(value);
|
||||
vgField.setValue('');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
me.column1.push(vgField);
|
||||
}
|
||||
|
||||
me.column1.push(vgnameField);
|
||||
|
||||
me.column1.push(thinpoolField);
|
||||
|
||||
me.column1.push({
|
||||
xtype: 'pveContentTypeSelector',
|
||||
cts: ['images', 'rootdir'],
|
||||
fieldLabel: gettext('Content'),
|
||||
name: 'content',
|
||||
value: ['images', 'rootdir'],
|
||||
multiSelect: true,
|
||||
allowBlank: false
|
||||
});
|
||||
|
||||
me.column2 = [
|
||||
{
|
||||
xtype: 'PVE.form.NodeSelector',
|
||||
name: 'nodes',
|
||||
fieldLabel: gettext('Nodes'),
|
||||
emptyText: gettext('All') + ' (' +
|
||||
gettext('No restrictions') +')',
|
||||
multiSelect: true,
|
||||
autoSelect: false
|
||||
},
|
||||
{
|
||||
xtype: 'pvecheckbox',
|
||||
name: 'enable',
|
||||
checked: true,
|
||||
uncheckedValue: 0,
|
||||
fieldLabel: gettext('Enable')
|
||||
}
|
||||
];
|
||||
|
||||
me.callParent();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.define('PVE.storage.LvmThinEdit', {
|
||||
extend: 'PVE.window.Edit',
|
||||
|
||||
initComponent : function() {
|
||||
var me = this;
|
||||
|
||||
me.create = !me.storageId;
|
||||
|
||||
if (me.create) {
|
||||
me.url = '/api2/extjs/storage';
|
||||
me.method = 'POST';
|
||||
} else {
|
||||
me.url = '/api2/extjs/storage/' + me.storageId;
|
||||
me.method = 'PUT';
|
||||
}
|
||||
|
||||
var ipanel = Ext.create('PVE.storage.LvmThinInputPanel', {
|
||||
create: me.create,
|
||||
storageId: me.storageId
|
||||
});
|
||||
|
||||
Ext.apply(me, {
|
||||
subject: PVE.Utils.format_storage_type('lvmthin'),
|
||||
isAdd: true,
|
||||
items: [ ipanel ]
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
||||
if (!me.create) {
|
||||
me.load({
|
||||
success: function(response, options) {
|
||||
var values = response.result.data;
|
||||
var ctypes = values.content || '';
|
||||
|
||||
values.content = ctypes.split(',');
|
||||
|
||||
if (values.nodes) {
|
||||
values.nodes = values.nodes.split(',');
|
||||
}
|
||||
values.enable = values.disable ? 0 : 1;
|
||||
ipanel.setValues(values);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user