Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _api_data.py #324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/324-fix-firewall-log-and-log-prefix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- api_info, api_modify - fields ``log`` and ``log-prefix`` in paths ``ip firewall filter``, ``ip firewall mangle``, ``ip firewall nat``, ``ip firewall raw`` now have the correct default values (https://github.com/ansible-collections/community.routeros/pull/324).
16 changes: 8 additions & 8 deletions plugins/module_utils/_api_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2986,8 +2986,8 @@ def join_path(path):
'jump-target': KeyInfo(can_disable=True),
'layer7-protocol': KeyInfo(can_disable=True),
'limit': KeyInfo(can_disable=True),
'log': KeyInfo(can_disable=True),
'log-prefix': KeyInfo(can_disable=True),
'log': KeyInfo(default=False),
'log-prefix': KeyInfo(default=''),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason behind this change? Was the behavior always wrong, or did RouterOS's behavior change from one version to another?

Copy link
Contributor Author

@liquorice-head liquorice-head Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image As far as I'm concerned, the behavior was always wrong. I have tested on 6.49.10, 6.49.13, 7.14.1. If you use the --diff parameter in ansible with check mode, you will see that each time ansible tries to remove these fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can second that. It was always bugging me but I didn't have the time to investigate.

'nth': KeyInfo(can_disable=True),
'out-bridge-port': KeyInfo(can_disable=True),
'out-bridge-port-list': KeyInfo(can_disable=True),
Expand Down Expand Up @@ -3057,8 +3057,8 @@ def join_path(path):
'jump-target': KeyInfo(can_disable=True),
'layer7-protocol': KeyInfo(can_disable=True),
'limit': KeyInfo(can_disable=True),
'log': KeyInfo(can_disable=True),
'log-prefix': KeyInfo(can_disable=True),
'log': KeyInfo(default=False),
'log-prefix': KeyInfo(default=''),
'new-connection-mark': KeyInfo(can_disable=True),
'new-dscp': KeyInfo(can_disable=True),
'new-mss': KeyInfo(can_disable=True),
Expand Down Expand Up @@ -3137,8 +3137,8 @@ def join_path(path):
'jump-target': KeyInfo(can_disable=True),
'layer7-protocol': KeyInfo(can_disable=True),
'limit': KeyInfo(can_disable=True),
'log': KeyInfo(can_disable=True),
'log-prefix': KeyInfo(can_disable=True),
'log': KeyInfo(default=False),
'log-prefix': KeyInfo(default=''),
'nth': KeyInfo(can_disable=True),
'out-bridge-port': KeyInfo(can_disable=True),
'out-bridge-port-list': KeyInfo(can_disable=True),
Expand Down Expand Up @@ -3200,8 +3200,8 @@ def join_path(path):
'ipv4-options': KeyInfo(can_disable=True),
'jump-target': KeyInfo(can_disable=True),
'limit': KeyInfo(can_disable=True),
'log': KeyInfo(can_disable=True),
'log-prefix': KeyInfo(can_disable=True),
'log': KeyInfo(default=False),
'log-prefix': KeyInfo(default=''),
'nth': KeyInfo(can_disable=True),
'out-bridge-port': KeyInfo(can_disable=True),
'out-bridge-port-list': KeyInfo(can_disable=True),
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/plugins/modules/test_api_find_and_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,20 +620,26 @@ def test_change_remove_generic(self):
'comment': 'defconf',
'protocol': 'icmp',
'disabled': False,
'log': False,
'log-prefix': '',
},
{
'.id': '*3',
'action': 'accept',
'chain': 'input',
'comment': 'defconf',
'disabled': False,
'log': False,
'log-prefix': '',
},
{
'.id': '*4',
'action': 'accept',
'chain': 'input',
'comment': 'defconf',
'disabled': False,
'log': False,
'log-prefix': '',
},
{
'.id': '*7',
Expand All @@ -642,6 +648,8 @@ def test_change_remove_generic(self):
'comment': 'defconf',
'disabled': False,
'in-interface': 'wan',
'log': False,
'log-prefix': '',
},
{
'.id': '*8',
Expand All @@ -650,6 +658,8 @@ def test_change_remove_generic(self):
'comment': 'defconf',
'connection-state': 'established',
'disabled': False,
'log': False,
'log-prefix': '',
},
{
'.id': '*9',
Expand All @@ -658,6 +668,8 @@ def test_change_remove_generic(self):
'comment': 'defconf',
'connection-state': 'related',
'disabled': False,
'log': False,
'log-prefix': '',
},
{
'.id': '*A',
Expand All @@ -666,6 +678,8 @@ def test_change_remove_generic(self):
'comment': 'defconf',
'connection-status': 'invalid',
'disabled': False,
'log': False,
'log-prefix': '',
},
])
self.assertEqual(result['match_count'], 3)
Expand Down