2.5 Plugin Environment support and Testcases for dellos6 modules (#34890)

* Dellos6_2.5_support

* cleanup

* Fix pep8

* fix waitfor

* fix_facts

* fix_assert
This commit is contained in:
abirami-n 2018-01-22 18:04:21 +05:30 committed by John R Barker
commit 775118aae2
24 changed files with 1017 additions and 147 deletions

View file

@ -12,7 +12,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
---
module: dellos6_command
@ -34,7 +33,7 @@ options:
configured provider. The resulting output from the command
is returned. If the I(wait_for) argument is provided, the
module is not returned until the condition is satisfied or
the number of I(retries) as expired.
the number of retries has expired.
required: true
wait_for:
description:
@ -45,6 +44,19 @@ options:
See examples.
required: false
default: null
version_added: "2.2"
match:
description:
- The I(match) argument is used in conjunction with the
I(wait_for) argument to specify the match policy. Valid
values are C(all) or C(any). If the value is set to C(all)
then all conditionals in the wait_for must be satisfied. If
the value is set to C(any) then only one of the values must be
satisfied.
required: false
default: all
choices: ['any', 'all']
version_added: "2.5"
retries:
description:
- Specifies the number of retries a command should be tried
@ -64,43 +76,30 @@ options:
"""
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
vars:
cli:
host: "{{ inventory_hostname }}"
username: admin
password: admin
transport: cli
tasks:
- name: run show version on remote devices
dellos6_command:
commands: show version
provider: "{{ cli }}"
- name: run show version on remote devices
dellos6_command:
commands: show version
- name: run show version and check to see if output contains Dell
dellos6_command:
commands: show version
wait_for: result[0] contains Dell
provider: "{{ cli }}"
- name: run show version and check to see if output contains Dell
dellos6_command:
commands: show version
wait_for: result[0] contains Dell
- name: run multiple commands on remote nodes
dellos6_command:
commands:
- show version
- show interfaces
provider: "{{ cli }}"
- name: run multiple commands on remote nodes
dellos6_command:
commands:
- show version
- show interfaces
- name: run multiple commands and evaluate the output
dellos6_command:
commands:
- show version
- show interfaces
wait_for:
- result[0] contains Dell
- result[1] contains Access
provider: "{{ cli }}"
- name: run multiple commands and evaluate the output
dellos6_command:
commands:
- show version
- show interfaces
wait_for:
- result[0] contains Dell
- result[1] contains Access
"""
RETURN = """
@ -109,19 +108,16 @@ stdout:
returned: always apart from low level errors (such as action plugin)
type: list
sample: ['...', '...']
stdout_lines:
description: The value of stdout split into a list
returned: always apart from low level errors (such as action plugin)
type: list
sample: [['...', '...'], ['...'], ['...']]
failed_conditions:
description: The list of conditionals that have failed
returned: failed
type: list
sample: ['...', '...']
warnings:
description: The list of warnings (if any) generated by module based on arguments
returned: always
@ -220,11 +216,11 @@ def main():
msg = 'One or more conditional statements have not be satisfied'
module.fail_json(msg=msg, failed_conditions=failed_conditions)
result = {
result.update({
'changed': False,
'stdout': responses,
'stdout_lines': list(to_lines(responses))
}
})
module.exit_json(**result)