From ad9d7c3829ea94fe4f6a7e6c99a20a60f88c5d3f Mon Sep 17 00:00:00 2001 From: Tomas Herfert <68421396+therfert@users.noreply.github.com> Date: Sat, 12 Nov 2022 16:08:25 +0100 Subject: [PATCH] Support for additional API paths (#125) * adding api path interface pppoe-client Signed-off-by: Tomas Herfert * support for api path interface vlan Signed-off-by: Tomas Herfert * support for api path interface bridge vlan Signed-off-by: Tomas Herfert * PR ID update Signed-off-by: Tomas Herfert * typo fix Signed-off-by: Tomas Herfert * support for API path interface bridge and update of interface bridge port ingress-filtering to True Signed-off-by: Tomas Herfert * Apply suggestion per code review Signed-off-by: Tomas Herfert * Update changelogs/fragments/125-api.yml Co-authored-by: Felix Fontein Signed-off-by: Tomas Herfert Co-authored-by: Tomas Herfert Co-authored-by: Felix Fontein --- changelogs/fragments/125-api.yml | 6 +++ plugins/module_utils/_api_data.py | 67 +++++++++++++++++++++++++++++-- plugins/modules/api_info.py | 4 ++ plugins/modules/api_modify.py | 4 ++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/125-api.yml diff --git a/changelogs/fragments/125-api.yml b/changelogs/fragments/125-api.yml new file mode 100644 index 00000000..582623e3 --- /dev/null +++ b/changelogs/fragments/125-api.yml @@ -0,0 +1,6 @@ +minor_changes: + - api_modify, api_info - support API paths ``interface pppoe-client``, ``interface vlan``, ``interface bridge``, ``interface bridge vlan`` + (https://github.com/ansible-collections/community.routeros/pull/125). +bugfixes: + - api_modify, api_info - the default of the field ``ingress-filtering`` in ``interface bridge port`` is now ``true``, which is the default in ROS + (https://github.com/ansible-collections/community.routeros/pull/125). diff --git a/plugins/module_utils/_api_data.py b/plugins/module_utils/_api_data.py index aa63a642..2e9572cf 100644 --- a/plugins/module_utils/_api_data.py +++ b/plugins/module_utils/_api_data.py @@ -79,25 +79,29 @@ def join_path(path): PATHS = { ('interface', 'bridge'): APIData( - # fully_understood=True, + fully_understood=True, primary_keys=('name', ), fields={ - 'admin-mac': KeyInfo(), + 'admin-mac': KeyInfo(default=''), 'ageing-time': KeyInfo(default='5m'), 'arp': KeyInfo(default='enabled'), 'arp-timeout': KeyInfo(default='auto'), - 'auto-mac': KeyInfo(default=False), + 'auto-mac': KeyInfo(default=True), 'comment': KeyInfo(can_disable=True, remove_value=''), 'dhcp-snooping': KeyInfo(default=False), 'disabled': KeyInfo(default=False), + 'ether-type': KeyInfo(default='0x8100'), 'fast-forward': KeyInfo(default=True), + 'frame-types': KeyInfo(default='admit-all'), 'forward-delay': KeyInfo(default='15s'), 'igmp-snooping': KeyInfo(default=False), + 'ingress-filtering': KeyInfo(default=True), 'max-message-age': KeyInfo(default='20s'), 'mtu': KeyInfo(default='auto'), 'name': KeyInfo(), 'priority': KeyInfo(default='0x8000'), 'protocol-mode': KeyInfo(default='rstp'), + 'pvid': KeyInfo(default=1), 'transmit-hold-count': KeyInfo(default=6), 'vlan-filtering': KeyInfo(default=False), }, @@ -173,6 +177,49 @@ def join_path(path): 'use-peer-dns': KeyInfo(), }, ), + ('interface', 'pppoe-client'): APIData( + fully_understood=True, + primary_keys=('name', ), + fields={ + 'ac-name': KeyInfo(default=''), + 'add-default-route': KeyInfo(default=False), + 'allow': KeyInfo(default='pap,chap,mschap1,mschap2'), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'default-route-distance': KeyInfo(default=1), + 'dial-on-demand': KeyInfo(default=False), + 'disabled': KeyInfo(default=True), + 'host-uniq': KeyInfo(can_disable=True), + 'interface': KeyInfo(required=True), + 'keepalive-timeout': KeyInfo(default=10), + 'max-mru': KeyInfo(default='auto'), + 'max-mtu': KeyInfo(default='auto'), + 'mrru': KeyInfo(default='disabled'), + 'name': KeyInfo(), + 'password': KeyInfo(default=''), + 'profile': KeyInfo(default='default'), + 'service-name': KeyInfo(default=''), + 'use-peer-dns': KeyInfo(default=False), + 'user': KeyInfo(default=''), + }, + ), + ('interface', 'vlan'): APIData( + fully_understood=True, + primary_keys=('name', ), + fields={ + 'arp': KeyInfo(default='enabled'), + 'arp-timeout': KeyInfo(default='auto'), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'disabled': KeyInfo(default=False), + 'interface': KeyInfo(required=True), + 'loop-protect': KeyInfo(default='default'), + 'loop-protect-disable-time': KeyInfo(default='5m'), + 'loop-protect-send-interval': KeyInfo(default='5s'), + 'mtu': KeyInfo(default=1500), + 'name': KeyInfo(), + 'use-service-tag': KeyInfo(default=False), + 'vlan-id': KeyInfo(required=True), + }, + ), ('interface', 'wireless', 'security-profiles'): APIData( unknown_mechanism=True, # primary_keys=('default', ), @@ -486,7 +533,7 @@ def join_path(path): 'frame-types': KeyInfo(default='admit-all'), 'horizon': KeyInfo(default='none'), 'hw': KeyInfo(default=True), - 'ingress-filtering': KeyInfo(default=False), + 'ingress-filtering': KeyInfo(default=True), 'interface': KeyInfo(), 'internal-path-cost': KeyInfo(default=10), 'learn': KeyInfo(default='auto'), @@ -531,6 +578,18 @@ def join_path(path): 'use-ip-firewall-for-vlan': KeyInfo(default=False), }, ), + ('interface', 'bridge', 'vlan'): APIData( + fully_understood=True, + primary_keys=('bridge', 'vlan-ids', ), + fields={ + 'bridge': KeyInfo(), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'disabled': KeyInfo(default=False), + 'tagged': KeyInfo(default=''), + 'untagged': KeyInfo(default=''), + 'vlan-ids': KeyInfo(), + }, + ), ('ip', 'firewall', 'connection', 'tracking'): APIData( single_value=True, fully_understood=True, diff --git a/plugins/modules/api_info.py b/plugins/modules/api_info.py index 8baa4185..5cc5075d 100644 --- a/plugins/modules/api_info.py +++ b/plugins/modules/api_info.py @@ -44,10 +44,12 @@ # BEGIN PATH LIST - caps-man aaa - certificate settings + - interface bridge - interface bridge port - interface bridge port-controller - interface bridge port-extender - interface bridge settings + - interface bridge vlan - interface detect-internet - interface ethernet - interface ethernet switch @@ -56,8 +58,10 @@ - interface list - interface list member - interface ovpn-server server + - interface pppoe-client - interface pptp-server server - interface sstp-server server + - interface vlan - interface wireless align - interface wireless cap - interface wireless sniffer diff --git a/plugins/modules/api_modify.py b/plugins/modules/api_modify.py index b657f9f6..d83cc70b 100644 --- a/plugins/modules/api_modify.py +++ b/plugins/modules/api_modify.py @@ -49,10 +49,12 @@ # BEGIN PATH LIST - caps-man aaa - certificate settings + - interface bridge - interface bridge port - interface bridge port-controller - interface bridge port-extender - interface bridge settings + - interface bridge vlan - interface detect-internet - interface ethernet - interface ethernet switch @@ -61,8 +63,10 @@ - interface list - interface list member - interface ovpn-server server + - interface pppoe-client - interface pptp-server server - interface sstp-server server + - interface vlan - interface wireless align - interface wireless cap - interface wireless sniffer