[pve-devel] [PATCH manager] Allow to set the firewall log rate limit and burst from the UI
Christian Ebner
c.ebner at proxmox.com
Mon Apr 1 12:39:23 CEST 2019
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/grid/FirewallOptions.js | 8 +++
www/manager6/window/FirewallLograteEdit.js | 105 +++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 www/manager6/window/FirewallLograteEdit.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 962a3f4d..5ad70933 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -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 \
diff --git a/www/manager6/grid/FirewallOptions.js b/www/manager6/grid/FirewallOptions.js
index 72fad34f..2952e854 100644
--- a/www/manager6/grid/FirewallOptions.js
+++ b/www/manager6/grid/FirewallOptions.js
@@ -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') {
diff --git a/www/manager6/window/FirewallLograteEdit.js b/www/manager6/window/FirewallLograteEdit.js
new file mode 100644
index 00000000..dc754411
--- /dev/null
+++ b/www/manager6/window/FirewallLograteEdit.js
@@ -0,0 +1,105 @@
+/*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,
+ bind: {
+ disabled: '{!enable.checked}'
+ }
+ },
+ {
+ 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',
+ bind: {
+ disabled: '{!enable.checked}'
+ }
+ }
+ ]
+ },
+ {
+ xtype: 'numberfield',
+ name: 'burst',
+ fieldLabel: gettext('Log burst limit'),
+ minValue: 1,
+ maxValue: 99,
+ value: 5,
+ bind: {
+ disabled: '{!enable.checked}'
+ }
+ }
+ ],
+
+ onGetValues: function(values) {
+ var me = this;
+ if (values.enable) {
+ values.rate += '/' + values.unit;
+ delete values.unit;
+ }
+ var properties = PVE.Parser.printPropertyString(values, undefined);
+ if (properties == '') {
+ return { 'delete': 'log_ratelimit' };
+ }
+ return { log_ratelimit: properties };
+ },
+
+ setValues: function(values) {
+ var me = this;
+
+ var 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'
+ }],
+
+ initComponent : function() {
+ var me = this;
+
+ me.callParent();
+ me.load();
+ }
+});
--
2.11.0
More information about the pve-devel
mailing list