mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Refactor nxos cliconf get_device_info and add requirements for JSON structured output support in nxos_facts module (#42089)
* nxos_facts requires JSON structured output support Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * refactor get_device_info for legacy devices Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update additional logic Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -37,6 +37,9 @@ description:
|
||||
author:
|
||||
- Jason Edelman (@jedelman8)
|
||||
- Gabriele Gerbino (@GGabriele)
|
||||
notes:
|
||||
- This module is only supported on the NX-OS device that supports JSON
|
||||
structured output. NX-OS OS version should be 6.0(2)A8 or 7.x or later.
|
||||
options:
|
||||
gather_subset:
|
||||
description:
|
||||
@@ -169,6 +172,7 @@ vlan_list:
|
||||
import re
|
||||
|
||||
from ansible.module_utils.network.nxos.nxos import run_commands, get_config
|
||||
from ansible.module_utils.network.nxos.nxos import get_capabilities
|
||||
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import string_types, iteritems
|
||||
@@ -538,6 +542,13 @@ def main():
|
||||
|
||||
module = AnsibleModule(argument_spec=spec, supports_check_mode=True)
|
||||
|
||||
capabilities = get_capabilities(module)
|
||||
if capabilities:
|
||||
os_version = capabilities['device_info']['network_os_version']
|
||||
os_version_major = int(os_version[0])
|
||||
if os_version_major < 7 and "6.0(2)A8" not in os_version:
|
||||
module.fail_json(msg="this module requires JSON structured output support on the NX-OS device")
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user