From 1a9b0ae731d49b9b8b249ed12b5e8305208187d9 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Tue, 4 Jul 2017 21:49:26 +0530 Subject: [PATCH] Remove xml return for junos declarative modules (#26400) * Remove xml return * Add diff return * Related doc changes --- .../network/interface/net_interface.py | 15 +---------- .../modules/network/interface/net_linkagg.py | 2 +- .../modules/network/junos/junos_banner.py | 16 +++++------- .../modules/network/junos/junos_interface.py | 19 ++++++-------- .../modules/network/junos/junos_logging.py | 25 ++++++++----------- .../modules/network/junos/junos_system.py | 22 ++++++++-------- .../modules/network/junos/junos_user.py | 12 ++++++++- .../modules/network/junos/junos_vlan.py | 15 ++++++----- .../modules/network/layer2/net_vlan.py | 9 +------ lib/ansible/modules/network/layer3/net_vrf.py | 2 +- .../modules/network/system/net_banner.py | 13 +--------- .../modules/network/system/net_logging.py | 16 +----------- .../modules/network/system/net_system.py | 15 +---------- 13 files changed, 62 insertions(+), 119 deletions(-) diff --git a/lib/ansible/modules/network/interface/net_interface.py b/lib/ansible/modules/network/interface/net_interface.py index 780ddf5719..991003da8e 100644 --- a/lib/ansible/modules/network/interface/net_interface.py +++ b/lib/ansible/modules/network/interface/net_interface.py @@ -107,22 +107,9 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - interface 20 - 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: > - - - ge-0/0/0 - test interface - - """ diff --git a/lib/ansible/modules/network/interface/net_linkagg.py b/lib/ansible/modules/network/interface/net_linkagg.py index bfbe01f2ac..fdd6eab784 100644 --- a/lib/ansible/modules/network/interface/net_linkagg.py +++ b/lib/ansible/modules/network/interface/net_linkagg.py @@ -82,7 +82,7 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - set interfaces bonding bond0 diff --git a/lib/ansible/modules/network/junos/junos_banner.py b/lib/ansible/modules/network/junos/junos_banner.py index 9e5f00b184..6cdef2c34d 100644 --- a/lib/ansible/modules/network/junos/junos_banner.py +++ b/lib/ansible/modules/network/junos/junos_banner.py @@ -101,16 +101,13 @@ EXAMPLES = """ """ RETURN = """ -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device +diff: + description: Configuration difference before and after applying change. + returned: when configuration is changed. type: string sample: > - - - this is my login banner - - " + [edit system login] + + message \"this is my login banner\"; """ import collections @@ -182,8 +179,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff}, - 'rpc': tostring(ele) + 'diff': diff, }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/junos/junos_interface.py b/lib/ansible/modules/network/junos/junos_interface.py index 2b6de72cbb..2b49a4301f 100644 --- a/lib/ansible/modules/network/junos/junos_interface.py +++ b/lib/ansible/modules/network/junos/junos_interface.py @@ -129,17 +129,15 @@ EXAMPLES = """ """ RETURN = """ -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device +diff: + description: Configuration difference before and after applying change. + returned: when configuration is changed. type: string sample: > - - - ge-0/0/0 - test interface - - + [edit interfaces] + + ge-0/0/1 { + + description test-interface; + + } """ import collections @@ -240,8 +238,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff}, - 'rpc': tostring(ele) + 'diff': diff, }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/junos/junos_logging.py b/lib/ansible/modules/network/junos/junos_logging.py index e5f93f7599..ff46c29b55 100644 --- a/lib/ansible/modules/network/junos/junos_logging.py +++ b/lib/ansible/modules/network/junos/junos_logging.py @@ -111,18 +111,17 @@ EXAMPLES = """ """ RETURN = """ -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device +diff: + description: Configuration difference before and after applying change. + returned: when configuration is changed. type: string sample: > - - - - pfe - - - + [edit system syslog] + + [edit system syslog] + file interactive-commands { ... } + + file test { + + pfe critical; + + } """ import collections @@ -186,11 +185,8 @@ def main(): ('dest', 'user', ['name', 'facility', 'level']), ('dest', 'console', ['facility', 'level'])] - mutually_exclusive = [('console', 'name')] - module = AnsibleModule(argument_spec=argument_spec, required_if=required_if, - mutually_exclusive=mutually_exclusive, supports_check_mode=True) warnings = list() @@ -240,8 +236,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff}, - 'rpc': tostring(ele) + 'diff': diff, }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/junos/junos_system.py b/lib/ansible/modules/network/junos/junos_system.py index a1bc342787..674e10167f 100644 --- a/lib/ansible/modules/network/junos/junos_system.py +++ b/lib/ansible/modules/network/junos/junos_system.py @@ -100,17 +100,18 @@ EXAMPLES = """ """ RETURN = """ -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device +diff: + description: Configuration difference before and after applying change. + returned: when configuration is changed. type: string sample: > - - - ge-0/0/0 - test interface - - + [edit system] + + host-name test; + + domain-name ansible.com; + + domain-search redhat.com; + [edit system name-server] + 172.26.1.1 { ... } + + 8.8.8.8; """ import collections @@ -190,8 +191,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff}, - 'rpc': tostring(ele) + 'diff': diff, }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/junos/junos_user.py b/lib/ansible/modules/network/junos/junos_user.py index e0daf5fb2c..d144888cae 100644 --- a/lib/ansible/modules/network/junos/junos_user.py +++ b/lib/ansible/modules/network/junos/junos_user.py @@ -118,6 +118,16 @@ EXAMPLES = """ """ 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 @@ -265,7 +275,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff} + 'diff': diff }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/junos/junos_vlan.py b/lib/ansible/modules/network/junos/junos_vlan.py index 5f6ef3750e..f51f065479 100644 --- a/lib/ansible/modules/network/junos/junos_vlan.py +++ b/lib/ansible/modules/network/junos/junos_vlan.py @@ -98,11 +98,15 @@ EXAMPLES = """ """ RETURN = """ -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device +diff: + description: Configuration difference before and after applying change. + returned: when configuration is changed. type: string - sample: "test-vlan-4" + sample: > + [edit vlans] + + test-vlan-1 { + + vlan-id 60; + + } """ import collections @@ -181,8 +185,7 @@ def main(): if diff: result.update({ 'changed': True, - 'diff': {'prepared': diff}, - 'rpc': tostring(ele) + 'diff': diff, }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/layer2/net_vlan.py b/lib/ansible/modules/network/layer2/net_vlan.py index ea39dcb79c..29663bb67a 100644 --- a/lib/ansible/modules/network/layer2/net_vlan.py +++ b/lib/ansible/modules/network/layer2/net_vlan.py @@ -76,16 +76,9 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - vlan 20 - 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: "test-vlan-4" """ diff --git a/lib/ansible/modules/network/layer3/net_vrf.py b/lib/ansible/modules/network/layer3/net_vrf.py index 36178e058c..69e3b31dda 100644 --- a/lib/ansible/modules/network/layer3/net_vrf.py +++ b/lib/ansible/modules/network/layer3/net_vrf.py @@ -67,7 +67,7 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - vrf definition MANAGEMENT diff --git a/lib/ansible/modules/network/system/net_banner.py b/lib/ansible/modules/network/system/net_banner.py index c1a2f40d57..ff036c8b33 100644 --- a/lib/ansible/modules/network/system/net_banner.py +++ b/lib/ansible/modules/network/system/net_banner.py @@ -78,22 +78,11 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - banner login - this is my login banner - that contains a multiline - string - -rpc: - description: load-configuration RPC send to the device - returned: when configuration is changed on device - type: string - sample: > - - - this is my login banner - - " """ diff --git a/lib/ansible/modules/network/system/net_logging.py b/lib/ansible/modules/network/system/net_logging.py index 101127bb26..a2d34576f4 100644 --- a/lib/ansible/modules/network/system/net_logging.py +++ b/lib/ansible/modules/network/system/net_logging.py @@ -84,22 +84,8 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - 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: > - - - - pfe - - - """ diff --git a/lib/ansible/modules/network/system/net_system.py b/lib/ansible/modules/network/system/net_system.py index 4534483be8..bd55892d79 100644 --- a/lib/ansible/modules/network/system/net_system.py +++ b/lib/ansible/modules/network/system/net_system.py @@ -102,22 +102,9 @@ EXAMPLES = """ RETURN = """ commands: 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 sample: - hostname ios01 - 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: > - - - ge-0/0/0 - test interface - - """