gui: expose lxc features

but constrain editing to root@pam
give a checkbox (for now) for nfs and cifs, but keep all that are manually set

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-11-05 10:07:56 +01:00 committed by Thomas Lamprecht
parent 1f6700485b
commit 725128bbff
3 changed files with 100 additions and 0 deletions

View File

@ -146,6 +146,7 @@ JSSRC= \
lxc/Summary.js \
lxc/Network.js \
lxc/Resources.js \
lxc/FeaturesEdit.js \
lxc/Options.js \
lxc/DNS.js \
lxc/Config.js \

View File

@ -0,0 +1,93 @@
Ext.define('PVE.lxc.FeaturesInputPanel', {
extend: 'Proxmox.panel.InputPanel',
xtype: 'pveLxcFeaturesInputPanel',
// used to save the mounts fstypes until sending
mounts: [],
fstypes: ['nfs', 'cifs'],
items: [
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('keyctl'),
name: 'keyctl'
},
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('Nesting'),
name: 'nesting'
},
{
xtype: 'proxmoxcheckbox',
name: 'nfs',
fieldLabel: 'NFS'
},
{
xtype: 'proxmoxcheckbox',
name: 'cifs',
fieldLabel: 'CIFS'
}
],
onGetValues: function(values) {
var me = this;
var mounts = me.mounts;
me.fstypes.forEach(function(fs) {
if (values[fs]) {
mounts.push(fs);
}
delete values[fs];
});
if (mounts.length) {
values.mount = mounts.join(';');
}
var featuresstring = PVE.Parser.printPropertyString(values, undefined);
if (featuresstring == '') {
return { 'delete': 'features' };
}
return { features: featuresstring };
},
setValues: function(values) {
var me = this;
me.down('field[name=keyctl]').setDisabled(!values.unprivileged);
if (values.features) {
var res = PVE.Parser.parsePropertyString(values.features);
me.mounts = [];
if (res.mount) {
res.mount.split(/[; ]/).forEach(function(item) {
if (me.fstypes.indexOf(item) === -1) {
me.mounts.push(item);
} else {
res[item] = 1;
}
});
}
this.callParent([res]);
}
}
});
Ext.define('PVE.lxc.FeaturesEdit', {
extend: 'Proxmox.window.Edit',
xtype: 'pveLxcFeaturesEdit',
subject: gettext('Features'),
items: [{
xtype: 'pveLxcFeaturesInputPanel'
}],
initComponent : function() {
var me = this;
me.callParent();
me.load();
}
});

View File

@ -134,6 +134,12 @@ Ext.define('PVE.lxc.Options', {
header: gettext('Unprivileged container'),
renderer: Proxmox.Utils.format_boolean,
defaultValue: 0
},
features: {
header: gettext('Features'),
defaultValue: Proxmox.Utils.noneText,
editor: Proxmox.UserName === 'root@pam' ?
'PVE.lxc.FeaturesEdit' : undefined
}
};