From df8b01aaf768e24d61787c5c3d4d47c946df9912 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Thu, 11 Jan 2018 21:12:00 +0530 Subject: [PATCH] Handle platform os version for sandbox nxos_nxapi (#34490) Signed-off-by: Trishna Guha --- lib/ansible/modules/network/nxos/nxos_nxapi.py | 7 ++++++- test/units/modules/network/nxos/test_nxos_nxapi.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_nxapi.py b/lib/ansible/modules/network/nxos/nxos_nxapi.py index 775c975f00..502ba94653 100644 --- a/lib/ansible/modules/network/nxos/nxos_nxapi.py +++ b/lib/ansible/modules/network/nxos/nxos_nxapi.py @@ -79,7 +79,7 @@ options: the NXAPI feature is configured for the first time. When the C(sandbox) argument is set to True, the developer sandbox URL will accept requests and when the value is set to False, the - sandbox URL is unavailable. + sandbox URL is unavailable. This is supported on NX-OS 7K series. required: false default: no choices: ['yes', 'no'] @@ -133,10 +133,15 @@ from ansible.module_utils.six import iteritems def check_args(module, warnings): device_info = get_capabilities(module) + network_api = device_info.get('network_api', 'nxapi') if network_api == 'nxapi': module.fail_json(msg='module not supported over nxapi transport') + os_platform = device_info['device_info']['network_os_platform'] + if '7K' not in os_platform and module.params['sandbox']: + module.fail_json(msg='sandbox or enable_sandbox is supported on NX-OS 7K series of switches') + state = module.params['state'] if state == 'started': diff --git a/test/units/modules/network/nxos/test_nxos_nxapi.py b/test/units/modules/network/nxos/test_nxos_nxapi.py index 0f10183793..c83432b12c 100644 --- a/test/units/modules/network/nxos/test_nxos_nxapi.py +++ b/test/units/modules/network/nxos/test_nxos_nxapi.py @@ -39,7 +39,7 @@ class TestNxosNxapiModule(TestNxosModule): self.mock_get_capabilities = patch('ansible.modules.network.nxos.nxos_nxapi.get_capabilities') self.get_capabilities = self.mock_get_capabilities.start() - self.get_capabilities.return_value = {'network_api': 'cliconf'} + self.get_capabilities.return_value = {'device_info': {'network_os_platform': 'N7K-C7018'}, 'network_api': 'cliconf'} def tearDown(self): super(TestNxosNxapiModule, self).tearDown()