[pve-devel] [PATCH manager v2] Allow to set the firewall log rate limit and burst from the UI
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Apr 1 15:01:49 CEST 2019
On 4/1/19 2:45 PM, Christian Ebner wrote:
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
> Version 2:
> * Values are retained in config while disable/enable
> * Removed disabling of the textfield and combobox when unchecking enable
> in order to get the values instead of undefined.
> * initComponent -> autoLoad: true
applied, thanks! Additionally you could delete the keys if they are set equal
to our backend default, like we do at other places, but not to important.
>
> www/manager6/Makefile | 1 +
> www/manager6/grid/FirewallOptions.js | 8 +++
> www/manager6/window/FirewallLograteEdit.js | 94 ++++++++++++++++++++++++++++++
> 3 files changed, 103 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..c48be192
> --- /dev/null
> +++ b/www/manager6/window/FirewallLograteEdit.js
> @@ -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
> +});
>
More information about the pve-devel
mailing list