Remove xml return for junos declarative modules (#26400)

*  Remove xml return
*  Add diff return
*  Related doc changes
pull/26406/head
Ganesh Nalawade 7 years ago committed by GitHub
parent c1ac55147f
commit 1a9b0ae731

@ -107,22 +107,9 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device. description: The list of configuration mode commands to send to the device.
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- interface 20 - interface 20
- name test-interface - name test-interface
rpc:
description: load-configuration RPC send to the device
returned: C(rpc) is returned only for junos device
when configuration is changed on device
type: string
sample: >
<interfaces>
<interface>
<name>ge-0/0/0</name>
<description>test interface</description>
</interface>
</interfaces>
""" """

@ -82,7 +82,7 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- set interfaces bonding bond0 - set interfaces bonding bond0

@ -101,16 +101,13 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
rpc: diff:
description: load-configuration RPC send to the device description: Configuration difference before and after applying change.
returned: when configuration is changed on device returned: when configuration is changed.
type: string type: string
sample: > sample: >
<system> [edit system login]
<login> + message \"this is my login banner\";
<message>this is my login banner</message>
</login>
</system>"
""" """
import collections import collections
@ -182,8 +179,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff}, 'diff': diff,
'rpc': tostring(ele)
}) })
module.exit_json(**result) module.exit_json(**result)

@ -129,17 +129,15 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
rpc: diff:
description: load-configuration RPC send to the device description: Configuration difference before and after applying change.
returned: when configuration is changed on device returned: when configuration is changed.
type: string type: string
sample: > sample: >
<interfaces> [edit interfaces]
<interface> + ge-0/0/1 {
<name>ge-0/0/0</name> + description test-interface;
<description>test interface</description> + }
</interface>
</interfaces>
""" """
import collections import collections
@ -240,8 +238,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff}, 'diff': diff,
'rpc': tostring(ele)
}) })
module.exit_json(**result) module.exit_json(**result)

@ -111,18 +111,17 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
rpc: diff:
description: load-configuration RPC send to the device description: Configuration difference before and after applying change.
returned: when configuration is changed on device returned: when configuration is changed.
type: string type: string
sample: > sample: >
<system> [edit system syslog]
<syslog> + [edit system syslog]
<console replace=\"replace\" active=\"active\"> file interactive-commands { ... }
<name>pfe</name><error/> + file test {
</console> + pfe critical;
</syslog> + }
</system>
""" """
import collections import collections
@ -186,11 +185,8 @@ def main():
('dest', 'user', ['name', 'facility', 'level']), ('dest', 'user', ['name', 'facility', 'level']),
('dest', 'console', ['facility', 'level'])] ('dest', 'console', ['facility', 'level'])]
mutually_exclusive = [('console', 'name')]
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
required_if=required_if, required_if=required_if,
mutually_exclusive=mutually_exclusive,
supports_check_mode=True) supports_check_mode=True)
warnings = list() warnings = list()
@ -240,8 +236,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff}, 'diff': diff,
'rpc': tostring(ele)
}) })
module.exit_json(**result) module.exit_json(**result)

@ -100,17 +100,18 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
rpc: diff:
description: load-configuration RPC send to the device description: Configuration difference before and after applying change.
returned: when configuration is changed on device returned: when configuration is changed.
type: string type: string
sample: > sample: >
<interfaces> [edit system]
<interface> + host-name test;
<name>ge-0/0/0</name> + domain-name ansible.com;
<description>test interface</description> + domain-search redhat.com;
</interface> [edit system name-server]
</interfaces> 172.26.1.1 { ... }
+ 8.8.8.8;
""" """
import collections import collections
@ -190,8 +191,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff}, 'diff': diff,
'rpc': tostring(ele)
}) })
module.exit_json(**result) module.exit_json(**result)

@ -118,6 +118,16 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
diff:
description: Configuration difference before and after applying change.
returned: when configuration is changed.
type: string
sample: >
[edit system login]
+ user test-user {
+ uid 2005;
+ class read-only;
+ }
""" """
from functools import partial from functools import partial
@ -265,7 +275,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff} 'diff': diff
}) })
module.exit_json(**result) module.exit_json(**result)

@ -98,11 +98,15 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
rpc: diff:
description: load-configuration RPC send to the device description: Configuration difference before and after applying change.
returned: when configuration is changed on device returned: when configuration is changed.
type: string type: string
sample: "<vlans><vlan><name>test-vlan-4</name></vlan></vlans>" sample: >
[edit vlans]
+ test-vlan-1 {
+ vlan-id 60;
+ }
""" """
import collections import collections
@ -181,8 +185,7 @@ def main():
if diff: if diff:
result.update({ result.update({
'changed': True, 'changed': True,
'diff': {'prepared': diff}, 'diff': diff,
'rpc': tostring(ele)
}) })
module.exit_json(**result) module.exit_json(**result)

@ -76,16 +76,9 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- vlan 20 - vlan 20
- name test-vlan - name test-vlan
rpc:
description: load-configuration RPC send to the device
returned: C(rpc) is returned only for junos device
when configuration is changed on device
type: string
sample: "<vlans><vlan><name>test-vlan-4</name></vlan></vlans>"
""" """

@ -67,7 +67,7 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- vrf definition MANAGEMENT - vrf definition MANAGEMENT

@ -78,22 +78,11 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- banner login - banner login
- this is my login banner - this is my login banner
- that contains a multiline - that contains a multiline
- string - string
rpc:
description: load-configuration RPC send to the device
returned: when configuration is changed on device
type: string
sample: >
<system>
<login>
<message>this is my login banner</message>
</login>
</system>"
""" """

@ -84,22 +84,8 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- logging console critical - logging console critical
rpc:
description: load-configuration RPC send to the device
returned: C(rpc) is returned only for junos device
when configuration is changed on device
type: string
sample: >
<system>
<syslog>
<console replace=\"replace\" active=\"active\">
<name>pfe</name><error/>
</console>
</syslog>
</system>
""" """

@ -102,22 +102,9 @@ EXAMPLES = """
RETURN = """ RETURN = """
commands: commands:
description: The list of configuration mode commands to send to the device description: The list of configuration mode commands to send to the device
returned: always returned: always, except for the platforms that use Netconf transport to manage the device.
type: list type: list
sample: sample:
- hostname ios01 - hostname ios01
- ip domain name test.example.com - ip domain name test.example.com
rpc:
description: load-configuration RPC send to the device
returned: C(rpc) is returned only for junos device
when configuration is changed on device
type: string
sample: >
<interfaces>
<interface>
<name>ge-0/0/0</name>
<description>test interface</description>
</interface>
</interfaces>
""" """

Loading…
Cancel
Save