Allow to set the firewall log rate limit and burst from the UI

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-04-01 14:45:11 +02:00 committed by Thomas Lamprecht
parent 4e36fbabe8
commit 40120a3120
3 changed files with 103 additions and 0 deletions

View File

@ -85,6 +85,7 @@ JSSRC= \
window/StartupEdit.js \
window/CephInstall.js \
window/FirewallEnableEdit.js \
window/FirewallLograteEdit.js \
panel/NotesView.js \
grid/ResourceGrid.js \
grid/PoolMembers.js \

View File

@ -103,6 +103,14 @@ Ext.define('PVE.FirewallOptions', {
} else if (me.fwtype === 'dc') {
add_boolean_row('enable', gettext('Firewall'), 0);
add_boolean_row('ebtables', 'ebtables', 1);
me.rows.log_ratelimit = {
header: gettext('Log rate limit'),
required: true,
defaultValue: 'enable=0',
editor: {
xtype: 'pveFirewallLograteEdit'
}
};
}
if (me.fwtype === 'dc' || me.fwtype === 'vm') {

View File

@ -0,0 +1,94 @@
/*jslint confusion: true*/
Ext.define('PVE.FirewallLograteInputPanel', {
extend: 'Proxmox.panel.InputPanel',
xtype: 'pveFirewallLograteInputPanel',
viewModel: {},
items: [
{
xtype: 'proxmoxcheckbox',
name: 'enable',
reference: 'enable',
fieldLabel: gettext('Enable'),
value: false
},
{
layout: 'hbox',
border: false,
items: [
{
xtype: 'numberfield',
name: 'rate',
fieldLabel: gettext('Log rate limit'),
minValue: 1,
maxValue: 99,
allowBlank: false,
flex: 2,
value: 1
},
{
html: '<div style="margin: auto; padding: 2.5px;"><b>/</b></div>'
},
{
xtype: 'proxmoxKVComboBox',
name: 'unit',
comboItems: [['second', 'second'], ['minute', 'minute'],
['hour', 'hour'], ['day', 'day']],
allowBlank: false,
flex: 1,
value: 'second'
}
]
},
{
xtype: 'numberfield',
name: 'burst',
fieldLabel: gettext('Log burst limit'),
minValue: 1,
maxValue: 99,
value: 5
}
],
onGetValues: function(values) {
var me = this;
var vals = {};
vals.enable = values.enable !== undefined ? 1 : 0;
vals.rate = values.rate + '/' + values.unit;
vals.burst = values.burst;
var properties = PVE.Parser.printPropertyString(vals, undefined);
if (properties == '') {
return { 'delete': 'log_ratelimit' };
}
return { log_ratelimit: properties };
},
setValues: function(values) {
var me = this;
var properties = {};
if (values.log_ratelimit !== undefined) {
properties = PVE.Parser.parsePropertyString(values.log_ratelimit);
var matches = properties.rate.match(/^(\d+)\/(second|minute|hour|day)$/);
if (matches) {
properties.rate = matches[1];
properties.unit = matches[2];
}
}
me.callParent([properties]);
}
});
Ext.define('PVE.FirewallLograteEdit', {
extend: 'Proxmox.window.Edit',
xtype: 'pveFirewallLograteEdit',
subject: gettext('Log rate limit'),
items: [{
xtype: 'pveFirewallLograteInputPanel'
}],
autoLoad: true
});