Skip to content

Commit

Permalink
Handle platform os version for sandbox nxos_nxapi (ansible#34490)
Browse files Browse the repository at this point in the history
Signed-off-by: Trishna Guha <[email protected]>
  • Loading branch information
trishnaguha authored Jan 11, 2018
1 parent bfb5264 commit df8b01a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/ansible/modules/network/nxos/nxos_nxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
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']
Expand Down Expand Up @@ -133,10 +133,15 @@

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':
Expand Down
2 changes: 1 addition & 1 deletion test/units/modules/network/nxos/test_nxos_nxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setUp(self):

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()
Expand Down

0 comments on commit df8b01a

Please sign in to comment.