Commit Graph

86 Commits (main)

Author SHA1 Message Date
Vinay M dda46ee3cf
Fixes tests that use AnsibleUndefined (#383)
* Fixes tests that use AnsibleUndefined

* add change log

* add same for other cases
2024-12-17 13:47:07 +05:30
Andrew J Roth 038bcb163e
fixed ipcut to support ipv4 (#358)
* fixed ipcut to support ipv4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add changelog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com>
Co-authored-by: Ruchi Pakhle <ruchipakhle@gmail.com>
2024-08-02 16:09:34 +05:30
Emanuele Bernardi 540e0d8963
fix from_xml: return python dictionary (#361)
* removed the in between json conversion, now function returns python
dict, changed unit tests to check against the dict.

* remove the json import

* changelog added

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* changed changelog to minor

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com>
Co-authored-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
2024-07-25 22:20:32 +05:30
Ruchi Pakhle 1645351602
Remove Py27 compat files and update imports for magicmock and patch (#342)
* remove compat files and mock imports

* updates

* updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-28 11:30:53 +05:30
Sagar Paul 786fa9891d
[GHA] Update reference for GitHub actions (#318)
* Update reference for GitHub actions

* tox lint file update

* Make names consistent

* ack - check_label

* check source

* fix utils ref

* update lint workflow

* test

* test again

* fix assert statement

* update workflows

* test change

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add back token refresh

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-30 19:25:26 +05:30
Ashwini Mhatre 92903a3a58
Enhance fact_diff to show common lines (#323)
* Enhance fact_diff to show common lines

* Add integration and unit tests

* Fix sanity

---------

Co-authored-by: Ashwini Mhatre <amhatre@amhatre-thinkpadt14sgen2i.pnq.csb>
2024-01-16 17:55:39 +05:30
Ashwini Mhatre 4f07a4afca
fact_diff filter plugin (#310)
* Add fact_diff filter plugin

* Add integration and unit tests

* Add changelog

* Add argspect test

* Add examples

* Fix lint

* Fix ansible-lint

* REvert changes

* Fix sanity

* Address review comments

* Delete tests/integration/inventory

---------

Co-authored-by: Ashwini Mhatre <amhatre@amhatre-thinkpadt14sgen2i.pnq.csb>
2023-11-13 11:28:43 +05:30
Ashwini Mhatre 4deddf2c3b
Feature ipv6 format (#295)
* Create ipv6form.py

* Update ipv6form.py

* Update ipv6form.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add code

* Add docs

* Add uts and integration tests. fix sanity

* iFix sanity

* Fix sanity

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ashwini Mhatre <amhatre@amhatre-thinkpadt14sgen2i.pnq.csb>
2023-08-10 13:40:17 +05:30
Ashwini Mhatre ce5e10c004
Add ipcut filter plugin (#291)
* Add ipcut filter plugin

* Add testcases

* Add testcases

* Fix sanity

* Fix sanity

* Fix sanity

* Fix ansible-lint

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update ipcut.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix sanity

* Fix sanity

* iFix sanity

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ashwini Mhatre <amhatre@amhatre-thinkpadt14sgen2i.pnq.csb>
2023-08-07 16:19:33 +05:30
pre-commit-ci[bot] 1c31436512
[pre-commit.ci] pre-commit autoupdate (#290)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/add-trailing-comma: v2.5.1 → v3.0.0](https://github.com/asottile/add-trailing-comma/compare/v2.5.1...v3.0.0)
- [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.9-for-vscode...v3.0.0)
- [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-19 09:29:35 -04:00
Sebastian Wiesinger c2231a6b20
Update jsonschema validator (#226)
* Update jsonschema validator

Update jsonschema validator to support newer drafts. It now supports
drafts 2019-09 and 2020-12.

The logic for choosing the jsonschema validator class has changed so
that the following enhancements are available:

- When no draft is explicitly specified we now use use the validator
  draft that is specified in the "$schema" field of the criteria. This
  is done by the jsonschema module by default and should support
  possible future drafts without any changes to this code.

- Optionally allow to disable format checks in the code. As format
  checks are not required by the spec there might be situations where
  people want to disable them.

* Update requirements.txt

* Skip all tests which dependas on jsonschema 4.5

* jsonschema: Refactor code to support python 3.6

* Fix jsonschema requirements for python<3.7

* jsonschema: Update code for compatibility

* Better documentation and error handling for missing schema specifications

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ashwini Mhatre <amhatre@redhat.com>
Co-authored-by: ashwini-mhatre <mashu97@gmail.com>
2023-04-05 11:01:12 -04:00
Kate Case 9668f26a26
Update pre-commit config (#245)
* Update pre-commit config
2023-03-29 18:18:57 -04:00
Kate Case 24e53efe5e
Add documentation for IPv6 in ipsubnet filter (#212)
* fix typo. Add example for IPV6

* add unit tests for IPv6

Co-authored-by: serosset <serosset@cisco.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-05 16:00:19 -05:00
Federico Chiacchiaretta 0aee02eb97
Welcome to support for indentation with spaces in to_xml plugin (#192)
* Welcome to support for indentation with spaces in to_xml plugin

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changelog fragment

* Unit tests for:

* Indent with spaces and explicit indent_width (4)
* Invalid indent

I also slightly modified VALID_DATA to produce output with indentation,
so existing test_valid_data and OUTPUT has been updated accordingly.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix changelog section name to minor_changes

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-04 14:13:13 -04:00
Harm Geerts e3e4f7595d
Fix #209 ansible.utils filters should raise AnsibleFilterError (#210)
* Fix #209 ansible.utils filters should raise AnsibleFilterError

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-14 10:55:05 -04:00
Kate Case 462e4e7f71
Clean up test failures (#216)
* Fix arguments-renamed

* Handle changed behavior in 2.15
2022-10-13 11:01:42 -04:00
Tim Way 57c5cd4336
Switch To Calculating Networking Information Directly For Performance (#146)
* Add Unit Tests To Capture Failures From 'subnet' Generator

The netaddr library returns a generator for the 'subnet' call. This works great until you use larger networks. While it is uncommon to encounter it in IPv4 usage it is trivial to hit it in IPv6.

* Switch To Calculating Networking Information Directly For Performance

This replaces the inefficient generator for 'subnet' and uses math to determine the result directly. Since a list is not returned directly to the client in the implemented cases this works great and is fast.

A further optimization at least on the logic of this might be to break the different cases implemented by the filter out into unique functions. I did not do this yet because I wanted to get feedback on this direction.

* Changelog Fragment For PR / Bugfix

Adding changelog fragment that references source issue.

* Dropping Python 3.7 Bypass Removes Need For 'sys' Module

A test for ipsubnet was bypassed under 3.7 because of an inconsistent return value w/3.6 and 2.7. I removed the bypass and changed the behavior of the filter to raise an AnsibleFilterError in all versions of Python.

* Add A Pair of Integration Tests

These demonstrate the issue with the current implementation and would normally stall out while building the list of possible subnets from the generator.

* Address Changelog Feedback

I kept the performance item as a bugfix but bumped the typing to a minor change.

* Add 'netaddr' To Integration Test 'requirements.txt'

* The `ansible-test integration --docker` requires this line in requirements.txt to pass the 'netaddr' related tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Replace str -> to_text

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kate Case <this.is@katherineca.se>
2022-08-31 12:09:35 -04:00
Bradley A. Thornton a0622d06ce
Add trailing comma support to pre-commit (#190) 2022-06-01 18:05:10 +05:30
Bradley A. Thornton 2541cb3f6a
Add isort, increase black line length (#189) 2022-05-26 13:18:57 -04:00
Bradley A. Thornton 4fe771a95c
Enable prettier via pre-commit (#188) 2022-05-26 10:02:52 -04:00
Nathaniel Case e76854d1e1 Move check_mode setting to the proper location regardless of version 2022-04-25 11:11:15 -04:00
cidrblock c533f5c758 Linting and test config 2022-04-13 06:01:59 -07:00
cidrblock 363fac094b Fix 2022-04-11 11:43:15 -07:00
cidrblock 0b67dab6c9 Another init 2022-04-11 07:25:48 -07:00
cidrblock 79c6ad9ae5 Add init 2022-04-11 07:25:47 -07:00
KB-perByte ca31a4e474
update docs 2022-04-11 16:13:46 +05:30
KB-perByte 1ce17fab54
update tests 2022-04-09 11:28:35 +05:30
KB-perByte 595c9ee38f
review pt 1 2022-04-08 23:31:45 +05:30
Bradley A. Thornton 1c4d7faf83
Merge branch 'main' into consolidate 2022-04-07 13:20:12 -07:00
pre-commit-ci[bot] c4ad14f305 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-04-07 03:28:27 -07:00
KB-perByte 02779ae85a
UTs added 2022-04-05 12:23:31 +05:30
KB-perByte 141c175cff
sanity fixex updated 2022-04-04 17:58:09 +05:30
Ashwini Mhatre 0716010fe3
Fix bugs in Ipaddr filters (#149)
Fix bugs in Ipaddr filters

SUMMARY

ipaddr - Fix input validation issues in ipaddr,ipv4,ipv6,ipwrap filters.
ipaddr - Add valid network for link-local
fixes: #148
fixes: ansible-collections/ansible.netcommon#375
fixes: ansible-collections/ansible.netcommon#350

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
2022-03-04 11:43:59 +00:00
Ashwini Mhatre 9f510450f8
Improve ut coverage (#145)
Improve ut coverage

SUMMARY

Add more testcases for ipaddr filter

ISSUE TYPE

COMPONENT NAME

ipaddr.py
ADDITIONAL INFORMATION

Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
2022-03-01 05:06:47 +00:00
Tim Way a14a9337c6
Add 'netaddr' To 'requirements.txt' For Unit Tests (#143)
Add 'netaddr' To 'requirements.txt' For Unit Tests

This enables 'ansible-test --docker' and 'ansible-test --venv' to be able to leverage 'netaddr' and pass tests

SUMMARY

This adds the 'netaddr' python module to the requirements specific to unit tests. This allows 'ansible-test' to work for '--docker' and '--venv' without manual intervention.
I also re-ordered the current list to be alphabetical.

Fixes #142
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

Unit tests in ansible.utils for ipsubnet
ADDITIONAL INFORMATION



git clone https://github.com/ansible-collections/ansible.utils.git
cd ansible.utils
ansible-galaxy collection build .
ansible-galaxy collection install -p . ansible-utils-\*.tar.gz
ansible-test units --docker base tests/unit/plugins/filter/test_ipsubnet.py --requirements --verbose

Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
2022-02-25 07:32:23 +00:00
Nathaniel Case ad9d3e1399
New validate sub-plugin "config" (#112)
New validate sub-plugin "config"

SUMMARY


Implement ansible-collections/ansible.network#15 as a validate sub-plugin.
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

validate

Reviewed-by: Ganesh Nalawade <None>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: None <None>
2022-01-28 00:02:36 +00:00
Sagar Paul 624bc76e26
Recursive filter plugins remove_keys | replace_keys | keep_keys (#110)
Recursive filter plugins remove_keys | replace_keys | keep_keys

SUMMARY

New plugins

remove_keys
replace_keys
keep_keys


ISSUE TYPE


New Module Pull Request

COMPONENT NAME


remove_keys
replace_keys
keep_keys

ADDITIONAL INFORMATION

Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
2022-01-27 06:52:38 +00:00
Ashwini Mhatre ea54e97359
Add hwaddr, macaddr, slaac filter plugin (#129)
Add hwaddr, macaddr, slaac filter plugin

SUMMARY

Added hwaddr, macaddr, slaac filter plugin

ISSUE TYPE

New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Reviewed-by: None <None>
2022-01-24 21:43:18 +00:00
Ashwini Mhatre 4488b79b04
Add ipaddr Filter plugin (#115)
Add ipaddr Filter plugin

SUMMARY

depend-on: #113

ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Reviewed-by: None <None>
2022-01-24 11:15:16 +00:00
Ashwini Mhatre cfc7965400
Add ipwrap filter plugin (#118)
Add ipwrap filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Priyam Sahoo <None>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Reviewed-by: None <None>
2022-01-22 11:27:27 +00:00
Ashwini Mhatre 2aa677777e
Add network_in_usable filter plugin (#126)
Add network_in_usable filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
Reviewed-by: Priyam Sahoo <None>
2022-01-21 20:12:17 +00:00
Ashwini Mhatre 3cb7ea10ca
Add previous_nth_usable filter plugin (#124)
Add previous_nth_usable filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
2022-01-21 18:04:36 +00:00
Ashwini Mhatre 315200166f
Add plugin Reduce_on_network (#127)
Add plugin Reduce_on_network

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
2022-01-21 10:34:01 +00:00
Ashwini Mhatre 234b0a51cf
Add network_in_network filter plugin (#125)
Add network_in_network filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
2022-01-20 19:31:40 +00:00
Ashwini Mhatre 1d697455b6
Add next nth usable filter plugin (#123)
Add next nth usable filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Rohit Thakur <rohitthakur2590@outlook.com>
Reviewed-by: None <None>
Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
2022-01-20 17:30:14 +00:00
Ashwini Mhatre 80b7015fe8
Add ipsubnet filter plugin (#122)
Add ipsubnet filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: None <None>
2022-01-20 15:03:54 +00:00
Ashwini Mhatre c04c648b7a
Add IPV6 filter plugin (#121)
Add IPV6 filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nathaniel Case <this.is@nathanielca.se>
Reviewed-by: None <None>
2022-01-20 13:10:31 +00:00
Ashwini Mhatre 79b28faaaa
Add ipv4_hex filter plugin (#119)
Add ipv4_hex filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Priyam Sahoo <None>
Reviewed-by: None <None>
2022-01-20 11:48:12 +00:00
Ashwini Mhatre 458547c2b6
Add Ipmath filter plugin (#117)
Add Ipmath filter plugin

SUMMARY


ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: None <None>
2022-01-20 09:49:15 +00:00
Ashwini Mhatre 22234f2963
Add cidr_merge filter plugin (#113)
Add cidr_merge filter plugin

SUMMARY

Move ipaddr plugins from netcommon to utils:
cidr_merge filter plugin

ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: None <None>
2022-01-20 08:02:49 +00:00