1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/units/module_utils
Ganesh Nalawade 97a34cf008 Add options sub spec validation (#27119)
* Add aggregate parameter validation

aggregate parameter validation will support checking each individual dict
to resolve conditions for aliases, no_log, mutually_exclusive,
required, type check, values, required_together, required_one_of
and required_if conditions in argspec. It will also set default values.

eg:
tasks:
  - name: Configure interface attribute with aggregate
    net_interface:
      aggregate:
        - {name: ge-0/0/1, description: test-interface-1, duplex: full, state: present}
        - {name: ge-0/0/2, description: test-interface-2, active: False}
    register: response
    purge: Yes

Usage:
```
from ansible.module_utils.network_common import AggregateCollection

transform = AggregateCollection(module)
param = transform(module.params.get('aggregate'))
```

Aggregate allows supports for `purge` parameter, it will instruct the module
to remove resources from remote device that hasn’t been explicitly
defined in aggregate. This is not supported by with_* iterators

Also, it improves performace as compared to with_* iterator for network device
that has seperate candidate and running datastore.
For with_* iteration the sequence of operartion is
load-config-1 (candidate db) -> commit (running db) -> load_config-2
(candidate db) -> commit (running db) ...

With aggregate the sequence of operation is
load-config-1 (candidate db) -> load-config-2 (candidate db) -> commit
(running db)

As commit is executed only once per task for aggregate it has
huge perfomance benefit for large configurations.

* Fix CI issues

* Fix review comments

*  Add support for options validation for aliases, no_log,
   mutually_exclusive, required, type check, value check,
   required_together, required_one_of and required_if
   conditions in sub-argspec.
*  Add unit test for options in argspec.
*  Reverted aggregate implementaion.

* Minor change

* Add multi-level argspec support

*  Multi-level argspec support with module's top most
   conditionals options.

* Fix unit test failure

* Add parent context in errors for sub options

* Resolve merge conflict

* Fix CI issue
2017-08-01 09:32:18 -07:00
..
aws aws.core in new aws dir in module utils - module with AnsibleAWSModule class and fail_json_aws (#25780) 2017-07-11 14:01:35 -07:00
basic add custom module type validation (#27183) 2017-07-26 16:12:50 -07:00
ec2 [cloud] Improve Camel to Snake conversion in EC2 module_utils (#25015) 2017-08-01 11:09:22 -04:00
facts Mv AnsibleFactCollector back to module_utils (#26150) 2017-07-11 10:44:22 -04:00
gcp Fix spelling mistakes (comments only) (#25564) 2017-06-12 07:55:19 +01:00
json_utils test/: PEP8 compliancy (#24803) 2017-05-30 18:05:19 +01:00
parsing Consolidate boolean/mk_boolean conversion functions into a single location 2017-07-17 11:48:05 -07:00
__init__.py Add empty-init code-smell script. (#18406) 2016-11-07 15:02:13 -08:00
test_aci.py ACI module_utils library for ACI modules (#27070) 2017-07-31 12:44:27 +01:00
test_basic.py Add options sub spec validation (#27119) 2017-08-01 09:32:18 -07:00
test_database.py Revert "Update galaxy and database unit tests." 2017-02-09 15:19:01 -08:00
test_distribution_version.py Facts Refresh (2.4 roadmap) (#23012) 2017-06-01 11:17:49 -04:00
test_known_hosts.py test/: PEP8 compliancy (#24803) 2017-05-30 18:05:19 +01:00
test_network_common.py renames dict_combine to dict_merge in network_common (#26073) 2017-06-25 18:46:41 -04:00
test_postgresql.py test/: PEP8 compliancy (#24803) 2017-05-30 18:05:19 +01:00
test_text.py test/: PEP8 compliancy (#24803) 2017-05-30 18:05:19 +01:00