Commit graph

37 commits

Author SHA1 Message Date
Felix Fontein
30a79061f3
Use shared unit test utils from community.internal_test_tools (#353)
* Use shared unit test utils from community.internal_test_tools.

* Make sure community.internal_test_tools is installed in CI.
2025-03-12 21:34:12 +01:00
Felix Fontein
be9a7ed3ad
Improve tests (#348)
* Simplify filter error tests.

* Convert set_module_args to context manager.
2025-03-07 20:45:39 +01:00
liquorice-head
249b1a92e2
Update _api_data.py (#324)
* Update _api_data.py

* Create 324-fix-firewall-log-and-log-prefix.yaml

* Update changelogs/fragments/324-fix-firewall-log-and-log-prefix.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test_api_info.py

* fix tests

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: alsmirnov <alsmirnov@ourgapps.com>
2024-11-23 00:19:05 +01:00
Felix Fontein
0a9b749508
api_modify/api_info: add restrict option (#305)
* Allow to restrict api_info output.

* Allow to restrict what api_modify modifies.

* Add changelog.

* Fix docs.

* Move shared code/docs to module utils and doc fragments.

* Refactor and allow to match by regex.

* Simplify rules, allow to invert rule matcher.

* Add more tests.
2024-08-12 21:16:59 +02:00
derdeagle
ad6faf275d
Fixes #236: Add missing parameters for the "ip firewall" subpaths and set the default value for the "disabled" parameter for most paths (#237)
* Fixes #236: Add missing parameters

The parameters "address-list", "address-list-timeout", and "realm" were
missing for some subpaths of "ip firewall" and are now added.
Additionally the default value of "False" for the "disabled" parameter
has been set so that an e.g. firewall rule, which was disabled
(disabled=True) is enabled (disabled=False) after removing the
"disabled" argument in the data.

Some more parameters can now be removed, e.g. "jump-target", "log", and "log-prefix",
which are not mandatory.

* Add missing changes for #236

Additionally fixed the PR id in the changelog fragment.

* Update changelogs/fragments/237-add-missing-ip-firewall-attributes.yml

Full stop added at the end of the changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/237-add-missing-ip-firewall-attributes.yml

Full stop added at the end of the changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fix unit tests

---------

Co-authored-by: Johannes Münch <git@washiza.eu>
Co-authored-by: Felix Fontein <felix@fontein.de>
2023-12-03 13:02:08 +01:00
Felix Fontein
cf6c79e1b3
Implement basic support for read-only and write-only keys in api_info and api_modify (#213)
* Implement basic support for read-only and write-only keys in api_info and api_modify.

* Do not show write-only fields as 'disabled'.
2023-09-17 14:34:09 +02:00
Felix Fontein
dcc1cf441d
Allow to differ on API paths based on RouterOS version (2/2) (#212)
* Allow to add versioned field for paths.

* The field added in 1aa41ad375 is RouterOS 7.7+.

* The fields added in 2e1159b4c4 are RouterOS 7.5+.
2023-09-01 23:17:47 +02:00
Felix Fontein
4b0995135c
Allow to differ on API paths based on RouterOS version (1/2) (#209)
* Allow to provide definition for path based on API version.

* The paths added in 343c4883c0 are RouterOS 7+.
2023-09-01 22:27:18 +02:00
hansmi
2e1159b4c4
Support "address-list" and "match-subdomain" in static DNS records (#197)
RouterOS 7.5 added `address-list` and `match-subdomain` as fields for
static DNS records.

Changelog: https://forum.mikrotik.com/viewtopic.php?t=188851

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2023-08-20 14:11:04 +02:00
Felix Fontein
4329928474
ip dhcp-client: dhcp-options can be removed with value '' (#154)
* dhcp-options can be removed with value ''.

* Fix handling of disabled keys on creation.

* Fix typo.
2023-03-19 13:14:55 +01:00
Felix Fontein
1dfa79c5ef
Remove unnecessary test imports. (#150) 2023-02-12 21:17:22 +01:00
Andrei Costescu
586edbc211
Add regexp field to ip dns static (#142)
* Add regexp field to "ip dns static"

* Change test_invalid_required_missing to use "ip dhcp-server"

"ip dns static" requires name or regexp so it cannot be used in this test.

* Add required_one_of attribute to APIData

Used by "ip dns static" which requires either "name" or "regexp.

* Add mutually_exclusive attribute to APIData

Used by "ip dns static" where only one of "name" or "regexp" can be used.

* Add changelog fragment
2022-12-29 08:51:40 +01:00
Felix Fontein
d1ff3b2730
Add more tests for api_info and api_modify (#135)
* Add tests for builtin entries.

* Add tests for combined default and can_disable.
2022-11-18 12:55:34 +01:00
Tomas Herfert
5af14a8940
support for new API paths and few updates (#133)
* support for new API paths and few updates

Signed-off-by: Tomas Herfert <herfik>

* changelog fix

Signed-off-by: Tomas Herfert <herfik>

* tests update

Signed-off-by: Tomas Herfert <herfik>

Signed-off-by: Tomas Herfert <herfik>
Co-authored-by: Tomas Herfert <herfik>
2022-11-17 20:14:07 +01:00
Tomas Herfert
23b3aa3beb
API update (#128)
* adding support for api fields that can be disabled and have default value at the same time

Signed-off-by: Tomas Herfert <herfik>

* api path support: interface gre

Signed-off-by: Tomas Herfert <herfik>

* docs

Signed-off-by: Tomas Herfert <herfik>

* unit test update & yamlling fix

Signed-off-by: Tomas Herfert <herfik>

* test fix

Signed-off-by: Tomas Herfert <herfik>

* sanity fix

Signed-off-by: Tomas Herfert <herfik>

* changelog

Signed-off-by: Tomas Herfert <herfik>

* Update per suggestion

Co-authored-by: Felix Fontein <felix@fontein.de>

* api path support: interface eoip

Signed-off-by: Tomas Herfert <herfik>

* docs

Signed-off-by: Tomas Herfert <herfik>

* apply suggestion from code review

Signed-off-by: Tomas Herfert <herfik>

Signed-off-by: Tomas Herfert <herfik>
Co-authored-by: Tomas Herfert <herfik>
Co-authored-by: Felix Fontein <felix@fontein.de>
2022-11-17 12:48:50 +01:00
Felix Fontein
9fc22be186
api_modify, api_info: support more fields in existing paths (#121)
* Support more paths.

* Forgot comma.

* Adjust tests.

* power-cycle-ping-address and power-cycle-ping-timeout can be unset

Co-authored-by: Tomas Herfert <68421396+therfert@users.noreply.github.com>

Co-authored-by: Tomas Herfert <68421396+therfert@users.noreply.github.com>
2022-11-10 21:10:24 +01:00
Felix Fontein
d77cd95f91
Make reuse conformant (#108)
* Add .license files.

* Add reuse test.

* Update README.

* Add changelog fragment.

* Normalize licenses extra sanity test.

* Declare REUSE conformance.

* Update README.
2022-08-21 08:31:42 +02:00
Felix Fontein
f797b4a231
Support absent values. Support absent value 'all' for 'server' in /ip dhcp-server lease. (#107) 2022-08-13 10:55:37 +02:00
Felix Fontein
2911710f1b
Add api_info and api_modify modules (#91)
* Add api_info and api_modify modules.

* Add documentation, and cross-references for the modules.

* Bump version added for new modules.

* Ignore dynamic entries. Allow _info module to return them.

* Document behavior for dynamic entries.

* Update license headers.

* Add disclaimer.

* Improve formulation.

* Auto-generate path list in DOCUMENTATION.

* Add test to make sure lists have been generated automatically.
2022-07-31 22:06:19 +02:00
Felix Fontein
7973f58661
Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml, add missing license file (#101)
* Add SPDX license identifiers, mention all licenses in galaxy.yml.

* Add default copyright headers.

* Adjust remaining/missing entries.

* Fix/add more copyright statements.

* Add sanity test.

* Add changelog.

* Add missing license file.

* Remove colon after 'Copyright'.

* Avoid colon after 'Copyright' in lint script.
2022-07-18 23:16:54 +02:00
Felix Fontein
ff66ba9289
Add api_find_and_modify module. (#93) 2022-05-24 18:23:44 +02:00
Nikolay Dachev
d57de117f5
update community.routeros.api query functionality (#63)
* update query to accept multiple librouteros ADN parameters

* update query for new yml strucutre

* add extended_query as separate function:(code in progress)

* extended_query main code is ready for review

* add changelog #63

* small fix for code indentation

* fix pep

* clear all pep issues

* extended_query ready for review (new yml structure)

* small doc fix for std query

* Update changelogs/fragments/63-add-extended_query.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/63-add-extended_query.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update argument spec.

* Other suggestions.

* Fix syntax errors ('is' and 'or' are keywords).

* Make everything work again.

* Add docs, simplify code.

* Add some first tests.

* Do not add fake message when there is no search result.

* Improve tests.

* Fix tests.

* update extened query docs and ros api module examples

* fix pep plugins/modules/api.py:154:1: W293: blank line contains whitespace

* fix extended query example intend

* Update plugins/modules/api.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/api.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix example docs

Co-authored-by: dako <dako@syslin.sof.dachev.lan>
Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-23 14:44:02 +03:00
Felix Fontein
5f912dad16
Improve unit test performance. (Do not install library we do not use in the tests anyway.) (#92) 2022-05-15 22:42:26 +02:00
Felix Fontein
3d80ccec5f
Add api_facts module (#88)
* Add API docs fragment.

* Improve documentation.

* Move API code to api module_utils.

* Improve docs.

* Add api_facts module.

Does not yet support 'config'. I'm not sure whether that's actually
possible with the API.

* Convert subnet to integer if possible.

* Cleanup.

* Linting and fix tests.

* Remove things that make no sense.

* Simplify code.

* Add basic tests.

* Lint.
2022-05-12 16:17:43 +02:00
Felix Fontein
d73eb1c144
Add module_utils and filters for quoting and unquoting (#53)
* Move splitting code to own file.

* Move list to dictionary code to quoting as well.

* Add quoting functionality.

* Add quoting filters.

* Add integration tests to CI.

* Fix bugs, increase coverage.

* Make parsing more strict.

* Extract function parse_argument_value from split_routeros_command to make proper parsing of WHERE possible.

* Adjust expected error message in integration tests.

* Simplify code and improve coverage.

* Add changelog fragment for WHERE strictness in api module.

* Add documenation.

* Fix typo.

* Add documentation references.

* Add example to api module which uses quote_argument_value.

* Fix bug, and add tests which prevent this in the future.

* Add more escape sequence tests.

* Make sure all control characters are quoted.
2021-10-12 00:44:40 +03:00
Felix Fontein
f9d246cd7a
Make command always return changed=true. (#50) 2021-10-09 13:36:14 +02:00
Akim Lindberg
5042905471
fix(api): fixed a bug when splitting the argument string (#45)
* fix(api): fixed a bug when splitting the argument string

* fix(api): added the shlex module for splitting

* fix(api): added the shlex module for splitting

* fix(api): moved shlex.split to self method split_params

* Fix indentation.

* Implement custom splitting algorithm.

* Raise AssertionError in case of internal error.

* Update plugins/modules/api.py

this is correct thanks !

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Nikolay Dachev <nikolay@dachev.info>
2021-09-29 15:02:28 +02:00
Felix Fontein
a88f4c804b
Fix sanity failures (#43)
* Fix sanity failures.

* Add changelog fragment.
2021-08-12 08:53:21 +02:00
Felix Fontein
69682054e1
Allow api module to fail (#39)
* Allow api module to fail.

* Improve error handling.

* Fix api unit tests.

* Add very basic tests of return values.

* Update api.py

fix ignoring the Fail task if we get TrapError

* Do not mangle fail result, and adjust tests.

* Improve changelog fragment.

* Reclassify changelog fragment as minor_changes, improve text.

* Mark changelog as 'breaking change'.

Co-authored-by: Nikolay Dachev <nikolay@dachev.info>
2021-07-11 15:53:22 +02:00
Felix Fontein
937aa0dbfa
Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#38)
* Replace ansible.module_utils._text by ansible.module_utils.common.text.converters.

* One more.
2021-06-27 09:53:45 +02:00
Petr Klíma
1c18d34536
Verbose config extra fact (#23)
* allow nonverbose idempotent config

* nonverbose config output

* typpo

* typpo

* release fragment

* config extra fact

* add fact ansible_net_config_nonverbose

* unit tests

* changelog fragments

* remove version fragment

* remove extra debug printf()

* update chlog fragment

* corrections for upstream pull request

* corrections for upstream pull request

* typo in changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* typo in filename

Co-authored-by: Petr Klima <petr.klima@madeta.cz>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-03-29 19:05:10 +02:00
Felix Fontein
1b9c46fbe5 Initial cleanup. 2020-10-26 15:18:40 +01:00
Renato Almeida de Oliveira
5dd6ae782a Set export on Config to verbose (#104)
* Set export on Config to verbose

SUMMARY
In the configuration export session i think that using /export verbose is better than just /export, because with export only some configurations sections are going to be missed like BGP configuration, as proposed in https://github.com/ansible/ansible/pull/67868

ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
facts.py

ADDITIONAL INFORMATION
extract of the output with /export verbose

# software id =
#
#
#
/interface ethernet
set [ find default-name=ether1 ] advertise=\
    10M-half,10M-full,100M-half,100M-full,1000M-full arp=enabled arp-timeout=\
    auto auto-negotiation=yes cable-settings=default disable-running-check=\
    yes disabled=no full-duplex=yes loop-protect=default \
    loop-protect-disable-time=5m loop-protect-send-interval=5s mac-address=\
    50:00:00:02:00:00 mtu=1500 name=ether1 orig-mac-address=50:00:00:02:00:00 \
    rx-flow-control=off speed=1Gbps tx-flow-control=off
set [ find default-name=ether2 ] advertise=\
    10M-half,10M-full,100M-half,100M-full,1000M-full arp=enabled arp-timeout=\
    auto auto-negotiation=yes cable-settings=default disable-running-check=\
    yes disabled=no full-duplex=yes loop-protect=default \
    loop-protect-disable-time=5m loop-protect-send-interval=5s mac-address=\
    50:00:00:02:00:01 mtu=1500 name=ether2 orig-mac-address=50:00:00:02:00:01 \
    rx-flow-control=off speed=1Gbps tx-flow-control=off
set [ find default-name=ether3 ] advertise=\
.....
.....
Extract of Output with only /export:
# software id =
#
#
#
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=ether1
<END>

* Create 104_facts_export_verbose

* Update changelogs/fragments/104_facts_export_verbose

Co-authored-by: Felix Fontein <felix@fontein.de>

* Rename export to export_verbose

* Rename 104_facts_export_verbose to 104_facts_export_verbose.yml

Co-authored-by: Felix Fontein <felix@fontein.de>
2020-10-26 15:18:40 +01:00
adeptvin1
f1ae008c4d Update facts (#101)
* Update facts.py

* Update facts.py

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Update plugins/modules/facts.py

Co-authored-by: Egor Zaitsev <heuels@gmail.com>

* Create 101_update_facts.yml

* Update plugins/modules/facts.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/101_update_facts.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* add test default function

* add test data

* Update routing_ospf_neighbor_print_detail_without-paging

* add test function "Routing"

* added information of version

* Removed extra spaces

* add one more version, "ansible_net_cpu_load"

* remove many blank lines

* remove 'too many blank lines'

* renamed arhitec to arch

* Update facts.py

* Update test_facts.py

* Update test_facts.py

* one more

* remove one route

* Update test_facts.py

* remove one neighbor

Co-authored-by: Egor Zaitsev <heuels@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2020-10-26 15:18:40 +01:00
Nikolay Dachev
cc273e7ec1 add api.py (#97)
* add api.py

* fix yaml

* query doc fix

* query doc fix

* fix exmaples

* dummy force retest

* fix small typo in RETURN

* remove no_log which conflict with routeros add param.

* fix pep8

* fix no_log conflict base on issue: password/pass no_log #49465

* ver 1.0.1

* small docs change

* more docs fix

* last one for docs change

* pip8 fix

* Update plugins/modules/api.py

I did not nice that .. Thank you!

Co-authored-by: Felix Fontein <felix@fontein.de>

* remove metadata block

* do not allow empty values to be added in execution path

* Update plugins/modules/api.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* fixes for the last  review

* Apply suggestions from code review

more fixes

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* small changes in examples 'a' vs 'A'

* Apply suggestions from code review

more docs string fixes

Co-authored-by: Felix Fontein <felix@fontein.de>

* fixses in docs, reomve no_logs

* fix example vars

* fix again example a/A

* missing C in C()

* add external conn func

* fix pep8

* fix pep8 test2

* fix pep8 test3

* fix HAS_LIB

* return Ex as e

* fix pep8

* api unit test

* change unit test, change module structure

* pep8 fix

* more pep8

* some progress with unit test

* mm fix

* mock libros fix

* test

* try to fix mock

* test

* test mock

* more unit test

* libtoueros py3 only

* pytest importskyp added

* more unit test

* add update func unit test

* +more unit, fix mutually_exclusive

* fix missed , for module arg

* Apply suggestions from code review

typos fixes

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Update plugins/modules/api.py

will fix others as well

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* fix docs

* small doc fix

* fix missing dots etc. in doc

* unit test completed

* reduce dummy Key func

* fix Key return

* final fix

* fix pep8

* fix pep8

Co-authored-by: root <root@syslin.sof.dachev.lan>
Co-authored-by: Nikolay Dachev <dako@Uranus.sof.dachev.lan>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2020-10-26 15:18:40 +01:00
Jan-Philipp Litza
d26dfa16c7 facts: Allow multiple entries per iface (#6)
* facts: Allow multiple entries per iface

There can be multiple addresses per interface, as well as multiple
neighbors.

This changes the format of "ansible_net_neighbors" to list instead of
dict, because the old format could not store multiple neighbors per
interface.

Also, this fixes a crash when the ipv6 module is not loaded, because the
error "bad command name" was being parsed with interface=None

* facts: Fix tests

* facts: Add changelog fragment
2020-10-26 15:18:40 +01:00
John R Barker
bcfea39ddc Add networking (#1)
Initial commit of network content that was previously in community.general
2020-10-26 15:18:40 +01:00