[pve-devel] [RFC v2 manager 1/1] fix: # 2123 Logging of user defined firewall rules
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Mar 19 14:56:02 CET 2019
On 3/18/19 5:05 PM, Christian Ebner wrote:
> This patch relies on the corresponding patch to pve-firewall, adding the user
> defined log levels for firewall rules.
>
> By this, the user can select a per-rule log level for self defined rules. These
> are independent of the global log level, which is defined in the firewall options.
>
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
>
> Version 2:
> * Introduced PVE.FirewallLogLevel to share it between FirewallOptions.js and
> FirewallRules.js
> * Reordered elements of the array to be in order of the corresponding numeric
> value from the log_level_hash as defined in pve-firewall/src/PVE/Firewall.pm
>
> www/manager6/grid/FirewallOptions.js | 20 +++++++++++++++-----
> www/manager6/grid/FirewallRules.js | 17 +++++++++++++++--
> 2 files changed, 30 insertions(+), 7 deletions(-)
>
> diff --git a/www/manager6/grid/FirewallOptions.js b/www/manager6/grid/FirewallOptions.js
> index 1d56ecc0..f2e65fbc 100644
> --- a/www/manager6/grid/FirewallOptions.js
> +++ b/www/manager6/grid/FirewallOptions.js
> @@ -53,12 +53,9 @@ Ext.define('PVE.FirewallOptions', {
> subject: name,
> fieldDefaults: { labelWidth: labelWidth || 100 },
> items: {
> - xtype: 'proxmoxKVComboBox',
> + xtype: 'pveFirewallLogLevels',
> name: name,
> - fieldLabel: name,
> - comboItems: [['nolog', 'nolog'], ['info', 'info'], ['err', 'err'],
> - ['warning', 'warning'], ['crit', 'crit'], ['alert', 'alert'],
> - ['emerg', 'emerg'], ['debug', 'debug']]
> + fieldLabel: name
> }
> }
> };
> @@ -179,3 +176,16 @@ Ext.define('PVE.FirewallOptions', {
> me.on('deactivate', me.rstore.stopUpdate);
> }
> });
> +
> +
> +Ext.define('PVE.FirewallLogLevels', {
> + extend: 'Proxmox.form.KVComboBox',
> + alias: ['widget.pveFirewallLogLevels'],
> +
> + name: name,
> + fieldName: name,
huh? name as variable is not defined here, also "fieldName" should be "fieldLabel",
I'd guess..
Actually you could use the defaults:
> name: 'log',
> fieldLabel: gettext('Log level')
so that in the FirewallRulePanel it'd be enough to define the xtype, and in
FirewallOptions you overwrite both anyway.
> + value: 'nolog',
> + comboItems: [['nolog', 'nolog'], ['emerg', 'emerg'], ['alert', 'alert'],
> + ['crit', 'crit'], ['err', 'err'], ['warning', 'warning'],
> + ['notice', 'notice'], ['info', 'info'], ['debug', 'debug']]
> +});
> diff --git a/www/manager6/grid/FirewallRules.js b/www/manager6/grid/FirewallRules.js
> index 85b30371..1a6b2002 100644
> --- a/www/manager6/grid/FirewallRules.js
> +++ b/www/manager6/grid/FirewallRules.js
> @@ -59,7 +59,7 @@ Ext.define('PVE.FirewallRulePanel', {
> // hack: editable ComboGrid returns nothing when empty, so we need to set ''
> // Also, disabled text fields return nothing, so we need to set ''
>
> - Ext.Array.each(['source', 'dest', 'macro', 'proto', 'sport', 'dport'], function(key) {
> + Ext.Array.each(['source', 'dest', 'macro', 'proto', 'sport', 'dport', 'log'], function(key) {
> if (values[key] === undefined) {
> values[key] = '';
> }
> @@ -205,9 +205,14 @@ Ext.define('PVE.FirewallRulePanel', {
> name: 'dport',
> value: '',
> fieldLabel: gettext('Dest. port')
> + },
> + {
> + xtype: 'pveFirewallLogLevels',
> + name: 'log',
> + fieldLabel: gettext('Log level')
> }
> ];
> -
> +
> me.columnB = [
> {
> xtype: 'textfield',
> @@ -736,6 +741,14 @@ Ext.define('PVE.FirewallRules', {
> width: 100
> },
> {
> + header: gettext('Log level'),
> + dataIndex: 'log',
> + renderer: function(value, metaData, record) {
> + return render_errors('log', value, metaData, record);
> + },
> + width: 100
> + },
> + {
> header: gettext('Comment'),
> dataIndex: 'comment',
> flex: 1,
>
More information about the pve-devel
mailing list