changed collection arg to argregate on 2.4 network modules (#26649)

* changed collection arg to argregate on 2.4 network modules

* replace users with aggregate in eos_user, junos_user, nxos_user

* added version_added to places where we replaced users with aggregate in the docs

* fix ios_static_route test

* update tests to reference aggregate instead of collection/users
This commit is contained in:
David Newswanger 2017-07-26 10:09:17 -04:00 committed by Peter Sprygada
commit 8643e9cb34
42 changed files with 170 additions and 167 deletions

View file

@ -47,11 +47,11 @@ options:
description:
- Admin distance of the static route.
default: 1
collection:
aggregate:
description: List of static route definitions
purge:
description:
- Purge static routes not defined in the collections parameter.
- Purge static routes not defined in the aggregates parameter.
default: no
state:
description:
@ -74,9 +74,9 @@ EXAMPLES = """
next_hop: 10.0.0.1
state: absent
- name: configure collections of static routes
- name: configure aggregates of static routes
ios_static_route:
collection:
aggregate:
- { prefix: 192.168.2.0, mask 255.255.255.0, next_hop: 10.0.0.1 }
- { prefix: 192.168.3.0, mask 255.255.255.0, next_hop: 10.0.2.1 }
"""
@ -146,8 +146,8 @@ def map_config_to_obj(module):
def map_params_to_obj(module):
obj = []
if 'collection' in module.params and module.params['collection']:
for c in module.params['collection']:
if 'aggregate' in module.params and module.params['aggregate']:
for c in module.params['aggregate']:
d = c.copy()
if 'state' not in d:
@ -182,15 +182,15 @@ def main():
mask=dict(type='str'),
next_hop=dict(type='str'),
admin_distance=dict(default=1, type='int'),
collection=dict(type='list'),
aggregate=dict(type='list'),
purge=dict(type='bool'),
state=dict(default='present', choices=['present', 'absent'])
)
argument_spec.update(ios_argument_spec)
required_one_of = [['collection', 'prefix']]
required_one_of = [['aggregate', 'prefix']]
required_together = [['prefix', 'mask', 'next_hop']]
mutually_exclusive = [['collection', 'prefix']]
mutually_exclusive = [['aggregate', 'prefix']]
module = AnsibleModule(argument_spec=argument_spec,
required_one_of=required_one_of,

View file

@ -28,11 +28,11 @@ DOCUMENTATION = """
module: ios_user
version_added: "2.4"
author: "Trishna Guha (@trishnag)"
short_description: Manage the collection of local users on Cisco IOS device
short_description: Manage the aggregate of local users on Cisco IOS device
description:
- This module provides declarative management of the local usernames
configured on network devices. It allows playbooks to manage
either individual usernames or the collection of usernames in the
either individual usernames or the aggregate of usernames in the
current running config. It also supports purging usernames from the
configuration that are not explicitly defined.
options:
@ -46,7 +46,7 @@ options:
description:
- The username to be configured on the Cisco IOS device.
This argument accepts a string value and is mutually exclusive
with the C(collection) argument.
with the C(aggregate) argument.
Please note that this option is not same as C(provider username).
password:
description:
@ -256,20 +256,20 @@ def map_params_to_obj(module):
elif not module.params['name']:
module.fail_json(msg='username is required')
else:
collection = [{'name': module.params['name']}]
aggregate = [{'name': module.params['name']}]
else:
collection = list()
aggregate = list()
for item in users:
if not isinstance(item, dict):
collection.append({'name': item})
aggregate.append({'name': item})
elif 'name' not in item:
module.fail_json(msg='name is required')
else:
collection.append(item)
aggregate.append(item)
objects = list()
for item in collection:
for item in aggregate:
get_value = partial(get_param_value, item=item, module=module)
item['password'] = get_value('password')
item['nopassword'] = get_value('nopassword')
@ -298,7 +298,7 @@ def main():
""" main entry point for module execution
"""
argument_spec = dict(
users=dict(type='list', aliases=['collection']),
users=dict(type='list', aliases=['aggregate']),
name=dict(),
password=dict(no_log=True),